blob: 1188c86069ce9a554b102456585dee54f8bbc483 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam0fb93dd2014-02-19 00:32:59 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
24 * All Rights Reserved.
25 * Qualcomm Atheros Confidential and Proprietary.
26 *
27 */
28
29
Jeff Johnson295189b2012-06-20 16:38:30 -070030/** ------------------------------------------------------------------------- *
31 ------------------------------------------------------------------------- *
Jeff Johnsone7245742012-09-05 17:12:55 -070032
Jeff Johnson295189b2012-06-20 16:38:30 -070033
34 \file csrApiRoam.c
35
36 Implementation for the Common Roaming interfaces.
37
Kiet Lamaa8e15a2014-02-11 23:30:06 -080038 Copyright (C) 2008 Qualcomm, Incorporated
39
Jeff Johnson295189b2012-06-20 16:38:30 -070040
41 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070042/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070043 EDIT HISTORY FOR FILE
44
Jeff Johnson295189b2012-06-20 16:38:30 -070045 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
47
Jeff Johnson295189b2012-06-20 16:38:30 -070048 when who what, where, why
49---------- --- --------------------------------------------------------
5006/03/10 js Added support to hostapd driven
51 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070052===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070053#include "aniGlobal.h" //for tpAniSirGlobal
54#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070055#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070056#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070057#include "palApi.h"
58#include "csrInsideApi.h"
59#include "smsDebug.h"
60#include "logDump.h"
61#include "smeQosInternal.h"
62#include "wlan_qct_tl.h"
63#include "smeInside.h"
64#include "vos_diag_core_event.h"
65#include "vos_diag_core_log.h"
66#include "csrApi.h"
67#include "pmc.h"
68#include "vos_nvitem.h"
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053069#include "macTrace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070070#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
71#include "csrNeighborRoam.h"
72#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080073#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
74#include "csrEse.h"
75#endif /* FEATURE_WLAN_ESE && !FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070076#define CSR_NUM_IBSS_START_CHANNELS_50 4
77#define CSR_NUM_IBSS_START_CHANNELS_24 3
78#define CSR_DEF_IBSS_START_CHANNEL_50 36
79#define CSR_DEF_IBSS_START_CHANNEL_24 1
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080080#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD ( 5 * PAL_TIMER_TO_SEC_UNIT ) // 5 seconds, for WPA, WPA2, CCKM
Jeff Johnson295189b2012-06-20 16:38:30 -070081#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
82/*---------------------------------------------------------------------------
83 OBIWAN recommends [8 10]% : pick 9%
84---------------------------------------------------------------------------*/
85#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070086/*---------------------------------------------------------------------------
87 OBIWAN recommends -85dBm
88---------------------------------------------------------------------------*/
89#define CSR_VCC_RSSI_THRESHOLD 80
90#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
91#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
92#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
93#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -070094//We use constatnt 4 here
95//This macro returns true when higher AC parameter is bigger than lower AC for a difference
96//The bigger the number, the less chance of TX
97//It must put lower AC as the first parameter.
98#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070099//Flag to send/do not send disassoc frame over the air
100#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700101#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700102#define MAX_CB_VALUE_IN_INI (2)
103
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700104#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
105static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
106#endif
107
Jeff Johnson295189b2012-06-20 16:38:30 -0700108/*--------------------------------------------------------------------------
109 Static Type declarations
110 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800111static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800112
Jeff Johnson295189b2012-06-20 16:38:30 -0700113/*--------------------------------------------------------------------------
114 Type declarations
115 ------------------------------------------------------------------------*/
116#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700117int diagAuthTypeFromCSRType(eCsrAuthType authType)
118{
119 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700120 switch(authType)
121 {
122 case eCSR_AUTH_TYPE_SHARED_KEY:
123 n = AUTH_SHARED;
124 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700125 case eCSR_AUTH_TYPE_WPA:
126 n = AUTH_WPA_EAP;
127 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700128 case eCSR_AUTH_TYPE_WPA_PSK:
129 n = AUTH_WPA_PSK;
130 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700131 case eCSR_AUTH_TYPE_RSN:
132 n = AUTH_WPA2_EAP;
133 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700134 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700135#ifdef WLAN_FEATURE_11W
136 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
137#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700138 n = AUTH_WPA2_PSK;
139 break;
140#ifdef FEATURE_WLAN_WAPI
141 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
142 n = AUTH_WAPI_CERT;
143 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700144 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
145 n = AUTH_WAPI_PSK;
146 break;
147#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700148 default:
149 break;
150 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 return (n);
152}
Jeff Johnson295189b2012-06-20 16:38:30 -0700153int diagEncTypeFromCSRType(eCsrEncryptionType encType)
154{
155 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 switch(encType)
157 {
158 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
159 case eCSR_ENCRYPT_TYPE_WEP40:
160 n = ENC_MODE_WEP40;
161 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
163 case eCSR_ENCRYPT_TYPE_WEP104:
164 n = ENC_MODE_WEP104;
165 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 case eCSR_ENCRYPT_TYPE_TKIP:
167 n = ENC_MODE_TKIP;
168 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 case eCSR_ENCRYPT_TYPE_AES:
170 n = ENC_MODE_AES;
171 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700172#ifdef FEATURE_WLAN_WAPI
173 case eCSR_ENCRYPT_TYPE_WPI:
174 n = ENC_MODE_SMS4;
175 break;
176#endif /* FEATURE_WLAN_WAPI */
177 default:
178 break;
179 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 return (n);
181}
Jeff Johnson295189b2012-06-20 16:38:30 -0700182#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700183static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
184static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700185static void initConfigParam(tpAniSirGlobal pMac);
186static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
187 eCsrRoamCompleteResult Result, void *Context );
188static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
189 tCsrRoamProfile *pProfile,
190 tANI_BOOLEAN *pfSameIbss );
191static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
192static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700193 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
194static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700195eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
196static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
197eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
198eHalStatus csrRoamClose(tpAniSirGlobal pMac);
199void csrRoamMICErrorTimerHandler(void *pv);
200void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
201tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
202
203static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
204static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
205static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700206eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
207eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
208static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700209static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700210static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700211static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
212eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
213 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
214 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
215 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
216 tANI_U8 *pKeyRsc );
217static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
218 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
219 tCsrRoamProfile *pProfile );
220void csrRoamStatisticsTimerHandler(void *pv);
221void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700222static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
223VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
224 v_U8_t rssiNotification,
225 void * context);
226static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
227void csrRoamVccTrigger(tpAniSirGlobal pMac);
228eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
229/*
230 pStaEntry is no longer invalid upon the return of this function.
231*/
232static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700233static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700234static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700235tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
236 tDblLinkList *pStaList,
237 tCsrStatsClientReqInfo *pStaEntry);
238void csrRoamStatsClientTimerHandler(void *pv);
239tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
240 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
241void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
242 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700243void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700244void csrRoamTlStatsTimerHandler(void *pv);
245void csrRoamPeStatsTimerHandler(void *pv);
246tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
247void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
248tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
249eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
250static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
251static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
252static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
253static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
254 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
255//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
256static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
257void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
258#ifdef FEATURE_WLAN_BTAMP_UT_RF
259void csrRoamJoinRetryTimerHandler(void *pv);
260#endif
261extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700262extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700263static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700264void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700265
266//Initialize global variables
267static void csrRoamInitGlobals(tpAniSirGlobal pMac)
268{
269 if(pMac)
270 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800271 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
272 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 }
274 return;
275}
276
Jeff Johnson295189b2012-06-20 16:38:30 -0700277static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
278{
279 if(pMac)
280 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800281 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 }
283 return;
284}
Jeff Johnson295189b2012-06-20 16:38:30 -0700285eHalStatus csrOpen(tpAniSirGlobal pMac)
286{
287 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530288#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700289 static uNvTables nvTables;
290 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700291 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530292#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700293 tANI_U32 i;
294
295 do
296 {
297 /* Initialize CSR Roam Globals */
298 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
300 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
301
302 initConfigParam(pMac);
303 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
304 break;
305 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
306 break;
307 pMac->roam.nextRoamId = 1; //Must not be 0
308 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
309 break;
310 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
311 break;
312 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
313 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530314
315#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700316 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
317 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
318 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530319 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
320 WNI_CFG_COUNTRY_CODE_LEN);
321 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700322 }
323 else
324 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800325 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700326 //hardcoded for now
327 pMac->scan.countryCodeDefault[0] = 'U';
328 pMac->scan.countryCodeDefault[1] = 'S';
329 pMac->scan.countryCodeDefault[2] = 'I';
330 //status = eHAL_STATUS_SUCCESS;
331 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700332 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530333
334 if (!('0' == pMac->scan.countryCodeDefault[0] &&
335 '0' == pMac->scan.countryCodeDefault[1]))
336 {
337 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
338 &regId, COUNTRY_NV);
339 }
340 else
341 {
342 regId = REGDOMAIN_WORLD;
343 }
Abhishek Singha306a442013-11-07 18:39:01 +0530344 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 pMac->scan.domainIdDefault = regId;
346 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530347 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
348 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530350#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 }while(0);
352
353 return (status);
354}
355
Mihir Shetee1093ba2014-01-21 20:13:32 +0530356/* --------------------------------------------------------------------------
357 \fn csrInitChannels
358 \brief This function must be called to initialize CSR channel lists
359 \return eHalStatus
360 ----------------------------------------------------------------------------*/
361eHalStatus csrInitChannels(tpAniSirGlobal pMac)
362{
363 eHalStatus status = eHAL_STATUS_SUCCESS;
364 static uNvTables nvTables;
365 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
366 v_REGDOMAIN_t regId;
367
368 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
369 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
370 {
371 vos_mem_copy(pMac->scan.countryCodeDefault,
372 nvTables.defaultCountryTable.countryCode,
373 WNI_CFG_COUNTRY_CODE_LEN);
374 }
375 else
376 {
377 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
378 //hardcoded for now
379 pMac->scan.countryCodeDefault[0] = 'U';
380 pMac->scan.countryCodeDefault[1] = 'S';
381 pMac->scan.countryCodeDefault[2] = 'I';
382 }
383 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
384
385 if (!('0' == pMac->scan.countryCodeDefault[0] &&
386 '0' == pMac->scan.countryCodeDefault[1]))
387 {
388 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
389 &regId, COUNTRY_NV);
390 }
391 else
392 {
393 regId = REGDOMAIN_WORLD;
394 }
395
396 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
397 pMac->scan.domainIdDefault = regId;
398 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
399 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
400 WNI_CFG_COUNTRY_CODE_LEN);
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530401 vos_mem_copy(pMac->scan.countryCodeElected, pMac->scan.countryCodeDefault,
402 WNI_CFG_COUNTRY_CODE_LEN);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530403 status = csrInitGetChannels( pMac );
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530404 csrClearVotesForCountryInfo(pMac);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530405
406 return status;
407}
408
Jeff Johnson295189b2012-06-20 16:38:30 -0700409eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
410{
411 eHalStatus status = eHAL_STATUS_SUCCESS;
412 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
413 v_REGDOMAIN_t regId;
414 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 if(NULL == apCntryCode)
416 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530417 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700418 return eHAL_STATUS_FAILURE;
419 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530420 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700421 /* To get correct Regulatory domain from NV table
422 * 2 character Country code should be used
423 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700424 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
425/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700426 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700427
428 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
429 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800430 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700431 return eHAL_STATUS_FAILURE;
432 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700433*/
Kiet Lam6c583332013-10-14 05:37:09 +0530434 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
435 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700436 if (status != eHAL_STATUS_SUCCESS)
437 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700438 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700439 return status;
440 }
Abhishek Singha306a442013-11-07 18:39:01 +0530441 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700442 if (status != eHAL_STATUS_SUCCESS)
443 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700444 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700445 return status;
446 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 pMac->scan.domainIdDefault = regId;
448 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700449 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530450 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
451
Jeff Johnson295189b2012-06-20 16:38:30 -0700452 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530453 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
454
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 /* If 2 bytes country code, 3rd byte must be filled with space */
456 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
457 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530458 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700459 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530460 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
461 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700463 return status;
464}
Jeff Johnson295189b2012-06-20 16:38:30 -0700465eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
466{
467 eHalStatus status = eHAL_STATUS_SUCCESS;
468 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
469 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530470 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
471 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700472 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
473 {
474 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
475 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
476 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
477 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
478 }
479 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
480
481 return status;
482}
Jeff Johnson295189b2012-06-20 16:38:30 -0700483eHalStatus csrClose(tpAniSirGlobal pMac)
484{
485 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800486
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 csrRoamClose(pMac);
488 csrScanClose(pMac);
489 csrLLClose(&pMac->roam.statsClientReqList);
490 csrLLClose(&pMac->roam.peStatsReqList);
491 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 /* DeInit Globals */
493 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700494 return (status);
495}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530496
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800497eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530498{
499 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800500 tCsrScanStruct *pScan = &pMac->scan;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530501 tANI_U8 numChan = pScan->base20MHzChannels.numChannels;
502 tANI_U32 bufLen = sizeof(tSirUpdateChanList) +
503 (sizeof(tSirUpdateChanParam) * (numChan - 1));
504 vos_msg_t msg;
505 tANI_U8 i;
506
507 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
508 if (!pChanList)
509 {
510 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
511 "Failed to allocate memory for tSirUpdateChanList");
512 return eHAL_STATUS_FAILED_ALLOC;
513 }
514
515 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
516 msg.reserved = 0;
517 msg.bodyptr = pChanList;
518 pChanList->numChan = numChan;
519 for (i = 0; i < pChanList->numChan; i++)
520 {
521 pChanList->chanParam[i].chanId = pScan->defaultPowerTable[i].chanId;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800522 pChanList->chanParam[i].pwr = cfgGetRegulatoryMaxTransmitPower(pMac,
523 pScan->defaultPowerTable[i].chanId);
524 if (vos_nv_getChannelEnabledState(pChanList->chanParam[i].chanId) ==
525 NV_CHANNEL_DFS)
526 pChanList->chanParam[i].dfsSet = VOS_TRUE;
527 else
528 pChanList->chanParam[i].dfsSet = VOS_FALSE;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530529 }
530
531 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
532 {
533 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
534 "%s: Failed to post msg to WDA", __func__);
535 vos_mem_free(pChanList);
536 return eHAL_STATUS_FAILURE;
537 }
538
539 return eHAL_STATUS_SUCCESS;
540}
541
Jeff Johnson295189b2012-06-20 16:38:30 -0700542eHalStatus csrStart(tpAniSirGlobal pMac)
543{
544 eHalStatus status = eHAL_STATUS_SUCCESS;
545 tANI_U32 i;
546
547 do
548 {
549 //save the global vos context
550 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
551 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
552 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
553
554 status = csrRoamStart(pMac);
555 if(!HAL_STATUS_SUCCESS(status)) break;
556 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
557 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
558 if(!HAL_STATUS_SUCCESS(status)) break;
559 pMac->roam.sPendingCommands = 0;
560 csrScanEnable(pMac);
561#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
562 status = csrNeighborRoamInit(pMac);
563#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
564 pMac->roam.tlStatsReqInfo.numClient = 0;
565 pMac->roam.tlStatsReqInfo.periodicity = 0;
566 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
567 //init the link quality indication also
568 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
569 if(!HAL_STATUS_SUCCESS(status))
570 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800571 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 break;
573 }
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800574#ifdef QCA_WIFI_2_0
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530575 if (pMac->fScanOffload)
576 {
577 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
578 "Scan offload is enabled, update default chan list");
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800579 status = csrUpdateChannelList(pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530580 }
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800581#else
582 status = csrUpdateChannelList(pMac);
583#endif
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530584
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700586#if defined(ANI_LOGDUMP)
587 csrDumpInit(pMac);
588#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 return (status);
590}
591
Kiet Lama72a2322013-11-15 11:18:11 +0530592eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700593{
594 tANI_U32 sessionId;
595 tANI_U32 i;
596
597 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
598 {
599 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
600 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 csrScanDisable(pMac);
602 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
603 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700604 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
605
606#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
607 csrNeighborRoamClose(pMac);
608#endif
609 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 // deregister from PMC since we register during csrStart()
611 // (ignore status since there is nothing we can do if it fails)
612 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700613 //Reset the domain back to the deault
614 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800615 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700616
617 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
618 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530619 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700620 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
621 }
622
Kiet Lama72a2322013-11-15 11:18:11 +0530623#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
624 /* When HAL resets all the context information
625 * in HAL is lost, so we might need to send the
626 * scan offload request again when it comes
627 * out of reset for scan offload to be functional
628 */
629 if (HAL_STOP_TYPE_SYS_RESET == stopType)
630 {
631 bRoamScanOffloadStarted = VOS_FALSE;
632 }
633#endif
634
Jeff Johnson295189b2012-06-20 16:38:30 -0700635 return (eHAL_STATUS_SUCCESS);
636}
637
Jeff Johnson295189b2012-06-20 16:38:30 -0700638eHalStatus csrReady(tpAniSirGlobal pMac)
639{
640 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 csrScanGetSupportedChannels( pMac );
642 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
643 //use it to init the background scan list
644 csrInitBGScanChannelList(pMac);
645 /* HDD issues the init scan */
646 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800647 /* If the gScanAgingTime is set to '0' then scan results aging timeout
648 based on timer feature is not enabled*/
649 if(0 != pMac->scan.scanResultCfgAgingTime )
650 {
651 csrScanStartResultCfgAgingTimer(pMac);
652 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700653 //Store the AC weights in TL for later use
654 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700655 status = csrInitChannelList( pMac );
656 if ( ! HAL_STATUS_SUCCESS( status ) )
657 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800658 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 status );
660 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 return (status);
662}
Jeff Johnson295189b2012-06-20 16:38:30 -0700663void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
664{
665 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700666 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
667 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
668}
Jeff Johnson295189b2012-06-20 16:38:30 -0700669void csrSetGlobalCfgs( tpAniSirGlobal pMac )
670{
Jeff Johnsone7245742012-09-05 17:12:55 -0700671
Jeff Johnson295189b2012-06-20 16:38:30 -0700672 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
673 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
674 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
675 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
676 NULL, eANI_BOOLEAN_FALSE);
677 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700678 /* For now we will just use the 5GHz CB mode ini parameter to decide whether CB supported or not in Probes when there is no session
679 * Once session is established we will use the session related params stored in PE session for CB mode
680 */
681 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700682 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
683
684 //Update the operating mode to configured value during initialization,
685 //So that client can advertise full capabilities in Probe request frame.
686 csrSetDefaultDot11Mode( pMac );
687}
688
Jeff Johnson295189b2012-06-20 16:38:30 -0700689eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
690{
691 eHalStatus status = eHAL_STATUS_SUCCESS;
692 tANI_U32 i;
693 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 do
695 {
696 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
697 {
698 pSession = CSR_GET_SESSION( pMac, i );
699 pSession->roamingTimerInfo.pMac = pMac;
700 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
701 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700702 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
703 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530704 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
705 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700706 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530707 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800709 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 break;
711 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530712 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
713 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
714 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800716 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 return eHAL_STATUS_FAILURE;
718 }
719 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 return (status);
721}
722
Jeff Johnson295189b2012-06-20 16:38:30 -0700723eHalStatus csrRoamClose(tpAniSirGlobal pMac)
724{
725 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
727 {
728 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
729 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530730 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
731 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
732 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
733 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 return (eHAL_STATUS_SUCCESS);
735}
736
Jeff Johnson295189b2012-06-20 16:38:30 -0700737eHalStatus csrRoamStart(tpAniSirGlobal pMac)
738{
739 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 return (eHAL_STATUS_SUCCESS);
741}
742
Jeff Johnson295189b2012-06-20 16:38:30 -0700743void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
744{
745 csrRoamStopRoamingTimer(pMac, sessionId);
746 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
747 csrRoamDeregStatisticsReq(pMac);
748}
Jeff Johnson295189b2012-06-20 16:38:30 -0700749eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
750{
751 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800752 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700753 {
754 status = eHAL_STATUS_SUCCESS;
755 *pState = pMac->roam.roamSession[sessionId].connectState;
756 }
757 return (status);
758}
759
Jeff Johnson295189b2012-06-20 16:38:30 -0700760eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
761{
762 eHalStatus status = eHAL_STATUS_FAILURE;
763 tANI_U32 size = 0;
764 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700765
766 if(!pSession)
767 {
768 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
769 return eHAL_STATUS_FAILURE;
770 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700771
772 if(pProfile)
773 {
774 if(pSession->pConnectBssDesc)
775 {
776 do
777 {
778 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
779 if(size)
780 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530781 pProfile->pBssDesc = vos_mem_malloc(size);
782 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530784 vos_mem_copy(pProfile->pBssDesc,
785 pSession->pConnectBssDesc, size);
786 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 }
788 else
789 break;
790 }
791 else
792 {
793 pProfile->pBssDesc = NULL;
794 }
795 pProfile->AuthType = pSession->connectedProfile.AuthType;
796 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
797 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
798 pProfile->BSSType = pSession->connectedProfile.BSSType;
799 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
800 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530801 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
802 sizeof(tCsrBssid));
803 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
804 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700805#ifdef WLAN_FEATURE_VOWIFI_11R
806 if (pSession->connectedProfile.MDID.mdiePresent)
807 {
808 pProfile->MDID.mdiePresent = 1;
809 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
810 }
811 else
812 {
813 pProfile->MDID.mdiePresent = 0;
814 pProfile->MDID.mobilityDomain = 0;
815 }
816#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800817#ifdef FEATURE_WLAN_ESE
818 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
819 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700820 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800821 vos_mem_copy (pProfile->eseCckmInfo.krk,
822 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530823 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800824 pProfile->eseCckmInfo.reassoc_req_num=
825 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
826 pProfile->eseCckmInfo.krk_plumbed =
827 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 }
829#endif
830 }while(0);
831 }
832 }
833
834 return (status);
835}
836
Jeff Johnson295189b2012-06-20 16:38:30 -0700837eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
838{
839 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700840
841 if((csrIsConnStateConnected(pMac, sessionId)) ||
842 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 {
844 if(pProfile)
845 {
846 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
847 }
848 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 return (status);
850}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700851
Jeff Johnson295189b2012-06-20 16:38:30 -0700852eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
853{
854 eHalStatus status = eHAL_STATUS_SUCCESS;
855
Kiet Lam64c1b492013-07-12 13:56:44 +0530856 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530858 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530860 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700861 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530862 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700863 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530864 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
865
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
867 return (status);
868}
869
Jeff Johnson295189b2012-06-20 16:38:30 -0700870static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
871{
872 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 if( pConnectedInfo->pbFrames )
874 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530875 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 pConnectedInfo->pbFrames = NULL;
877 }
878 pConnectedInfo->nBeaconLength = 0;
879 pConnectedInfo->nAssocReqLength = 0;
880 pConnectedInfo->nAssocRspLength = 0;
881 pConnectedInfo->staId = 0;
882#ifdef WLAN_FEATURE_VOWIFI_11R
883 pConnectedInfo->nRICRspLength = 0;
884#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800885#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 pConnectedInfo->nTspecIeLength = 0;
887#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700888 return ( status );
889}
890
Jeff Johnson295189b2012-06-20 16:38:30 -0700891
892
Jeff Johnsone7245742012-09-05 17:12:55 -0700893
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700894void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
895{
896 csrReinitPreauthCmd(pMac, pCommand);
897 csrReleaseCommand( pMac, pCommand );
898}
899
Jeff Johnson295189b2012-06-20 16:38:30 -0700900void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
901{
902 csrReinitRoamCmd(pMac, pCommand);
903 csrReleaseCommand( pMac, pCommand );
904}
905
Jeff Johnson295189b2012-06-20 16:38:30 -0700906void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
907{
908 csrReinitScanCmd(pMac, pCommand);
909 csrReleaseCommand( pMac, pCommand );
910}
911
Jeff Johnson295189b2012-06-20 16:38:30 -0700912void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
913{
914 csrReinitWmStatusChangeCmd(pMac, pCommand);
915 csrReleaseCommand( pMac, pCommand );
916}
917
Jeff Johnson295189b2012-06-20 16:38:30 -0700918void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
919{
Kiet Lam64c1b492013-07-12 13:56:44 +0530920 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700921}
922
Jeff Johnson295189b2012-06-20 16:38:30 -0700923void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
924{
Kiet Lam64c1b492013-07-12 13:56:44 +0530925 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700926}
927
Jeff Johnson295189b2012-06-20 16:38:30 -0700928void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
929{
930 csrReinitSetKeyCmd(pMac, pCommand);
931 csrReleaseCommand( pMac, pCommand );
932}
Jeff Johnson295189b2012-06-20 16:38:30 -0700933void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
934{
935 csrReinitRemoveKeyCmd(pMac, pCommand);
936 csrReleaseCommand( pMac, pCommand );
937}
Jeff Johnson295189b2012-06-20 16:38:30 -0700938void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
939{
940
941 if( eSmeCsrCommandMask & pCommand->command )
942 {
943 switch (pCommand->command)
944 {
945 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800946 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -0800947 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
948 __func__, pCommand->u.scanCmd.reason,
949 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700950 if (NULL != pCommand->u.scanCmd.callback)
951 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800952 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
954 }
955 csrReleaseCommandScan( pMac, pCommand );
956 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700957 case eSmeCommandRoam:
958 csrReleaseCommandRoam( pMac, pCommand );
959 break;
960
961 case eSmeCommandWmStatusChange:
962 csrReleaseCommandWmStatusChange( pMac, pCommand );
963 break;
964
965 case eSmeCommandSetKey:
966 csrReleaseCommandSetKey( pMac, pCommand );
967 break;
968
969 case eSmeCommandRemoveKey:
970 csrReleaseCommandRemoveKey( pMac, pCommand );
971 break;
972
973 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800974 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 csrReleaseCommand( pMac, pCommand );
976 break;
977 }
978 }
979}
980
Jeff Johnson295189b2012-06-20 16:38:30 -0700981void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
982{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +0530983 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
984 macTraceGetcsrRoamSubState(NewSubstate),
985 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -0700986
Jeff Johnson295189b2012-06-20 16:38:30 -0700987 if(pMac->roam.curSubState[sessionId] == NewSubstate)
988 {
989 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700990 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 pMac->roam.curSubState[sessionId] = NewSubstate;
992}
993
Jeff Johnson295189b2012-06-20 16:38:30 -0700994eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
995{
996 eCsrRoamState PreviousState;
997
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +0530998 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
999 macTraceGetcsrRoamState(NewRoamState),
1000 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001001
1002 PreviousState = pMac->roam.curState[sessionId];
1003
1004 if ( NewRoamState != pMac->roam.curState[sessionId] )
1005 {
1006 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1007 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1008 {
1009 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1010 }
1011
1012 pMac->roam.curState[sessionId] = NewRoamState;
1013 }
1014 return( PreviousState );
1015}
1016
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001017void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001018{
1019 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001020 if(catOffset)
1021 {
1022 pMac->roam.configParam.bCatRssiOffset = catOffset;
1023 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1024 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001025 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)bestApRssi - pMac->roam.configParam.nSelect5GHzMargin - (int)(i * catOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001026 }
1027 }
1028}
1029
Jeff Johnson295189b2012-06-20 16:38:30 -07001030static void initConfigParam(tpAniSirGlobal pMac)
1031{
1032 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001033 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301034 pMac->roam.configParam.channelBondingMode24GHz =
1035 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1036 pMac->roam.configParam.channelBondingMode5GHz =
1037 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001038 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1039 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1040 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1041 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1042 pMac->roam.configParam.HeartbeatThresh24 = 40;
1043 pMac->roam.configParam.HeartbeatThresh50 = 40;
1044 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1045 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1046 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001047 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 pMac->roam.configParam.RTSThreshold = 2346;
1049 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1050 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1051 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1052 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1053 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1054 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1055 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1056 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1057 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1058 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1059 {
1060 pMac->roam.configParam.BssPreferValue[i] = i;
1061 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001062 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001063 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1064 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1065 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001066 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1067 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
1068 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1069 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1070 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1071 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001072 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1073 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001074 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001075#ifdef WLAN_AP_STA_CONCURRENCY
1076 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1077 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1078 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1079 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1080 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001081 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1082 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001083#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001084 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1085 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1086 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1087 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001088#ifdef WLAN_FEATURE_VOWIFI_11R
1089 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1090#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001091#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1092 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1093 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1094 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1095 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1096 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1097 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1098 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1099 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1100 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1101 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1102 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001103 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001104#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001105#ifdef WLAN_FEATURE_11AC
1106 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1107#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001108
1109 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1110 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001111
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001112 //Remove this code once SLM_Sessionization is supported
1113 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001114 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001115
Jeff Johnsone7245742012-09-05 17:12:55 -07001116}
Jeff Johnson295189b2012-06-20 16:38:30 -07001117eCsrBand csrGetCurrentBand(tHalHandle hHal)
1118{
1119 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1120 return pMac->roam.configParam.bandCapability;
1121}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001122
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001123
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001124#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001125/*
1126 This function flushes the roam scan cache
1127*/
1128eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1129{
1130 eHalStatus status = eHAL_STATUS_SUCCESS;
1131 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1132
1133 /* Free up the memory first (if required) */
1134 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1135 {
1136 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1137 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1138 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1139 }
1140 return status;
1141}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001142#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001143
1144
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001145#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001146/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001147 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001148*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001149eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001150{
1151 eHalStatus status = eHAL_STATUS_SUCCESS;
1152 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1153
1154 /* Free up the memory first (if required) */
1155 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1156 {
1157 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1158 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001159 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001160 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001161 return status;
1162}
1163
1164
1165
1166/*
1167 This function flushes the roam scan cache and creates fresh cache
1168 based on the input channel list
1169*/
1170eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1171 const tANI_U8 *pChannelList,
1172 const tANI_U8 numChannels)
1173{
1174 eHalStatus status = eHAL_STATUS_SUCCESS;
1175 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1176
Srinivas Girigowdade697412013-02-14 16:31:48 -08001177 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1178
1179 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1180 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1181
1182 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1183 {
1184 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1185 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1186 return eHAL_STATUS_RESOURCES;
1187 }
1188
1189 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301190 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1191 pChannelList,
1192 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001193 return status;
1194}
1195
1196/* This function modifies the bgscan channel list set via config ini or
1197 runtime, whenever the band changes.
1198 if the band is auto, then no operation is performed on the channel list
1199 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1200 if the band is 5G, then make sure channel list contains only 5G valid channels
1201*/
1202eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1203 eCsrBand eBand)
1204{
1205 eHalStatus status = eHAL_STATUS_SUCCESS;
1206 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1207 tANI_U8 outNumChannels = 0;
1208 tANI_U8 inNumChannels = 0;
1209 tANI_U8 *inPtr = NULL;
1210 tANI_U8 i = 0;
1211 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1212
1213 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1214
1215 {
1216 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1217 "No update required for channel list "
1218 "either cfg.ini channel list is not set up or "
1219 "auto band (Band %d)", eBand);
1220 return status;
1221 }
1222
1223 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1224 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1225 if (eCSR_BAND_24 == eBand)
1226 {
1227 for (i = 0; i < inNumChannels; i++)
1228 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001229 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001230 {
1231 ChannelList[outNumChannels++] = inPtr[i];
1232 }
1233 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001234 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001235 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001236 }
1237 else if (eCSR_BAND_5G == eBand)
1238 {
1239 for (i = 0; i < inNumChannels; i++)
1240 {
1241 /* Add 5G Non-DFS channel */
1242 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001243 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001244 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1245 {
1246 ChannelList[outNumChannels++] = inPtr[i];
1247 }
1248 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001249 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001250 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001251 }
1252 else if (eCSR_BAND_ALL == eBand)
1253 {
1254 for (i = 0; i < inNumChannels; i++)
1255 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001256 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001257 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1258 {
1259 ChannelList[outNumChannels++] = inPtr[i];
1260 }
1261 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001262 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001263 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001264 }
1265 else
1266 {
1267 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1268 "Invalid band, No operation carried out (Band %d)", eBand);
1269 status = eHAL_STATUS_INVALID_PARAMETER;
1270 }
1271
1272 return status;
1273}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001274#endif
1275
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001276#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001277/* This function modifies the roam scan channel list as per AP neighbor
1278 report; AP neighbor report may be empty or may include only other AP
1279 channels; in any case, we merge the channel list with the learned occupied
1280 channels list.
1281 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1282 if the band is 5G, then make sure channel list contains only 5G valid channels
1283*/
1284eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1285 tANI_U8 *pChannelList,
1286 tANI_U8 numChannels,
1287 const eCsrBand eBand)
1288{
1289 eHalStatus status = eHAL_STATUS_SUCCESS;
1290 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1291 tANI_U8 outNumChannels = 0;
1292 tANI_U8 inNumChannels = numChannels;
1293 tANI_U8 *inPtr = pChannelList;
1294 tANI_U8 i = 0;
1295 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1296 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1297 tANI_U8 mergedOutputNumOfChannels = 0;
1298 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1299
1300 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1301 * report Channels. This increases the chances of the DUT to get a candidate AP while
1302 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1303 if (pMac->scan.occupiedChannels.numChannels)
1304 {
1305 csrNeighborRoamMergeChannelLists(pMac,
1306 &pMac->scan.occupiedChannels.channelList[0],
1307 pMac->scan.occupiedChannels.numChannels,
1308 inPtr,
1309 inNumChannels,
1310 &mergedOutputNumOfChannels);
1311 inNumChannels = mergedOutputNumOfChannels;
1312 }
1313
1314 if (eCSR_BAND_24 == eBand)
1315 {
1316 for (i = 0; i < inNumChannels; i++)
1317 {
1318 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1319 {
1320 ChannelList[outNumChannels++] = inPtr[i];
1321 }
1322 }
1323 }
1324 else if (eCSR_BAND_5G == eBand)
1325 {
1326 for (i = 0; i < inNumChannels; i++)
1327 {
1328 /* Add 5G Non-DFS channel */
1329 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1330 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1331 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1332 {
1333 ChannelList[outNumChannels++] = inPtr[i];
1334 }
1335 }
1336 }
1337 else if (eCSR_BAND_ALL == eBand)
1338 {
1339 for (i = 0; i < inNumChannels; i++)
1340 {
1341 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1342 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1343 {
1344 ChannelList[outNumChannels++] = inPtr[i];
1345 }
1346 }
1347 }
1348 else
1349 {
1350 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1351 "Invalid band, No operation carried out (Band %d)", eBand);
1352 return eHAL_STATUS_INVALID_PARAMETER;
1353 }
1354
1355 /* if roaming within band is enabled, then select only the
1356 in band channels .
1357 This is required only if the band capability is set to ALL,
1358 E.g., if band capability is only 2.4G then all the channels in the
1359 list are already filtered for 2.4G channels, hence ignore this check*/
1360
1361 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1362 {
1363 csrNeighborRoamChannelsFilterByCurrentBand(
1364 pMac,
1365 ChannelList,
1366 outNumChannels,
1367 tmpChannelList,
1368 &outNumChannels);
Kiet Lamf2f201e2013-11-16 21:24:16 +05301369 vos_mem_copy(ChannelList,
1370 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001371 }
1372
1373 /* Prepare final roam scan channel list */
1374 if(outNumChannels)
1375 {
1376 /* Clear the channel list first */
1377 if (NULL != currChannelListInfo->ChannelList)
1378 {
1379 vos_mem_free(currChannelListInfo->ChannelList);
1380 currChannelListInfo->ChannelList = NULL;
1381 currChannelListInfo->numOfChannels = 0;
1382 }
1383
1384 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1385 if (NULL == currChannelListInfo->ChannelList)
1386 {
1387 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1388 "Failed to allocate memory for roam scan channel list");
1389 currChannelListInfo->numOfChannels = 0;
1390 return VOS_STATUS_E_RESOURCES;
1391 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301392 vos_mem_copy(currChannelListInfo->ChannelList,
1393 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001394 }
1395 return status;
1396}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001397#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001398
Jeff Johnson295189b2012-06-20 16:38:30 -07001399eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1400{
1401 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1402 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001403 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1404 (eBand == eCSR_BAND_24))
1405 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001406 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001408 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001409 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 pMac->roam.configParam.uCfgDot11Mode, eBand);
1411 return eHAL_STATUS_INVALID_PARAMETER;
1412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1414 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1415 (eBand == eCSR_BAND_5G))
1416 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001417 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001419 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001420 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 pMac->roam.configParam.uCfgDot11Mode, eBand);
1422 return eHAL_STATUS_INVALID_PARAMETER;
1423 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001424 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001425 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001426 pMac->roam.configParam.eBand = eBand;
1427 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001429#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001430 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1431 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001432#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 status = csrInitGetChannels( pMac );
1434 if (eHAL_STATUS_SUCCESS == status)
1435 csrInitChannelList( hHal );
1436 return status;
1437}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001438
1439
Jeff Johnsone7245742012-09-05 17:12:55 -07001440/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1441 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1442 * Ideally we should have kept the ini value and enum value same and representing the same
1443 * cb values as in 11n standard i.e.
1444 * Set to 1 (SCA) if the secondary channel is above the primary channel
1445 * Set to 3 (SCB) if the secondary channel is below the primary channel
1446 * Set to 0 (SCN) if no secondary channel is present
1447 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1448 * 0 - secondary none
1449 * 1 - secondary LOW
1450 * 2 - secondary HIGH
1451 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1452 * The enum values are as follows:
1453 * PHY_SINGLE_CHANNEL_CENTERED = 0
1454 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1455 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1456 */
1457ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1458{
1459
1460 ePhyChanBondState phyCbState;
1461 switch (cbIniValue) {
1462 // secondary none
1463 case 0:
1464 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1465 break;
1466 // secondary LOW
1467 case 1:
1468 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1469 break;
1470 // secondary HIGH
1471 case 2:
1472 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1473 break;
1474#ifdef WLAN_FEATURE_11AC
1475 case 3:
1476 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1477 break;
1478 case 4:
1479 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1480 break;
1481 case 5:
1482 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1483 break;
1484 case 6:
1485 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1486 break;
1487 case 7:
1488 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1489 break;
1490 case 8:
1491 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1492 break;
1493 case 9:
1494 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1495 break;
1496#endif
1497 default:
1498 // If an invalid value is passed, disable CHANNEL BONDING
1499 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1500 break;
1501 }
1502 return phyCbState;
1503}
1504
1505v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1506{
1507
1508 v_U32_t cbIniValue;
1509 switch (phyCbState) {
1510 // secondary none
1511 case PHY_SINGLE_CHANNEL_CENTERED:
1512 cbIniValue = 0;
1513 break;
1514 // secondary LOW
1515 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1516 cbIniValue = 1;
1517 break;
1518 // secondary HIGH
1519 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1520 cbIniValue = 2;
1521 break;
1522#ifdef WLAN_FEATURE_11AC
1523 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1524 cbIniValue = 3;
1525 break;
1526 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1527 cbIniValue = 4;
1528 break;
1529 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1530 cbIniValue = 5;
1531 break;
1532 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1533 cbIniValue = 6;
1534 break;
1535 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1536 cbIniValue = 7;
1537 break;
1538 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1539 cbIniValue = 8;
1540 break;
1541 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1542 cbIniValue = 9;
1543 break;
1544#endif
1545 default:
1546 // return some invalid value
1547 cbIniValue = 10;
1548 break;
1549 }
1550 return cbIniValue;
1551}
Jeff Johnson295189b2012-06-20 16:38:30 -07001552
1553eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1554{
1555 eHalStatus status = eHAL_STATUS_SUCCESS;
1556
1557 if(pParam)
1558 {
1559 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1560 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1561 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1562 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1563 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1564 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1565
1566 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001567 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1568
Jeff Johnsone7245742012-09-05 17:12:55 -07001569 /* channelBondingMode5GHz plays a dual role right now
1570 * INFRA STA will use this non zero value as CB enabled and SOFTAP will use this non-zero value to determine the secondary channel offset
1571 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1572 */
1573 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1574 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001575 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001576 }
1577 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1578 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1579 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001580 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001581 }
1582 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1584 pMac->roam.configParam.phyMode = pParam->phyMode;
1585 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1586 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1587 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1588 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1589 pMac->roam.configParam.TxRate = pParam->TxRate;
1590 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1591 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1592 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1593 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1594 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001595 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 //if HDD passed down non zero values then only update,
1597 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301598 if (pParam->nInitialDwellTime)
1599 {
1600 pMac->roam.configParam.nInitialDwellTime =
1601 pParam->nInitialDwellTime;
1602 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001603 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 {
1605 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1606 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001607 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 {
1609 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1610 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001611 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 {
1613 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1614 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001615 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 {
1617 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1618 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001619 if (pParam->nActiveMaxChnTimeBtc)
1620 {
1621 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1622 }
1623 if (pParam->nActiveMinChnTimeBtc)
1624 {
1625 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1626 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001627#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001628 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001629 {
1630 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1631 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001632 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001633 {
1634 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1635 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001636 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001637 {
1638 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1639 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001640 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001641 {
1642 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1643 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001644 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001645 {
1646 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1647 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001648 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001649 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001650 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1651 }
1652 if (pParam->nNumP2PChanCombinedConc)
1653 {
1654 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001655 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001656#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001657 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001658 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 {
1660 //Change the unit from second to microsecond
1661 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1663 {
1664 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1665 }
1666 else
1667 {
1668 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1669 }
1670 }
1671 else
1672 {
1673 pMac->roam.configParam.impsSleepTime = 0;
1674 }
1675 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001676 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1677 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 //if HDD passed down non zero values for age params, then only update,
1679 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001680 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 {
1682 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 if(pParam->scanAgeTimeNCNPS)
1685 {
1686 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 if(pParam->scanAgeTimeNCPS)
1689 {
1690 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1691 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 if(pParam->scanAgeTimeCNPS)
1693 {
1694 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1695 }
1696 if(pParam->scanAgeTimeCPS)
1697 {
1698 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1699 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301700 if (pParam->initialScanSkipDFSCh)
1701 {
1702 pMac->roam.configParam.initialScanSkipDFSCh =
1703 pParam->initialScanSkipDFSCh;
1704 }
1705
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001706 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001707 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1708 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1709 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1710 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1711 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001712 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1713 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1715 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1716 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1717 //Assign this before calling CsrInit11dInfo
1718 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 if( csrIs11dSupported( pMac ) )
1720 {
1721 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1722 }
1723 else
1724 {
1725 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1726 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001727
1728 /* Initialize the power + channel information if 11h is enabled.
1729 If 11d is enabled this information has already been initialized */
1730 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1731 {
1732 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1733 }
1734
1735
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301736#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301737 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1738 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001739 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001740#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001741#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001743 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001744 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001745 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001746 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001747 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001748 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001749 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001750 pMac->roam.configParam.nProbes = pParam->nProbes;
1751 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001752#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001753#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1754 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001755 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001756#endif
1757#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001758 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001759 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001760#endif
1761
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001762#ifdef FEATURE_WLAN_ESE
1763 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001764#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001765#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301766 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1767 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001768 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1769 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1770 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1771 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1772 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1773 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1774 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1775 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001776 {
1777 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001778 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07001779 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1780 {
1781 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001783 }
1784#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001785 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1786 pMac->scan.fValidateList = pParam->fValidateList;
1787 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1788 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001789 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001791 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1792 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1793 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1794 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1795 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1796 * single session
1797 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001798 //Remove this code once SLM_Sessionization is supported
1799 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001800 pMac->roam.configParam.doBMPSWorkaround = 0;
1801
Jeff Johnsone7245742012-09-05 17:12:55 -07001802#ifdef WLAN_FEATURE_11AC
1803 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001804 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001805 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001806 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001807#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001808 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001809
1810 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001811 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001812 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1813 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301814 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07001815 }
1816
1817 return status;
1818}
1819
Jeff Johnson295189b2012-06-20 16:38:30 -07001820eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1821{
1822 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001823 if(pParam)
1824 {
1825 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1826 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1827 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1828 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1829 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1830 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001831 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1832 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1834 pParam->phyMode = pMac->roam.configParam.phyMode;
1835 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1836 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1837 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1838 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1839 pParam->TxRate = pMac->roam.configParam.TxRate;
1840 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1841 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1842 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1843 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1844 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1846 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1847 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1848 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001849 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1850 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1851 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001852#ifdef WLAN_AP_STA_CONCURRENCY
1853 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1854 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1855 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1856 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1857 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001858 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1859 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001860#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 //Change the unit from microsecond to second
1862 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1863 pParam->eBand = pMac->roam.configParam.eBand;
1864 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1865 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1866 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1867 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1868 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1869 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1870 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1871 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1872 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1873 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1874 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1875 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1876 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1878 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1879 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1880 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001881 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1882 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1883 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1884 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1885 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001886 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001887 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001888 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001889 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001890
1891#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301892 vos_mem_copy(&pParam->neighborRoamConfig,
1893 &pMac->roam.configParam.neighborRoamConfig,
1894 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001895#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001896#ifdef WLAN_FEATURE_11AC
1897 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001898 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001899 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001900 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001901#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001902#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301903 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1904 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001905#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001906#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001907 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1908 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1909 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1910 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1911 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001912 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001913 pParam->nProbes = pMac->roam.configParam.nProbes;
1914 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001915#endif
1916#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1917 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1918 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1919#endif
1920#ifdef FEATURE_WLAN_LFR
1921 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1922#endif
1923
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001924#ifdef FEATURE_WLAN_ESE
1925 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001926#endif
1927#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301928 vos_mem_copy(&pParam->neighborRoamConfig,
1929 &pMac->roam.configParam.neighborRoamConfig,
1930 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001931 {
1932 int i;
1933 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1934 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1935 {
1936 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1937 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001938 }
1939#endif
1940
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001941 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001942
krunal soni5afa96c2013-09-06 22:19:02 -07001943 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001944 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07001945
krunal sonie9002db2013-11-25 14:24:17 -08001946 pParam->isCoalesingInIBSSAllowed =
1947 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301948 pParam->allowDFSChannelRoam =
1949 pMac->roam.configParam.allowDFSChannelRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07001950 csrSetChannels(pMac, pParam);
1951
1952 status = eHAL_STATUS_SUCCESS;
1953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 return (status);
1955}
1956
Jeff Johnson295189b2012-06-20 16:38:30 -07001957eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1958{
1959 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1960 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1961 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1962 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001963 do
1964 {
1965 if(eCSR_BAND_24 == eBand)
1966 {
1967 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1968 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1969 }
1970 if(eCSR_BAND_5G == eBand)
1971 {
1972 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1973 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1974 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1975 )
1976 {
1977 break;
1978 }
1979 }
1980 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1981 {
1982 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1983 }
1984 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1985 {
1986 newPhyMode = eCSR_DOT11_MODE_AUTO;
1987 }
1988 else
1989 {
1990 //Check for dual band and higher capability first
1991 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1992 {
1993 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1994 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1995 }
1996 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1997 {
1998 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1999 if(eCSR_BAND_24 == eBand) break;
2000 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2001 eBand = eCSR_BAND_5G;
2002 }
2003 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2004 {
2005 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2006 if(eCSR_BAND_5G == eBand) break;
2007 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2008 eBand = eCSR_BAND_24;
2009 }
2010 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2011 {
2012 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2013 if(eCSR_BAND_5G == eBand) break;
2014 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2015 eBand = eCSR_BAND_24;
2016 }
2017 else if(eCSR_DOT11_MODE_11n & phyMode)
2018 {
2019 newPhyMode = eCSR_DOT11_MODE_11n;
2020 }
2021 else if(eCSR_DOT11_MODE_abg & phyMode)
2022 {
2023 newPhyMode = eCSR_DOT11_MODE_abg;
2024 }
2025 else if(eCSR_DOT11_MODE_11a & phyMode)
2026 {
2027 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2028 {
2029 if(eCSR_BAND_ALL == eBand)
2030 {
2031 newPhyMode = eCSR_DOT11_MODE_abg;
2032 }
2033 else
2034 {
2035 //bad setting
2036 break;
2037 }
2038 }
2039 else
2040 {
2041 newPhyMode = eCSR_DOT11_MODE_11a;
2042 eBand = eCSR_BAND_5G;
2043 }
2044 }
2045 else if(eCSR_DOT11_MODE_11g & phyMode)
2046 {
2047 newPhyMode = eCSR_DOT11_MODE_11g;
2048 eBand = eCSR_BAND_24;
2049 }
2050 else if(eCSR_DOT11_MODE_11b & phyMode)
2051 {
2052 newPhyMode = eCSR_DOT11_MODE_11b;
2053 eBand = eCSR_BAND_24;
2054 }
2055 else
2056 {
2057 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002058 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 newPhyMode = eCSR_DOT11_MODE_AUTO;
2060 }
2061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002062 //Done validating
2063 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002064 //Now we need to check whether a restart is needed.
2065 if(eBand != pMac->roam.configParam.eBand)
2066 {
2067 fRestartNeeded = eANI_BOOLEAN_TRUE;
2068 break;
2069 }
2070 if(newPhyMode != pMac->roam.configParam.phyMode)
2071 {
2072 fRestartNeeded = eANI_BOOLEAN_TRUE;
2073 break;
2074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002075 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 if(HAL_STATUS_SUCCESS(status))
2077 {
2078 pMac->roam.configParam.eBand = eBand;
2079 pMac->roam.configParam.phyMode = newPhyMode;
2080 if(pfRestartNeeded)
2081 {
2082 *pfRestartNeeded = fRestartNeeded;
2083 }
2084 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002085 return (status);
2086}
2087
Jeff Johnson295189b2012-06-20 16:38:30 -07002088void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2089{
2090 tANI_U8 Index;
2091 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 // for dual band NICs, don't need to trim the channel list....
2093 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2094 {
2095 // 2.4 GHz band operation requires the channel list to be trimmed to
2096 // the 2.4 GHz channels only...
2097 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2098 {
2099 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2100 Index++ )
2101 {
2102 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2103 {
2104 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2105 cChannels++;
2106 }
2107 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002108 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2109 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2110 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2111 // only if we need to.
2112 //
2113 // The amount of memory to clear is the number of channesl that we trimmed
2114 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2115
2116 if ( pChannelList->numChannels > cChannels )
2117 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302118 vos_mem_set(&pChannelList->channelList[ cChannels ],
2119 sizeof( pChannelList->channelList[ 0 ] ) *
2120 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002121 }
2122
2123 pChannelList->numChannels = cChannels;
2124 }
2125 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2126 {
2127 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2128 {
2129 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2130 {
2131 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2132 cChannels++;
2133 }
2134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2136 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2137 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2138 // only if we need to.
2139 //
2140 // The amount of memory to clear is the number of channesl that we trimmed
2141 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2142 if ( pChannelList->numChannels > cChannels )
2143 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302144 vos_mem_set(&pChannelList->channelList[ cChannels ],
2145 sizeof( pChannelList->channelList[ 0 ] ) *
2146 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 }
2148
2149 pChannelList->numChannels = cChannels;
2150 }
2151 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002152}
Jeff Johnson295189b2012-06-20 16:38:30 -07002153#define INFRA_AP_DEFAULT_CHANNEL 6
2154eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2155{
2156 tANI_U8 index= 0;
2157 eHalStatus status = eHAL_STATUS_FAILURE;
2158 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2159 {
2160 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2161 status = eHAL_STATUS_SUCCESS;
2162 break;
2163 }
2164 }
2165 return status;
2166}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002167
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002168
Jeff Johnson295189b2012-06-20 16:38:30 -07002169eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2170{
2171 eHalStatus status = eHAL_STATUS_SUCCESS;
2172 tANI_U8 num20MHzChannelsFound = 0;
2173 VOS_STATUS vosStatus;
2174 tANI_U8 Index = 0;
2175 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002176
Jeff Johnson295189b2012-06-20 16:38:30 -07002177
2178 //TODO: this interface changed to include the 40MHz channel list
2179 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2180 // Read the scan channel list (including the power limit) from EEPROM
2181 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2182 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2183 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2184 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002185 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 status = eHAL_STATUS_FAILURE;
2187 }
2188 else
2189 {
2190 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2191 {
2192 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2193 }
2194 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2195 // Move the channel list to the global data
2196 // structure -- this will be used as the scan list
2197 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2198 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 }
2201 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2202 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2203 {
2204 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2205 }
2206 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2207 {
2208 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2209 }
2210 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 return (status);
2213}
2214
Jeff Johnson295189b2012-06-20 16:38:30 -07002215eHalStatus csrInitChannelList( tHalHandle hHal )
2216{
2217 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2218 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2220 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002221 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2222 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002224 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002225
2226 return (status);
2227}
Jeff Johnson295189b2012-06-20 16:38:30 -07002228eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2229 tCsrUpdateConfigParam *pUpdateConfigParam)
2230{
2231 eHalStatus status = eHAL_STATUS_FAILURE;
2232 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002233 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2234 status = CsrInit11dInfo(pMac, ps11dinfo);
2235 return status;
2236}
2237
Jeff Johnson295189b2012-06-20 16:38:30 -07002238static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2239{
2240 eHalStatus status = eHAL_STATUS_FAILURE;
2241 tANI_U8 index;
2242 tANI_U32 count=0;
2243 tSirMacChanInfo *pChanInfo;
2244 tSirMacChanInfo *pChanInfoStart;
2245 tANI_BOOLEAN applyConfig = TRUE;
2246
Mihir Shetebc866f62014-02-13 16:08:53 +05302247 pMac->scan.currentCountryRSSI = -128;
2248
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 if(!ps11dinfo)
2250 {
2251 return (status);
2252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2254 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302255 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2256 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2257 ps11dinfo->Channels.channelList,
2258 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 }
2260 else
2261 {
2262 //No change
2263 return (eHAL_STATUS_SUCCESS);
2264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002265 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302266
2267 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2268 WNI_CFG_COUNTRY_CODE_LEN);
2269
2270
Jeff Johnson295189b2012-06-20 16:38:30 -07002271 //Tush: at csropen get this initialized with default, during csr reset if this
2272 // already set with some value no need initilaize with default again
2273 if(0 == pMac->scan.countryCodeCurrent[0])
2274 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302275 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2276 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302279 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2280 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302282 vos_mem_set(pChanInfo,
2283 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2284 0);
2285
Jeff Johnson295189b2012-06-20 16:38:30 -07002286 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002287 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2288 {
2289 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2290 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2291 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2292 pChanInfo++;
2293 count++;
2294 }
2295 if(count)
2296 {
2297 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2298 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302299 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002300 }
2301 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2302 if( HAL_STATUS_SUCCESS(status) )
2303 {
2304 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2305 {
2306 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2307 {
2308 applyConfig = FALSE;
2309 }
2310 }
2311
2312 if(TRUE == applyConfig)
2313 {
2314 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002315 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002316 }
2317
2318 }
2319 return (status);
2320}
2321/* Initialize the Channel + Power List in the local cache and in the CFG */
2322eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2323{
2324 tANI_U8 index;
2325 tANI_U32 count=0;
2326 tSirMacChanInfo *pChanInfo;
2327 tSirMacChanInfo *pChanInfoStart;
2328
2329 if(!ps11dinfo || !pMac)
2330 {
2331 return eHAL_STATUS_FAILURE;
2332 }
2333
Kiet Lam64c1b492013-07-12 13:56:44 +05302334 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2335 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002336 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302337 vos_mem_set(pChanInfo,
2338 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2339 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002340 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002341
2342 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2343 {
2344 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2345 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2346 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2347 pChanInfo++;
2348 count++;
2349 }
2350 if(count)
2351 {
2352 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2353 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302354 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 }
2356
Jeff Johnsone7245742012-09-05 17:12:55 -07002357 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002358}
2359
2360//pCommand may be NULL
2361//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2362void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2363{
2364 tListElem *pEntry, *pNextEntry;
2365 tSmeCmd *pDupCommand;
2366 tDblLinkList localList;
2367
2368 vos_mem_zero(&localList, sizeof(tDblLinkList));
2369 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2370 {
2371 smsLog(pMac, LOGE, FL(" failed to open list"));
2372 return;
2373 }
2374 csrLLLock( &pMac->sme.smeCmdPendingList );
2375 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2376 while( pEntry )
2377 {
2378 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2379 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 // Remove the previous command if..
2381 // - the new roam command is for the same RoamReason...
2382 // - the new roam command is a NewProfileList.
2383 // - the new roam command is a Forced Dissoc
2384 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2385 if (
2386 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2387 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002388 /* This peermac check is requried for Softap/GO scenarios
2389 * For STA scenario below OR check will suffice as pCommand will
2390 * always be NULL for STA scenarios
2391 */
2392 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002393 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2394 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2395 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2396 ||
2397 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002398 ( (sessionId == pDupCommand->sessionId) &&
2399 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 ((eCsrForcedDisassoc == eRoamReason) ||
2401 (eCsrHddIssued == eRoamReason))
2402 )
2403 )
2404 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002405 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 // Remove the 'stale' roam command from the pending list...
2407 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2408 {
2409 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2410 }
2411 }
2412 pEntry = pNextEntry;
2413 }
2414 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2415
2416 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2417 {
2418 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2419 //Tell caller that the command is cancelled
2420 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2421 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2422 csrReleaseCommandRoam(pMac, pDupCommand);
2423 }
2424 csrLLClose(&localList);
2425}
Jeff Johnson295189b2012-06-20 16:38:30 -07002426eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2427 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2428{
2429 eHalStatus status = eHAL_STATUS_SUCCESS;
2430#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2431 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2432#endif
2433 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2435 {
2436 pSession = CSR_GET_SESSION( pMac, sessionId );
2437 }
2438 else
2439 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002440 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 VOS_ASSERT(0);
2442 return eHAL_STATUS_FAILURE;
2443 }
krunal soni587bf012014-02-04 12:35:11 -08002444
2445 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2446 {
2447 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2448 return eHAL_STATUS_FAILURE;
2449 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002450
krunal soni587bf012014-02-04 12:35:11 -08002451 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2452
krunal soni7f7d2c92014-02-06 15:08:43 -08002453 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002455 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002457 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2458 /*
2459 * Decrement bRefAssocStartCnt for FT reassoc failure.
2460 * Reason: For FT reassoc failures, we first call
2461 * csrRoamCallCallback before notifying a failed roam
2462 * completion through csrRoamComplete. The latter in
2463 * turn calls csrRoamProcessResults which tries to
2464 * once again call csrRoamCallCallback if bRefAssocStartCnt
2465 * is non-zero. Since this is redundant for FT reassoc
2466 * failure, decrement bRefAssocStartCnt.
2467 */
2468 pSession->bRefAssocStartCnt--;
2469 }
2470
Jeff Johnson295189b2012-06-20 16:38:30 -07002471 if(NULL != pSession->callback)
2472 {
2473 if( pRoamInfo )
2474 {
2475 pRoamInfo->sessionId = (tANI_U8)sessionId;
2476 }
2477
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302478 /* avoid holding the global lock when making the roaming callback, original change came
2479 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2480 is possible on other OS ports where the callback may need to take locks to protect
2481 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002482 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2483 that may actually depend on the lock being held */
2484 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2485 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2486 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2487 }
2488 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2489 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2490#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302491 vos_mem_set(&connectionStatus,
2492 sizeof(vos_event_wlan_status_payload_type), 0);
2493
krunal soni7f7d2c92014-02-06 15:08:43 -08002494 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002495 {
2496 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2497 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2498 if(NULL != pRoamInfo->pBssDesc)
2499 {
2500 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2501 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2504 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2505 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302506 vos_mem_copy(connectionStatus.ssid,
2507 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2508
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2510 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002512 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2513 {
2514 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2515 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2516 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002518 if(eCSR_ROAM_RESULT_FORCED == u2)
2519 {
2520 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2521 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2522 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002524 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2525 {
2526 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2527 connectionStatus.reason = eCSR_REASON_DISASSOC;
2528 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2531 {
2532 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2533 connectionStatus.reason = eCSR_REASON_DEAUTH;
2534 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002536#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2537
2538 return (status);
2539}
Jeff Johnson295189b2012-06-20 16:38:30 -07002540// Returns whether handoff is currently in progress or not
2541tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2542{
2543#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2544 return csrNeighborRoamIsHandoffInProgress(pMac);
2545#else
2546 return eANI_BOOLEAN_FALSE;
2547#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002548}
Jeff Johnson295189b2012-06-20 16:38:30 -07002549eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2550 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2551{
2552 eHalStatus status = eHAL_STATUS_SUCCESS;
2553 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2554 tANI_U16 reasonCode;
2555 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002556
2557 if(!pSession)
2558 {
2559 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2560 return eHAL_STATUS_FAILURE;
2561 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002562
2563 //Restore AC weight in case we change it
2564 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2565 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002566 smsLog(pMac, LOG1, FL(" restore AC weights (%d-%d-%d-%d)"), pMac->roam.ucACWeights[0], pMac->roam.ucACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2568 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2569 }
2570
2571 if ( fMICFailure )
2572 {
2573 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2574 }
2575 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2576 {
2577 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002578 }
2579 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 {
2581 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002583#ifdef WLAN_FEATURE_VOWIFI_11R
2584 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2585 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2586 {
2587 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302588 vos_mem_copy(&bssId,
2589 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2590 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002591 }
2592 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002593#endif
2594 if(pSession->pConnectBssDesc)
2595 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302596 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002598
Jeff Johnson295189b2012-06-20 16:38:30 -07002599
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302600 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2601 " subState = %s reason=%d"),
2602 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2603 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002604
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2606
2607 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2608
2609 if(HAL_STATUS_SUCCESS(status))
2610 {
2611 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002612#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2613 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2614 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2615 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002616 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2618 }
2619#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002620 }
2621 else
2622 {
2623 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2624 }
2625
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 return (status);
2627}
Jeff Johnson295189b2012-06-20 16:38:30 -07002628
Jeff Johnson295189b2012-06-20 16:38:30 -07002629/* ---------------------------------------------------------------------------
2630 \fn csrRoamIssueDisassociateStaCmd
2631 \brief csr function that HDD calls to disassociate a associated station
2632 \param sessionId - session Id for Soft AP
2633 \param pPeerMacAddr - MAC of associated station to delete
2634 \param reason - reason code, be one of the tSirMacReasonCodes
2635 \return eHalStatus
2636 ---------------------------------------------------------------------------*/
2637eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2638 tANI_U32 sessionId,
2639 tANI_U8 *pPeerMacAddr,
2640 tANI_U32 reason)
2641{
2642 eHalStatus status = eHAL_STATUS_SUCCESS;
2643 tSmeCmd *pCommand;
2644
2645 do
2646 {
2647 pCommand = csrGetCommandBuffer( pMac );
2648 if ( !pCommand )
2649 {
2650 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2651 status = eHAL_STATUS_RESOURCES;
2652 break;
2653 }
2654 pCommand->command = eSmeCommandRoam;
2655 pCommand->sessionId = (tANI_U8)sessionId;
2656 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2657 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2658 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2659 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2660 if( !HAL_STATUS_SUCCESS( status ) )
2661 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002662 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 csrReleaseCommandRoam( pMac, pCommand );
2664 }
2665 }while(0);
2666
2667 return status;
2668}
2669
2670
Jeff Johnson295189b2012-06-20 16:38:30 -07002671/* ---------------------------------------------------------------------------
2672 \fn csrRoamIssueDeauthSta
2673 \brief csr function that HDD calls to delete a associated station
2674 \param sessionId - session Id for Soft AP
2675 \param pPeerMacAddr - MAC of associated station to delete
2676 \param reason - reason code, be one of the tSirMacReasonCodes
2677 \return eHalStatus
2678 ---------------------------------------------------------------------------*/
2679eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2680 tANI_U32 sessionId,
2681 tANI_U8 *pPeerMacAddr,
2682 tANI_U32 reason)
2683{
2684 eHalStatus status = eHAL_STATUS_SUCCESS;
2685 tSmeCmd *pCommand;
2686
2687 do
2688 {
2689 pCommand = csrGetCommandBuffer( pMac );
2690 if ( !pCommand )
2691 {
2692 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2693 status = eHAL_STATUS_RESOURCES;
2694 break;
2695 }
2696 pCommand->command = eSmeCommandRoam;
2697 pCommand->sessionId = (tANI_U8)sessionId;
2698 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2699 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2700 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2701 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2702 if( !HAL_STATUS_SUCCESS( status ) )
2703 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002704 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 csrReleaseCommandRoam( pMac, pCommand );
2706 }
2707 }while(0);
2708
2709 return status;
2710}
Jeff Johnson295189b2012-06-20 16:38:30 -07002711eHalStatus
2712csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2713 tANI_BOOLEAN bEnable )
2714{
2715 eHalStatus status = eHAL_STATUS_FAILURE;
2716 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2717 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 if (!pSession)
2719 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002720 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002721 return (status);
2722 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 if (pSession->pConnectBssDesc)
2724 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302725 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 }
2727 else
2728 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002729 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 return (status);
2731 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002732 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2733 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002734 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2735 return (status);
2736}
Jeff Johnson295189b2012-06-20 16:38:30 -07002737eHalStatus
2738csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2739 VOS_MODULE_ID modId, void *pUsrContext,
2740 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2741{
2742 eHalStatus status = eHAL_STATUS_SUCCESS;
2743 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2744 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 if (!pSession)
2746 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002747 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002748 return (status);
2749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 if(pSession->pConnectBssDesc)
2751 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302752 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002753 }
2754 else
2755 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002756 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002757 return (status);
2758 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002759 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2760 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002761 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2762 return (status);
2763}
Jeff Johnson295189b2012-06-20 16:38:30 -07002764eHalStatus
2765csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2766 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2767{
2768 eHalStatus status = eHAL_STATUS_SUCCESS;
2769 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2770 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2771
2772 if (!pSession)
2773 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002774 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 return (status);
2776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 if(pSession->pConnectBssDesc)
2778 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302779 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 }
2781 else
2782 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002783 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002784 return (status);
2785 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002786 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2787 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002788
2789 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2790
2791 return (status);
2792}
Jeff Johnson295189b2012-06-20 16:38:30 -07002793eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2794{
2795 eHalStatus status = eHAL_STATUS_SUCCESS;
2796 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2797 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002798
2799 if (!pSession)
2800 {
2801 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2802 return eHAL_STATUS_FAILURE;
2803 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002804
2805 if(pSession->pConnectBssDesc)
2806 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302807 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002809 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2810 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2812
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302813 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002814 if(!HAL_STATUS_SUCCESS(status))
2815 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302816 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2817 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002818 }
2819
Jeff Johnson295189b2012-06-20 16:38:30 -07002820 return (status);
2821}
2822
Jeff Johnson295189b2012-06-20 16:38:30 -07002823eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2824{
2825 eHalStatus status = eHAL_STATUS_SUCCESS;
2826 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2827 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002828
2829 if(!pSession)
2830 {
2831 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2832 return eHAL_STATUS_FAILURE;
2833 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002834
2835 // If no BSS description was found in this connection (happens with start IBSS), then
2836 // nix the BSS description that we keep around for the connected BSS) and get out...
2837 if(NULL == pBssDesc)
2838 {
2839 csrFreeConnectBssDesc(pMac, sessionId);
2840 }
2841 else
2842 {
2843 size = pBssDesc->length + sizeof( pBssDesc->length );
2844 if(NULL != pSession->pConnectBssDesc)
2845 {
2846 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2847 {
2848 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2849 csrFreeConnectBssDesc(pMac, sessionId);
2850 }
2851 }
2852 if(NULL == pSession->pConnectBssDesc)
2853 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302854 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302856 if (NULL == pSession->pConnectBssDesc)
2857 status = eHAL_STATUS_FAILURE;
2858 else
2859 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002861 return (status);
2862}
2863
Jeff Johnson295189b2012-06-20 16:38:30 -07002864eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2865 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2866 tDot11fBeaconIEs *pIes)
2867{
2868 eHalStatus status = eHAL_STATUS_SUCCESS;
2869 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302871 if (pIes == NULL)
2872 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002873
Jeff Johnson295189b2012-06-20 16:38:30 -07002874 do
2875 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302876 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2877 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 //get qos
2879 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2880 //get SSID
2881 if(pIes->SSID.present)
2882 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302883 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002884 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2885 }
2886 else
2887 pBssConfig->SSID.length = 0;
2888 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2889 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002890 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 //Return failed if profile doesn't have an SSID either.
2892 if(pProfile->SSIDs.numOfSSIDs == 0)
2893 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002894 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002895 status = eHAL_STATUS_FAILURE;
2896 break;
2897 }
2898 }
2899 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2900 {
2901 pBssConfig->eBand = eCSR_BAND_5G;
2902 }
2903 else
2904 {
2905 pBssConfig->eBand = eCSR_BAND_24;
2906 }
2907 //phymode
2908 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2909 {
2910 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2911 }
2912 else
2913 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002914 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002915 //force it
2916 if(eCSR_BAND_24 == pBssConfig->eBand)
2917 {
2918 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2919 }
2920 else
2921 {
2922 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2923 }
2924 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002925 //Qos
2926 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2927 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2928 {
2929 //Joining BSS is not 11n capable and WMM is disabled on client.
2930 //Disable QoS and WMM
2931 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2932 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302933
2934 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302935 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302936 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2937 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2938 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2939 {
2940 //Joining BSS is 11n capable and WMM is disabled on AP.
2941 //Assume all HT AP's are QOS AP's and enable WMM
2942 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2943 }
2944
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 //auth type
2946 switch( pProfile->negotiatedAuthType )
2947 {
2948 default:
2949 case eCSR_AUTH_TYPE_WPA:
2950 case eCSR_AUTH_TYPE_WPA_PSK:
2951 case eCSR_AUTH_TYPE_WPA_NONE:
2952 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2953 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2954 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 case eCSR_AUTH_TYPE_SHARED_KEY:
2956 pBssConfig->authType = eSIR_SHARED_KEY;
2957 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 case eCSR_AUTH_TYPE_AUTOSWITCH:
2959 pBssConfig->authType = eSIR_AUTO_SWITCH;
2960 break;
2961 }
2962 //short slot time
2963 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2964 {
2965 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2966 }
2967 else
2968 {
2969 pBssConfig->uShortSlotTime = 0;
2970 }
2971 if(pBssConfig->BssCap.ibss)
2972 {
2973 //We don't support 11h on IBSS
2974 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2975 }
2976 else
2977 {
2978 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2979 }
2980 //power constraint
2981 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2982 //heartbeat
2983 if ( CSR_IS_11A_BSS( pBssDesc ) )
2984 {
2985 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2986 }
2987 else
2988 {
2989 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2990 }
2991 //Join timeout
2992 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002993 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002994 if ( pBssDesc->beaconInterval )
2995 {
2996 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002997 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 }
2999 else
3000 {
3001 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3002 }
3003 //validate CB
3004 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sandeep Puligilla60342762014-01-30 21:05:37 +05303005
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 return (status);
3008}
3009
Jeff Johnson295189b2012-06-20 16:38:30 -07003010static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3011 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3012{
3013 eHalStatus status = eHAL_STATUS_SUCCESS;
3014 tANI_U8 operationChannel = 0;
3015 tANI_U8 qAPisEnabled = FALSE;
3016 //SSID
3017 pBssConfig->SSID.length = 0;
3018 if(pProfile->SSIDs.numOfSSIDs)
3019 {
3020 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303021 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3022 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 }
3024 else
3025 {
3026 //SSID must present
3027 return eHAL_STATUS_FAILURE;
3028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 //Settomg up the capabilities
3030 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3031 {
3032 pBssConfig->BssCap.ibss = 1;
3033 }
3034 else
3035 {
3036 pBssConfig->BssCap.ess = 1;
3037 }
3038 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3039 {
3040 pBssConfig->BssCap.privacy = 1;
3041 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 pBssConfig->eBand = pMac->roam.configParam.eBand;
3043 //phymode
3044 if(pProfile->ChannelInfo.ChannelList)
3045 {
3046 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003048 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3049 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 //QOS
3051 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 if ( pBssConfig->BssCap.ess == 1 )
3053 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 /*For Softap case enable WMM*/
3055 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3056 qAPisEnabled = TRUE;
3057 }
3058 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3060 qAPisEnabled = TRUE;
3061 } else {
3062 qAPisEnabled = FALSE;
3063 }
3064 } else {
3065 qAPisEnabled = TRUE;
3066 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003067 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3068 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3069 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3070 )
3071 {
3072 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3073 } else {
3074 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3075 }
3076
3077 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003078 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 {
3080 default:
3081 case eCSR_AUTH_TYPE_WPA:
3082 case eCSR_AUTH_TYPE_WPA_PSK:
3083 case eCSR_AUTH_TYPE_WPA_NONE:
3084 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3085 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3086 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 case eCSR_AUTH_TYPE_SHARED_KEY:
3088 pBssConfig->authType = eSIR_SHARED_KEY;
3089 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 case eCSR_AUTH_TYPE_AUTOSWITCH:
3091 pBssConfig->authType = eSIR_AUTO_SWITCH;
3092 break;
3093 }
3094 //short slot time
3095 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3096 {
3097 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3098 }
3099 else
3100 {
3101 pBssConfig->uShortSlotTime = 0;
3102 }
3103 //power constraint. We don't support 11h on IBSS
3104 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3105 pBssConfig->uPowerLimit = 0;
3106 //heartbeat
3107 if ( eCSR_BAND_5G == pBssConfig->eBand )
3108 {
3109 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3110 }
3111 else
3112 {
3113 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3114 }
3115 //Join timeout
3116 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003117
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 return (status);
3119}
Jeff Johnson295189b2012-06-20 16:38:30 -07003120static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3121{
3122 eHalStatus status = eHAL_STATUS_FAILURE;
3123 tDot11fBeaconIEs *pIes = NULL;
3124
3125 do
3126 {
3127 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3128 {
3129 //err msg
3130 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003131 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 break;
3133 }
3134 //check if the AP is QAP & it supports APSD
3135 if( CSR_IS_QOS_BSS(pIes) )
3136 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303137 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 }
3139 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303140
3141 if (NULL != pIes)
3142 {
3143 vos_mem_free(pIes);
3144 }
3145
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 return status;
3147}
3148
Jeff Johnson295189b2012-06-20 16:38:30 -07003149void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3150{
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3152 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3153 // See !!Note: below in this function...
3154 tANI_U32 PrivacyEnabled = 0;
3155 tANI_U32 RsnEnabled = 0;
3156 tANI_U32 WepDefaultKeyId = 0;
3157 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3158 tANI_U32 Key0Length = 0;
3159 tANI_U32 Key1Length = 0;
3160 tANI_U32 Key2Length = 0;
3161 tANI_U32 Key3Length = 0;
3162
3163 // Reserve for the biggest key
3164 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3165 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3166 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3167 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3168
3169 switch ( pProfile->negotiatedUCEncryptionType )
3170 {
3171 case eCSR_ENCRYPT_TYPE_NONE:
3172
3173 // for NO encryption, turn off Privacy and Rsn.
3174 PrivacyEnabled = 0;
3175 RsnEnabled = 0;
3176
3177 // WEP key length and Wep Default Key ID don't matter in this case....
3178
3179 // clear out the WEP keys that may be hanging around.
3180 Key0Length = 0;
3181 Key1Length = 0;
3182 Key2Length = 0;
3183 Key3Length = 0;
3184
3185 break;
3186
3187 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303188 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003189
3190 // Privacy is ON. NO RSN for Wep40 static key.
3191 PrivacyEnabled = 1;
3192 RsnEnabled = 0;
3193
3194 // Set the Wep default key ID.
3195 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003196 // Wep key size if 5 bytes (40 bits).
3197 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3198
3199 // set encryption keys in the CFG database or clear those that are not present in this profile.
3200 if ( pProfile->Keys.KeyLength[0] )
3201 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303202 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3203 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3205 }
3206 else
3207 {
3208 Key0Length = 0;
3209 }
3210
3211 if ( pProfile->Keys.KeyLength[1] )
3212 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303213 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3214 WNI_CFG_WEP_KEY_LENGTH_5);
3215 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 }
3217 else
3218 {
3219 Key1Length = 0;
3220 }
3221
3222 if ( pProfile->Keys.KeyLength[2] )
3223 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303224 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3225 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3227 }
3228 else
3229 {
3230 Key2Length = 0;
3231 }
3232
3233 if ( pProfile->Keys.KeyLength[3] )
3234 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303235 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3236 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3238 }
3239 else
3240 {
3241 Key3Length = 0;
3242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003243 break;
3244
3245 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303246 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003247
3248 // Privacy is ON. NO RSN for Wep40 static key.
3249 PrivacyEnabled = 1;
3250 RsnEnabled = 0;
3251
3252 // Set the Wep default key ID.
3253 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3254
3255 // Wep key size if 13 bytes (104 bits).
3256 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3257
3258 // set encryption keys in the CFG database or clear those that are not present in this profile.
3259 if ( pProfile->Keys.KeyLength[0] )
3260 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303261 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3262 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003263 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3264 }
3265 else
3266 {
3267 Key0Length = 0;
3268 }
3269
3270 if ( pProfile->Keys.KeyLength[1] )
3271 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303272 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3273 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3275 }
3276 else
3277 {
3278 Key1Length = 0;
3279 }
3280
3281 if ( pProfile->Keys.KeyLength[2] )
3282 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303283 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3284 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003285 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3286 }
3287 else
3288 {
3289 Key2Length = 0;
3290 }
3291
3292 if ( pProfile->Keys.KeyLength[3] )
3293 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303294 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3295 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003296 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3297 }
3298 else
3299 {
3300 Key3Length = 0;
3301 }
3302
3303 break;
3304
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 case eCSR_ENCRYPT_TYPE_TKIP:
3306 case eCSR_ENCRYPT_TYPE_AES:
3307#ifdef FEATURE_WLAN_WAPI
3308 case eCSR_ENCRYPT_TYPE_WPI:
3309#endif /* FEATURE_WLAN_WAPI */
3310 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3311 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3312 PrivacyEnabled = (0 != fPrivacy);
3313
3314 // turn on RSN enabled for WPA associations
3315 RsnEnabled = 1;
3316
3317 // WEP key length and Wep Default Key ID don't matter in this case....
3318
3319 // clear out the static WEP keys that may be hanging around.
3320 Key0Length = 0;
3321 Key1Length = 0;
3322 Key2Length = 0;
3323 Key3Length = 0;
3324
3325 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 default:
3327 PrivacyEnabled = 0;
3328 RsnEnabled = 0;
3329 break;
3330 }
3331
3332 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3333 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3334 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3335 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3336 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3337 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3338 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3339 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3340}
3341
Jeff Johnson295189b2012-06-20 16:38:30 -07003342static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3343{
3344 tANI_U32 len = 0;
3345 if(pSSID->length <= WNI_CFG_SSID_LEN)
3346 {
3347 len = pSSID->length;
3348 }
3349 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3350}
3351
Jeff Johnson295189b2012-06-20 16:38:30 -07003352eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3353{
3354 eHalStatus status = eHAL_STATUS_SUCCESS;
3355 tANI_U32 QoSEnabled;
3356 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 // set the CFG enable/disable variables based on the qosType being configured...
3358 switch( qosType )
3359 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3361 QoSEnabled = FALSE;
3362 WmeEnabled = TRUE;
3363 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003364 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3365 QoSEnabled = FALSE;
3366 WmeEnabled = TRUE;
3367 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3369 QoSEnabled = FALSE;
3370 WmeEnabled = TRUE;
3371 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3373 QoSEnabled = TRUE;
3374 WmeEnabled = FALSE;
3375 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003376 case eCSR_MEDIUM_ACCESS_11e_HCF:
3377 QoSEnabled = TRUE;
3378 WmeEnabled = FALSE;
3379 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 default:
3381 case eCSR_MEDIUM_ACCESS_DCF:
3382 QoSEnabled = FALSE;
3383 WmeEnabled = FALSE;
3384 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 }
3386 //save the WMM setting for later use
3387 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303388 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003389 return (status);
3390}
Jeff Johnson295189b2012-06-20 16:38:30 -07003391static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3392 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3393{
3394 eHalStatus status = eHAL_STATUS_FAILURE;
3395 int i;
3396 eCsrCfgDot11Mode cfgDot11Mode;
3397 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303398 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3399 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003401
3402 if( NULL != pIes )
3403 {
3404 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 // Originally, we thought that for 11a networks, the 11a rates are always
3406 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3407 // appear in the Operational Rate set. Consequently, in either case, we
3408 // would blindly put the rates we support into our Operational Rate set
3409 // (including the basic rates, which we have already verified are
3410 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 // However, it turns out that this is not always the case. Some AP's
3412 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3413 // too. Now, we're a little more careful:
3414 pDstRate = pOpRateSet->rate;
3415 if(pIes->SuppRates.present)
3416 {
3417 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3418 {
3419 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3420 {
3421 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003422 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 }
3424 }
3425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3427 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3428 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3429 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3430 {
3431 // If there are Extended Rates in the beacon, we will reflect those
3432 // extended rates that we support in out Extended Operational Rate
3433 // set:
3434 pDstRate = pExRateSet->rate;
3435 if(pIes->ExtSuppRates.present)
3436 {
3437 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3438 {
3439 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3440 {
3441 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3442 pExRateSet->numRates++;
3443 }
3444 }
3445 }
3446 }
3447 }//Parsing BSSDesc
3448 else
3449 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003450 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 }
3452 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3453 return status;
3454}
3455
3456static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3457 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3458{
3459 int i;
3460 tANI_U8 *pDstRate;
3461 eCsrCfgDot11Mode cfgDot11Mode;
3462 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3463 tANI_U32 OperationalRatesLength = 0;
3464 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3465 tANI_U32 ExtendedOperationalRatesLength = 0;
3466 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3467 tANI_U32 ProprietaryOperationalRatesLength = 0;
3468 tANI_U32 PropRatesEnable = 0;
3469 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3470 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003471 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 if( NULL != pIes )
3473 {
3474 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 // Originally, we thought that for 11a networks, the 11a rates are always
3476 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3477 // appear in the Operational Rate set. Consequently, in either case, we
3478 // would blindly put the rates we support into our Operational Rate set
3479 // (including the basic rates, which we have already verified are
3480 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003481 // However, it turns out that this is not always the case. Some AP's
3482 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3483 // too. Now, we're a little more careful:
3484 pDstRate = OperationalRates;
3485 if(pIes->SuppRates.present)
3486 {
3487 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3488 {
3489 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3490 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3491 {
3492 *pDstRate++ = pIes->SuppRates.rates[ i ];
3493 OperationalRatesLength++;
3494 }
3495 }
3496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003497 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3498 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3499 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3500 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3501 {
3502 // If there are Extended Rates in the beacon, we will reflect those
3503 // extended rates that we support in out Extended Operational Rate
3504 // set:
3505 pDstRate = ExtendedOperationalRates;
3506 if(pIes->ExtSuppRates.present)
3507 {
3508 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3509 {
3510 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3511 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3512 {
3513 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3514 ExtendedOperationalRatesLength++;
3515 }
3516 }
3517 }
3518 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 // Enable proprietary MAC features if peer node is Airgo node and STA
3520 // user wants to use them
3521 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3522 {
3523 PropRatesEnable = 1;
3524 }
3525 else
3526 {
3527 PropRatesEnable = 0;
3528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 // For ANI network companions, we need to populate the proprietary rate
3530 // set with any proprietary rates we found in the beacon, only if user
3531 // allows them...
3532 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3533 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3534 {
3535 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3536 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3537 {
3538 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3539 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303540 vos_mem_copy(ProprietaryOperationalRates,
3541 pIes->Airgo.PropSuppRates.rates,
3542 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003543 }
3544 else {
3545 // No proprietary modes...
3546 ProprietaryOperationalRatesLength = 0;
3547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 /* Get MCS Rate */
3549 pDstRate = MCSRateIdxSet;
3550 if ( pIes->HTCaps.present )
3551 {
3552 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3553 {
3554 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3555 {
3556 MCSRateLength++;
3557 *pDstRate++ = i;
3558 }
3559 }
3560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003561 // Set the operational rate set CFG variables...
3562 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3563 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3564 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3565 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3566 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3567 ProprietaryOperationalRates,
3568 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3569 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3570 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3571 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3572 }//Parsing BSSDesc
3573 else
3574 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003575 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 }
3577}
3578
Jeff Johnson295189b2012-06-20 16:38:30 -07003579static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3580 tCsrRoamProfile *pProfile )
3581{
3582 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3583 { 8,
3584 { SIR_MAC_RATE_6,
3585 SIR_MAC_RATE_9,
3586 SIR_MAC_RATE_12,
3587 SIR_MAC_RATE_18,
3588 SIR_MAC_RATE_24,
3589 SIR_MAC_RATE_36,
3590 SIR_MAC_RATE_48,
3591 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003592 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3593 { 4,
3594 { SIR_MAC_RATE_1,
3595 SIR_MAC_RATE_2,
3596 SIR_MAC_RATE_5_5,
3597 SIR_MAC_RATE_11 } } };
3598
3599
3600 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3601 { SIR_MAC_RATE_72,
3602 SIR_MAC_RATE_96,
3603 SIR_MAC_RATE_108 } };
3604 eCsrCfgDot11Mode cfgDot11Mode;
3605 eCsrBand eBand;
3606 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3607 tANI_U32 OperationalRatesLength = 0;
3608 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3609 tANI_U32 ExtendedOperationalRatesLength = 0;
3610 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3611 tANI_U32 ProprietaryOperationalRatesLength = 0;
3612 tANI_U32 PropRatesEnable = 0;
3613 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 if(pProfile->ChannelInfo.ChannelList)
3615 {
3616 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3617 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003619 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3620 // networks, the 11b rates appear in the Operational Rate set. In either case,
3621 // we can blindly put the rates we support into our Operational Rate set
3622 // (including the basic rates, which we have already verified are supported
3623 // earlier in the roaming decision).
3624 if ( eCSR_BAND_5G == eBand )
3625 {
3626 // 11a rates into the Operational Rate Set.
3627 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3628 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303629 vos_mem_copy(OperationalRates,
3630 DefaultSupportedRates11a.supportedRateSet.rate,
3631 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003632
3633 // Nothing in the Extended rate set.
3634 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003635 // populate proprietary rates if user allows them
3636 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3637 {
3638 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3639 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303640 vos_mem_copy(ProprietaryOperationalRates,
3641 DefaultSupportedPropRates.propRate,
3642 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003643 }
3644 else
3645 {
3646 // No proprietary modes
3647 ProprietaryOperationalRatesLength = 0;
3648 }
3649 }
3650 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3651 {
3652 // 11b rates into the Operational Rate Set.
3653 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3654 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303655 vos_mem_copy(OperationalRates,
3656 DefaultSupportedRates11b.supportedRateSet.rate,
3657 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 // Nothing in the Extended rate set.
3659 ExtendedOperationalRatesLength = 0;
3660 // No proprietary modes
3661 ProprietaryOperationalRatesLength = 0;
3662 }
3663 else
3664 {
3665 // 11G
3666
3667 // 11b rates into the Operational Rate Set.
3668 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3669 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303670 vos_mem_copy(OperationalRates,
3671 DefaultSupportedRates11b.supportedRateSet.rate,
3672 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003673
3674 // 11a rates go in the Extended rate set.
3675 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3676 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303677 vos_mem_copy(ExtendedOperationalRates,
3678 DefaultSupportedRates11a.supportedRateSet.rate,
3679 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003680
3681 // populate proprietary rates if user allows them
3682 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3683 {
3684 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3685 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303686 vos_mem_copy(ProprietaryOperationalRates,
3687 DefaultSupportedPropRates.propRate,
3688 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003689 }
3690 else
3691 {
3692 // No proprietary modes
3693 ProprietaryOperationalRatesLength = 0;
3694 }
3695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3697 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3698 {
3699 PropRatesEnable = 1;
3700 }
3701 else
3702 {
3703 PropRatesEnable = 0;
3704 }
3705
3706 // Set the operational rate set CFG variables...
3707 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3708 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3709 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3710 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3711 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3712 ProprietaryOperationalRates,
3713 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3714 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003715}
Jeff Johnson295189b2012-06-20 16:38:30 -07003716void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3717{
3718 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003719
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3721 tANI_U32 sessionId;
3722 tSmeCmd *pCommand = NULL;
3723
3724 if(NULL == pEntry)
3725 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003726 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 return;
3728 }
3729 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3730 sessionId = pCommand->sessionId;
3731
3732 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3733 {
3734 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3735 }
3736}
3737
Jeff Johnson295189b2012-06-20 16:38:30 -07003738//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3739tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3740{
3741 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3742 {
3743 return (WNI_CFG_PHY_MODE_11B);
3744 }
3745 else
3746 {
3747 if(eCSR_BAND_24 == band)
3748 return (WNI_CFG_PHY_MODE_11G);
3749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 return (WNI_CFG_PHY_MODE_11A);
3751}
Jeff Johnson295189b2012-06-20 16:38:30 -07003752
Jeff Johnsone7245742012-09-05 17:12:55 -07003753
3754#ifdef WLAN_FEATURE_11AC
3755ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3756{
3757 switch ( aniCBMode )
3758 {
3759 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3760 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3761 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3762 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3763 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3764 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3765 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3766 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3767 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003768 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003769 return PHY_SINGLE_CHANNEL_CENTERED;
3770 }
3771}
3772#endif
3773
Jeff Johnson295189b2012-06-20 16:38:30 -07003774//pIes may be NULL
3775eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3776 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303777 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003778{
3779 eHalStatus status = eHAL_STATUS_SUCCESS;
3780 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3781 tANI_U8 channel = 0;
3782 //Make sure we have the domain info for the BSS we try to connect to.
3783 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303784 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003785 {
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05303786 if (csrLearnCountryInformation(pMac, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003787 {
3788 //Make sure the 11d info from this BSSDesc can be applied
3789 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303790 if (VOS_TRUE == resetCountry)
3791 {
3792 csrApplyCountryInformation(pMac, FALSE);
3793 }
3794 else
3795 {
3796 csrApplyCountryInformation(pMac, TRUE);
3797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 }
Kiran4a17ebe2013-01-31 10:43:43 -08003799 if ((csrIs11dSupported (pMac)) && pIes)
3800 {
3801 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003802 {
Kiran4a17ebe2013-01-31 10:43:43 -08003803 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003804 }
3805 else
3806 {
3807 //Let's also update the below to make sure we don't update CC while
3808 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303809 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003810 pBssDesc->bssId, sizeof(tSirMacAddr));
3811 }
Kiran4a17ebe2013-01-31 10:43:43 -08003812 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 //Qos
3815 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3816 //SSID
3817 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3818 //fragment threshold
3819 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3820 //RTS threshold
3821 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3822
3823 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 //Auth type
3825 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3826 //encryption type
3827 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3828 //short slot time
3829 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003830 //11d
3831 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3832 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3833 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003834 /*//11h
3835 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3836 */
3837 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3838 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003839
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003840 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 {
3842 channel = pProfile->operationChannel;
3843 }
3844 else
3845 {
3846 if(pBssDesc)
3847 {
3848 channel = pBssDesc->channelId;
3849 }
3850 }
3851 if(0 != channel)
3852 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05303853 if(CSR_IS_CHANNEL_24GHZ(channel) &&
3854 !pMac->roam.configParam.channelBondingMode24GHz &&
3855 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
3856 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05303858 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
3859 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
3860 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 }
3862 else
3863 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003864 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003865 }
3866 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003867#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003868 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3869 // in function csrConvertCBIniValueToPhyCBState()
3870 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3871 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003872 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003873 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003874 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003875 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05303876 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003877 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003878 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003879 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003880 }
3881 else
3882#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003883 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3884 //Rate
3885 //Fixed Rate
3886 if(pBssDesc)
3887 {
3888 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3889 }
3890 else
3891 {
3892 csrSetCfgRateSetFromProfile(pMac, pProfile);
3893 }
3894 //Make this the last CFG to set. The callback will trigger a join_req
3895 //Join time out
3896 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3897
3898 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 return (status);
3900}
3901
Jeff Johnson295189b2012-06-20 16:38:30 -07003902eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3903 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3904{
3905 eHalStatus status;
3906 tBssConfigParam *pBssConfig;
3907 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003908
3909 if(!pSession)
3910 {
3911 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3912 return eHAL_STATUS_FAILURE;
3913 }
3914
Kiet Lam64c1b492013-07-12 13:56:44 +05303915 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
3916 if ( NULL == pBssConfig )
3917 status = eHAL_STATUS_FAILURE;
3918 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303920 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3922 if(HAL_STATUS_SUCCESS(status))
3923 {
3924 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003925 /* This will allow to pass cbMode during join req */
3926 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003927 //For IBSS, we need to prepare some more information
3928 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 )
3931 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003932 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 }
3934 // If we are in an IBSS, then stop the IBSS...
3935 ////Not worry about WDS connection for now
3936 if ( csrIsConnStateIbss( pMac, sessionId ) )
3937 {
3938 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3939 }
3940 else
3941 {
3942 // if we are in an Infrastructure association....
3943 if ( csrIsConnStateInfra( pMac, sessionId ) )
3944 {
3945 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3946 // across SSIDs (roaming to a new SSID)... //
3947 //Not worry about WDS connection for now
3948 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303949 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 {
3951 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303952 status = csrRoamIssueDisassociate( pMac, sessionId,
3953 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303955 else
3956 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3958 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303959 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303961 // Set parameters for this Bss.
3962 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3963 pBssDesc, pBssConfig,
3964 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303968 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 {
3970 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3971 // Nothing to stop.
3972 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303974 )
3975 {
3976 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3977 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3978 // Set parameters for this Bss.
3979 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3980 pBssDesc, pBssConfig,
3981 pIes, is11rRoamingFlag);
3982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 }
3984 }
3985 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05303986 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07003987 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 return (status);
3989}
3990
Jeff Johnson295189b2012-06-20 16:38:30 -07003991eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3992 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3993{
3994 eCsrJoinState eRoamState = eCsrContinueRoaming;
3995 eHalStatus status;
3996 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3997 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3998 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003999
4000 if(!pSession)
4001 {
4002 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4003 return (eCsrStopRoaming);
4004 }
4005
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 if( CSR_IS_WDS_STA( pProfile ) )
4007 {
4008 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4009 if( !HAL_STATUS_SUCCESS( status ) )
4010 {
4011 eRoamState = eCsrStopRoaming;
4012 }
4013 }
4014 else
4015 {
4016 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4017 {
4018 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4019 return (eCsrStopRoaming);
4020 }
4021 if ( csrIsInfraBssDesc( pBssDesc ) )
4022 {
4023 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4024 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4025 // have changed and handle the changes (without disturbing the current association).
4026
4027 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4028 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4029 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4030 )
4031 {
4032 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4033 // with Authenticating first. To force this, stop the current association (Disassociate) and
4034 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4035 // a new Association.
4036 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4037 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004038 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4040 {
4041 eRoamState = eCsrReassocToSelfNoCapChange;
4042 }
4043 else
4044 {
4045 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304047 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4049 if(HAL_STATUS_SUCCESS(status))
4050 {
4051 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004052 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304054 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4055 pBssDesc, &bssConfig,
4056 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 if(!HAL_STATUS_SUCCESS(status))
4058 {
4059 eRoamState = eCsrStopRoaming;
4060 }
4061 }
4062 else
4063 {
4064 eRoamState = eCsrStopRoaming;
4065 }
4066 }//same profile
4067 }
4068 else
4069 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304070 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4072 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304073 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4074 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304076 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304078 }
4079 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 {
4081 // note: we used to pre-auth here with open authentication networks but that was not working so well.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304082 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07004083 // work much better.
4084 //
4085 //
4086 // stop the existing network before attempting to join the new network...
4087 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4088 {
4089 eRoamState = eCsrStopRoaming;
4090 }
4091 }
4092 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304093 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 {
4095 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4096 {
4097 eRoamState = eCsrStopRoaming;
4098 }
4099 }
4100 if( pIesLocal && !pScanResult->pvIes )
4101 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304102 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 }
4104 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 return( eRoamState );
4106}
4107
Jeff Johnson295189b2012-06-20 16:38:30 -07004108eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4109 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4110{
4111 eHalStatus status = eHAL_STATUS_SUCCESS;
4112 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304113 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 roamInfo.pBssDesc = pBssDesc;
4115 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4116 return (status);
4117}
Jeff Johnson295189b2012-06-20 16:38:30 -07004118//In case no matching BSS is found, use whatever default we can find
4119static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4120{
4121 //Need to get all negotiated types in place first
4122 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004123 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 {
4125 default:
4126 case eCSR_AUTH_TYPE_WPA:
4127 case eCSR_AUTH_TYPE_WPA_PSK:
4128 case eCSR_AUTH_TYPE_WPA_NONE:
4129 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4130 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4131 break;
4132
4133 case eCSR_AUTH_TYPE_SHARED_KEY:
4134 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4135 break;
4136
4137 case eCSR_AUTH_TYPE_AUTOSWITCH:
4138 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4139 break;
4140 }
4141 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4142 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4143 //In this case, the multicast encryption needs to follow the uncast ones.
4144 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4145 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4146}
4147
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004148
4149static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4150{
4151 switch(pCommand->u.roamCmd.roamReason)
4152 {
4153 case eCsrLostLink1:
4154 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4155 break;
4156 case eCsrLostLink2:
4157 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4158 break;
4159 case eCsrLostLink3:
4160 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4161 break;
4162 default:
4163 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4164 pCommand->u.roamCmd.roamReason);
4165 break;
4166 }
4167}
4168
Jeff Johnson295189b2012-06-20 16:38:30 -07004169static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4170{
4171 eHalStatus status;
4172 tCsrScanResult *pScanResult = NULL;
4173 eCsrJoinState eRoamState = eCsrStopRoaming;
4174 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4175 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4176 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4177#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4178 v_U8_t acm_mask = 0;
4179#endif
4180 tANI_U32 sessionId = pCommand->sessionId;
4181 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4182 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4183 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004184
4185 if(!pSession)
4186 {
4187 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4188 return (eCsrStopRoaming);
4189 }
4190
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 do
4192 {
4193 // Check for Cardbus eject condition, before trying to Roam to any BSS
4194 //***if( !balIsCardPresent(pAdapter) ) break;
4195
Kiet Lam64c1b492013-07-12 13:56:44 +05304196 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004197 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 if(NULL != pBSSList)
4199 {
4200 // When handling AP's capability change, continue to associate to
4201 // same BSS and make sure pRoamBssEntry is not Null.
4202 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4203 {
4204 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4205 {
4206 //Try the first BSS
4207 pCommand->u.roamCmd.pLastRoamBss = NULL;
4208 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4209 }
4210 else
4211 {
4212 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4213 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4214 {
4215 //Done with all the BSSs
4216 //In this case, will tell HDD the completion
4217 break;
4218 }
4219 else
4220 {
4221 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304222 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004223 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4224 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4225 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4226 pRoamInfo = &roamInfo;
4227 }
4228 }
4229 while(pCommand->u.roamCmd.pRoamBssEntry)
4230 {
4231 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 /*If concurrency enabled take the concurrent connected channel first. */
4233 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004234 if (vos_concurrent_sessions_running() &&
4235 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004236 {
4237 concurrentChannel =
4238 csrGetConcurrentOperationChannel(pMac);
4239 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004240 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004241 if ((concurrentChannel) &&
4242 (concurrentChannel ==
4243 pScanResult->Result.BssDescriptor.channelId))
4244 {
4245 //make this 0 because we do not want the
4246 //below check to pass as we don't want to
4247 //connect on other channel
4248 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4249 FL("Concurrent channel match =%d"),
4250 concurrentChannel);
4251 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 }
4253 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004254
4255 if (!concurrentChannel)
4256 {
4257
4258 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4259 sessionId, &pScanResult->Result.BssDescriptor,
4260 pCommand->u.roamCmd.roamId)))
4261 {
4262 //Ok to roam this
4263 break;
4264 }
4265 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004266 else
4267 {
4268 eRoamState = eCsrStopRoamingDueToConcurrency;
4269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4271 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4272 {
4273 //Done with all the BSSs
4274 fDone = eANI_BOOLEAN_TRUE;
4275 break;
4276 }
4277 }
4278 if(fDone)
4279 {
4280 break;
4281 }
4282 }
4283 }
4284 //We have something to roam, tell HDD when it is infra.
4285 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4286 //For WDS, the indication is eCSR_ROAM_WDS_IND
4287 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4288 {
4289 if(pRoamInfo)
4290 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004291 if(pSession->bRefAssocStartCnt)
4292 {
4293 pSession->bRefAssocStartCnt--;
4294 //Complete the last association attemp because a new one is about to be tried
4295 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4296 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004298 }
4299 }
4300 /* If the roaming has stopped, not to continue the roaming command*/
4301 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4302 {
4303 //No need to complete roaming here as it already completes
4304 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4305 pCommand->u.roamCmd.roamReason);
4306 eRoamState = eCsrStopRoaming;
4307 csrSetAbortRoamingCommand(pMac, pCommand);
4308 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304310 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 if(pScanResult)
4312 {
4313 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4315 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004316 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 fDone = eANI_BOOLEAN_TRUE;
4318 eRoamState = eCsrStopRoaming;
4319 break;
4320 }
4321 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4322 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4323 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4324 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4325 CSR_IS_QOS_BSS(pIesLocal) &&
4326 CSR_IS_UAPSD_BSS(pIesLocal) )
4327 {
4328#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004329 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4330 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004331#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004332 }
4333 else
4334 {
4335 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4336 }
4337 if( pIesLocal && !pScanResult->Result.pvIes)
4338 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304339 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004340 }
4341 }
4342 else
4343 {
4344 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4345 }
4346 roamInfo.pProfile = pProfile;
4347 pSession->bRefAssocStartCnt++;
4348 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4349 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4352 {
4353 // If this is a start IBSS profile, then we need to start the IBSS.
4354 if ( CSR_IS_START_IBSS(pProfile) )
4355 {
4356 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 // Attempt to start this IBSS...
4358 csrRoamAssignDefaultParam( pMac, pCommand );
4359 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4360 if(HAL_STATUS_SUCCESS(status))
4361 {
4362 if ( fSameIbss )
4363 {
4364 eRoamState = eCsrStartIbssSameIbss;
4365 }
4366 else
4367 {
4368 eRoamState = eCsrContinueRoaming;
4369 }
4370 }
4371 else
4372 {
4373 //it somehow fail need to stop
4374 eRoamState = eCsrStopRoaming;
4375 }
4376 break;
4377 }
4378 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 )
4381 {
4382 // Attempt to start this WDS...
4383 csrRoamAssignDefaultParam( pMac, pCommand );
4384 /* For AP WDS, we dont have any BSSDescription */
4385 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4386 if(HAL_STATUS_SUCCESS(status))
4387 {
4388 eRoamState = eCsrContinueRoaming;
4389 }
4390 else
4391 {
4392 //it somehow fail need to stop
4393 eRoamState = eCsrStopRoaming;
4394 }
4395 }
4396 else
4397 {
4398 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004399 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004400 eRoamState = eCsrStopRoaming;
4401 break;
4402 }
4403 }
4404 else //We have BSS
4405 {
4406 //Need to assign these value because they are used in csrIsSameProfile
4407 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4408 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4409 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4410 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4411 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4412 {
4413 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4414 {
4415 eRoamState = eCsrStartIbssSameIbss;
4416 break;
4417 }
4418 }
4419 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4420 {
4421 //trying to connect to the one already connected
4422 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4423 eRoamState = eCsrReassocToSelfNoCapChange;
4424 break;
4425 }
4426 // Attempt to Join this Bss...
4427 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4428 break;
4429 }
4430
4431 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004432 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4433 {
4434 //Need to indicate association_completion if association_start has been done
4435 if(pSession->bRefAssocStartCnt > 0)
4436 {
4437 pSession->bRefAssocStartCnt--;
4438 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004439 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004440 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4441 eCSR_ROAM_ASSOCIATION_COMPLETION,
4442 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4443 }
4444 }
4445
4446 return( eRoamState );
4447}
4448
Jeff Johnson295189b2012-06-20 16:38:30 -07004449static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4450{
4451 eHalStatus status = eHAL_STATUS_SUCCESS;
4452 eCsrJoinState RoamState;
4453 tANI_U32 sessionId = pCommand->sessionId;
4454
Jeff Johnson295189b2012-06-20 16:38:30 -07004455 //***if( hddIsRadioStateOn( pAdapter ) )
4456 {
4457 // Attept to join a Bss...
4458 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004459
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004461 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 {
4463 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004464 // and if connected in Infrastructure mode...
4465 if ( csrIsConnStateInfra(pMac, sessionId) )
4466 {
4467 //... then we need to issue a disassociation
4468 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4469 if(!HAL_STATUS_SUCCESS(status))
4470 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004471 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004472 //roam command is completed by caller in the failed case
4473 fComplete = eANI_BOOLEAN_TRUE;
4474 }
4475 }
4476 else if( csrIsConnStateIbss(pMac, sessionId) )
4477 {
4478 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4479 if(!HAL_STATUS_SUCCESS(status))
4480 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004481 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 //roam command is completed by caller in the failed case
4483 fComplete = eANI_BOOLEAN_TRUE;
4484 }
4485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4487 {
4488 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4489 if(!HAL_STATUS_SUCCESS(status))
4490 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004491 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 //roam command is completed by caller in the failed case
4493 fComplete = eANI_BOOLEAN_TRUE;
4494 }
4495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004496 else
4497 {
4498 fComplete = eANI_BOOLEAN_TRUE;
4499 }
4500 if(fComplete)
4501 {
4502 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004503 if(eCsrStopRoamingDueToConcurrency == RoamState)
4504 {
4505 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4506 }
4507 else
4508 {
4509 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 }
4512 }
4513 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4514 {
4515 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4516 }
4517 else if ( eCsrStartIbssSameIbss == RoamState )
4518 {
4519 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4520 }
4521 }//hddIsRadioStateOn
4522
4523 return status;
4524}
Jeff Johnson295189b2012-06-20 16:38:30 -07004525eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4526{
4527 tANI_U32 sessionId;
4528 tCsrRoamSession *pSession;
4529 tCsrScanResult *pScanResult = NULL;
4530 tSirBssDescription *pBssDesc = NULL;
4531 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 sessionId = pCommand->sessionId;
4533 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004534
4535 if(!pSession)
4536 {
4537 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4538 return eHAL_STATUS_FAILURE;
4539 }
4540
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4542 {
4543 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004544 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4546 return eHAL_STATUS_FAILURE;
4547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 if (pCommand->u.roamCmd.pRoamBssEntry)
4549 {
4550 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4551 pBssDesc = &pScanResult->Result.BssDescriptor;
4552 }
4553 else
4554 {
4555 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004556 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4558 return eHAL_STATUS_FAILURE;
4559 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4561 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4562 return status;
4563}
4564
Jeff Johnson295189b2012-06-20 16:38:30 -07004565eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4566{
4567 eHalStatus status = eHAL_STATUS_SUCCESS;
4568 tCsrRoamInfo roamInfo;
4569 tANI_U32 sessionId = pCommand->sessionId;
4570 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004571
4572 if(!pSession)
4573 {
4574 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4575 return eHAL_STATUS_FAILURE;
4576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004577
4578 switch ( pCommand->u.roamCmd.roamReason )
4579 {
4580 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004582 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 case eCsrSmeIssuedDisassocForHandoff:
4585 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4586#if 0 // TODO : Confirm this change
4587 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4588#else
4589 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4590#endif
4591
4592 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004595 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004596 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004599 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004600 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004601 case eCsrHddIssuedReassocToSameAP:
4602 case eCsrSmeIssuedReassocToSameAP:
4603 {
4604 tDot11fBeaconIEs *pIes = NULL;
4605
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 if( pSession->pConnectBssDesc )
4607 {
4608 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4609 if(!HAL_STATUS_SUCCESS(status) )
4610 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004611 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 }
4613 else
4614 {
4615 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4616 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4617 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4619 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4620 pSession->bRefAssocStartCnt++;
4621 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4622 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4623
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004624 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004625 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4626 &pCommand->u.roamCmd.roamProfile );
4627 if(!HAL_STATUS_SUCCESS(status))
4628 {
4629 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004630 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004631 }
4632
Kiet Lam64c1b492013-07-12 13:56:44 +05304633 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 pIes = NULL;
4635 }
4636 }
4637 break;
4638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004640 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004641 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4642 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4643 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004645 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004646 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4647 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004648
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 case eCsrStopBss:
4650 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4651 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4652 break;
4653
4654 case eCsrForcedDisassocSta:
4655 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4656 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4657 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4658 pCommand->u.roamCmd.reason);
4659 break;
4660
4661 case eCsrForcedDeauthSta:
4662 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4663 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4664 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4665 pCommand->u.roamCmd.reason);
4666 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004667
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004668 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004669 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004670 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4671 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004672 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004673
4674 default:
4675 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4676
4677 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4678 {
4679 //Remember the roaming profile
4680 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304681 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4682 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304684 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004685 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4686 }
4687 }
4688
4689 //At this point, original uapsd_mask is saved in pCurRoamProfile
4690 //uapsd_mask in the pCommand may change from this point on.
4691
4692 // Attempt to roam with the new scan results (if we need to..)
4693 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004694 if(!HAL_STATUS_SUCCESS(status))
4695 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004696 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004698 break;
4699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 return (status);
4701}
4702
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004703void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4704{
4705 pCommand->u.roamCmd.pLastRoamBss = NULL;
4706 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4707 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304708 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004709}
4710
Jeff Johnson295189b2012-06-20 16:38:30 -07004711void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4712{
4713 if(pCommand->u.roamCmd.fReleaseBssList)
4714 {
4715 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4716 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4717 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4718 }
4719 if(pCommand->u.roamCmd.fReleaseProfile)
4720 {
4721 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4722 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4723 }
4724 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4725 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304726 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004727}
4728
Jeff Johnson295189b2012-06-20 16:38:30 -07004729void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4730{
Kiet Lam64c1b492013-07-12 13:56:44 +05304731 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004732}
Jeff Johnson295189b2012-06-20 16:38:30 -07004733void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4734{
4735 tListElem *pEntry;
4736 tSmeCmd *pCommand;
4737 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004738 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004739 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4740 if ( pEntry )
4741 {
4742 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004743 // If the head of the queue is Active and it is a ROAM command, remove
4744 // and put this on the Free queue.
4745 if ( eSmeCommandRoam == pCommand->command )
4746 {
4747 //we need to process the result first before removing it from active list because state changes
4748 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4749 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4750 if( fReleaseCommand )
4751 {
4752 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4753 {
4754 csrReleaseCommandRoam( pMac, pCommand );
4755 }
4756 else
4757 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004758 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004759 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 }
4761 }
4762 else
4763 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004764 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004765 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 }
4767 }
4768 else
4769 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004770 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 }
4772 }
4773 else
4774 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004775 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 if( fReleaseCommand )
4778 {
4779 smeProcessPendingQueue( pMac );
4780 }
4781}
4782
Jeff Johnson295189b2012-06-20 16:38:30 -07004783void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4784{
4785 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004786 if(!pSession)
4787 {
4788 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4789 return;
4790 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304791 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4792 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004793 pSession->NumPmkidCandidate = 0;
4794}
Jeff Johnson295189b2012-06-20 16:38:30 -07004795#ifdef FEATURE_WLAN_WAPI
4796void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4797{
4798 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004799 if(!pSession)
4800 {
4801 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4802 return;
4803 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304804 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4805 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004806 pSession->NumBkidCandidate = 0;
4807}
4808#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004809extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4810
Jeff Johnson295189b2012-06-20 16:38:30 -07004811static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4812 tSirBssDescription *pSirBssDesc,
4813 tDot11fBeaconIEs *pIes)
4814{
4815 eHalStatus status = eHAL_STATUS_SUCCESS;
4816 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4817 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004818
4819 if(!pSession)
4820 {
4821 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4822 return eHAL_STATUS_FAILURE;
4823 }
4824
Jeff Johnson295189b2012-06-20 16:38:30 -07004825 if((eCSR_AUTH_TYPE_WPA == authType) ||
4826 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4827 (eCSR_AUTH_TYPE_RSN == authType) ||
4828 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4829#if defined WLAN_FEATURE_VOWIFI_11R
4830 ||
4831 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4832 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4833#endif /* FEATURE_WLAN_WAPI */
4834#ifdef FEATURE_WLAN_WAPI
4835 ||
4836 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4837 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4838#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004839#ifdef WLAN_FEATURE_11W
4840 ||
4841 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4842#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004843 )
4844 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4846 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004847 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 }
4849 if( pIesLocal )
4850 {
4851 tANI_U32 nIeLen;
4852 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004853 if((eCSR_AUTH_TYPE_RSN == authType) ||
4854#if defined WLAN_FEATURE_VOWIFI_11R
4855 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4856 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4857#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004858#if defined WLAN_FEATURE_11W
4859 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4860#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004861 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4862 {
4863 if(pIesLocal->RSN.present)
4864 {
4865 //Calculate the actual length
4866 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4867 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4868 + 2 //akm_suite_count
4869 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4870 + 2; //reserved
4871 if( pIesLocal->RSN.pmkid_count )
4872 {
4873 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4874 }
4875 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304876 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4877 if (NULL == pSession->pWpaRsnRspIE)
4878 status = eHAL_STATUS_FAILURE;
4879 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304881 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4883 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4884 //copy upto akm_suites
4885 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304886 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4887 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004888 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304889 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4890 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004891 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304892 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4893 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004894 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 if( pIesLocal->RSN.pwise_cipher_suite_count )
4896 {
4897 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304898 vos_mem_copy(pIeBuf,
4899 pIesLocal->RSN.pwise_cipher_suites,
4900 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004901 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4902 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304903 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 pIeBuf += 2;
4905 if( pIesLocal->RSN.akm_suite_count )
4906 {
4907 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304908 vos_mem_copy(pIeBuf,
4909 pIesLocal->RSN.akm_suites,
4910 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4912 }
4913 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05304914 vos_mem_copy(pIeBuf,
4915 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
4916 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4918 }
4919 }
4920 }
4921 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4922 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4923 {
4924 if(pIesLocal->WPA.present)
4925 {
4926 //Calculate the actual length
4927 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4928 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4929 + 2 //auth_suite_count
4930 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4931 // The WPA capabilities follows the Auth Suite (two octects)--
4932 // this field is optional, and we always "send" zero, so just
4933 // remove it. This is consistent with our assumptions in the
4934 // frames compiler; c.f. bug 15234:
4935 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304936
4937 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4938 if ( NULL == pSession->pWpaRsnRspIE )
4939 status = eHAL_STATUS_FAILURE;
4940 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 {
4942 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4943 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4944 pIeBuf = pSession->pWpaRsnRspIE + 2;
4945 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05304946 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304948 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
4949 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304951 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
4952 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004953 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4954 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4955 }
4956 }
4957 }
4958#ifdef FEATURE_WLAN_WAPI
4959 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4960 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4961 {
4962 if(pIesLocal->WAPI.present)
4963 {
4964 //Calculate the actual length
4965 nIeLen = 4 //version + akm_suite_count
4966 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4967 + 2 //pwise_cipher_suite_count
4968 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4969 + 6; //gp_cipher_suite + preauth + reserved
4970 if( pIesLocal->WAPI.bkid_count )
4971 {
4972 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4973 }
4974
4975 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304976 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
4977 if ( NULL == pSession->pWapiRspIE )
4978 status = eHAL_STATUS_FAILURE;
4979 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 {
4981 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4982 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4983 pIeBuf = pSession->pWapiRspIE + 2;
4984 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05304985 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 pIeBuf += 4;
4987 if( pIesLocal->WAPI.akm_suite_count )
4988 {
4989 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304990 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
4991 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304993 }
4994 vos_mem_copy(pIeBuf,
4995 &pIesLocal->WAPI.unicast_cipher_suite_count,
4996 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004997 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4999 {
5000 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305001 vos_mem_copy( pIeBuf,
5002 pIesLocal->WAPI.unicast_cipher_suites,
5003 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5005 }
lukez3c809222013-05-03 10:23:02 -07005006 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305007 vos_mem_copy(pIeBuf,
5008 pIesLocal->WAPI.multicast_cipher_suite,
5009 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005010 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305011 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305012 vos_mem_copy(pIeBuf,
5013 pIesLocal->WAPI.multicast_cipher_suite + 4,
5014 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005015 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305016 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305017 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5018
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005019 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 if( pIesLocal->WAPI.bkid_count )
5021 {
5022 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305023 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5024 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5026 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305027 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005029 }
5030 }
5031#endif /* FEATURE_WLAN_WAPI */
5032 if( !pIes )
5033 {
5034 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305035 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005036 }
5037 }
5038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005039 return (status);
5040}
5041
Jeff Johnson295189b2012-06-20 16:38:30 -07005042static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5043{
5044 v_U8_t bACWeights[WLANTL_MAX_AC];
5045 v_U8_t paramBk, paramBe, paramVi, paramVo;
5046 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5048 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5049 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5050 //This doesn't address the case where the lower AC needs a real higher weight
5051 if( pIEs->WMMParams.present )
5052 {
5053 //no change to the lowest ones
5054 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5055 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5056 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5057 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5058 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5059 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5060 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5061 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5062 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5063 {
5064 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5065 fWeightChange = VOS_TRUE;
5066 }
5067 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5068 {
5069 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5070 fWeightChange = VOS_TRUE;
5071 }
5072 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5073 {
5074 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5075 fWeightChange = VOS_TRUE;
5076 }
5077 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5078 {
5079 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5080 fWeightChange = VOS_TRUE;
5081 }
5082 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5083 {
5084 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5085 fWeightChange = VOS_TRUE;
5086 }
5087 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5088 {
5089 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5090 fWeightChange = VOS_TRUE;
5091 }
5092 if(fWeightChange)
5093 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005094 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005095 bACWeights[2], bACWeights[3]);
5096 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5097 }
5098 }
5099}
Jeff Johnson295189b2012-06-20 16:38:30 -07005100#ifdef WLAN_FEATURE_VOWIFI_11R
5101//Returns whether the current association is a 11r assoc or not
5102tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5103{
5104#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5105 return csrNeighborRoamIs11rAssoc(pMac);
5106#else
5107 return eANI_BOOLEAN_FALSE;
5108#endif
5109}
5110#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005111#ifdef FEATURE_WLAN_ESE
5112//Returns whether the current association is a ESE assoc or not
5113tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005114{
5115#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005116 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005117#else
5118 return eANI_BOOLEAN_FALSE;
5119#endif
5120}
5121#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005122#ifdef FEATURE_WLAN_LFR
5123//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305124tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005125{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305126 tCsrRoamSession *pSession = NULL;
5127
5128 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5129 {
5130 pSession = CSR_GET_SESSION( pMac, sessionId );
5131 if (NULL != pSession->pCurRoamProfile)
5132 {
5133 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5134 {
5135 return eANI_BOOLEAN_FALSE;
5136 }
5137 }
5138 }
5139
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005140#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5141 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5142 {
5143 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5144 }
5145 else
5146#endif
5147 {
5148 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005149 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005150 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005151}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005152
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005153#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005154/* ---------------------------------------------------------------------------
5155
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005156 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005157
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005158 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005159
5160 \param pMac - The handle returned by macOpen.
5161
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005162 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005163
5164---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005165tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005166{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005167 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005168}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005169#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005170
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005171#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5172//Returns whether "FW based BG scan" is currently enabled...or not
5173tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5174{
5175 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5176}
5177#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005178#endif
5179
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005180#if defined(FEATURE_WLAN_ESE)
5181tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005182{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005183 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005184}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005185#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005186
Jeff Johnson295189b2012-06-20 16:38:30 -07005187//Return true means the command can be release, else not
5188static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5189 eCsrRoamCompleteResult Result, void *Context )
5190{
5191 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5192 tSirBssDescription *pSirBssDesc = NULL;
5193 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5194 tCsrScanResult *pScanResult = NULL;
5195 tCsrRoamInfo roamInfo;
5196 sme_QosAssocInfo assocInfo;
5197 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5198 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5199 tDot11fBeaconIEs *pIes = NULL;
5200 tANI_U32 sessionId = pCommand->sessionId;
5201 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5202 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5203 eRoamCmdStatus roamStatus;
5204 eCsrRoamResult roamResult;
5205 eHalStatus status;
5206 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005207 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005208
Jeff Johnson32d95a32012-09-10 13:15:23 -07005209 if(!pSession)
5210 {
5211 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5212 return eANI_BOOLEAN_FALSE;
5213 }
5214
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005215 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 switch( Result )
5217 {
5218 case eCsrJoinSuccess:
5219 // reset the IDLE timer
5220 // !!
5221 // !! fall through to the next CASE statement here is intentional !!
5222 // !!
5223 case eCsrReassocSuccess:
5224 if(eCsrReassocSuccess == Result)
5225 {
5226 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5227 }
5228 else
5229 {
5230 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5231 }
5232 // Success Join Response from LIM. Tell NDIS we are connected and save the
5233 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005234 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305235 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 //always free the memory here
5237 if(pSession->pWpaRsnRspIE)
5238 {
5239 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305240 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005241 pSession->pWpaRsnRspIE = NULL;
5242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005243#ifdef FEATURE_WLAN_WAPI
5244 if(pSession->pWapiRspIE)
5245 {
5246 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305247 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 pSession->pWapiRspIE = NULL;
5249 }
5250#endif /* FEATURE_WLAN_WAPI */
5251#ifdef FEATURE_WLAN_BTAMP_UT_RF
5252 //Reset counter so no join retry is needed.
5253 pSession->maxRetryCount = 0;
5254 csrRoamStopJoinRetryTimer(pMac, sessionId);
5255#endif
5256 /* This creates problem since we have not saved the connected profile.
5257 So moving this after saving the profile
5258 */
5259 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305260
5261 /* Reset remainInPowerActiveTillDHCP as it might have been set
5262 * by last failed secured connection.
5263 * It should be set only for secured connection.
5264 */
5265 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005266 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5267 {
5268 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5269 }
5270 else
5271 {
5272 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 //Use the last connected bssdesc for reassoc-ing to the same AP.
5275 //NOTE: What to do when reassoc to a different AP???
5276 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5277 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5278 {
5279 pSirBssDesc = pSession->pConnectBssDesc;
5280 if(pSirBssDesc)
5281 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305282 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5283 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005284 }
5285 }
5286 else
5287 {
5288
5289 if(pCommand->u.roamCmd.pRoamBssEntry)
5290 {
5291 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5292 if(pScanResult != NULL)
5293 {
5294 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5295 //this can be NULL
5296 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305297 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5298 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 }
5300 }
5301 }
5302 if( pSirBssDesc )
5303 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005304 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005305 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5306 //Save WPA/RSN IE
5307 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005308#ifdef FEATURE_WLAN_ESE
5309 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005310#endif
5311
5312 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5313 // substate change.
5314 // Moving even save profile above so that below mentioned conditon is also met.
5315 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5316 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005317 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5318 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5319 // will be dropped for the security context may not be set properly.
5320 //
5321 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5322 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5323 //
5324 // this reordering was done on titan_prod_usb branch and is being replicated here.
5325 //
5326
5327 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5328 !pProfile->bWPSAssociation)
5329 {
5330 // Issue the set Context request to LIM to establish the Unicast STA context
5331 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5332 pProfile->negotiatedUCEncryptionType,
5333 pSirBssDesc, &(pSirBssDesc->bssId),
5334 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5335 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005336 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005337 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5338 }
5339 // Issue the set Context request to LIM to establish the Broadcast STA context
5340 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5341 pSirBssDesc, &BroadcastMac,
5342 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5343 }
5344 else
5345 {
5346 //Need to wait for supplicant authtication
5347 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005348 //Set the subestate to WaitForKey in case authentiation is needed
5349 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5350
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 if(pProfile->bWPSAssociation)
5352 {
5353 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5354 }
5355 else
5356 {
5357 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5358 }
5359
5360 //Save sessionId in case of timeout
5361 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5362 //This time should be long enough for the rest of the process plus setting key
5363 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5364 {
5365 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005366 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005367 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5368 }
5369 }
5370
5371 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5372 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 if(Context)
5374 {
5375 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5376 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005377 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5378 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5379#ifdef WLAN_FEATURE_VOWIFI_11R
5380 len += pJoinRsp->parsedRicRspLen;
5381#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005382#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005383 len += pJoinRsp->tspecIeLen;
5384#endif
5385 if(len)
5386 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305387 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5388 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305390 vos_mem_copy(pSession->connectedInfo.pbFrames,
5391 pJoinRsp->frames, len);
5392 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5393 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5394 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005395#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305396 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005397#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005398#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305399 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005400#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305401 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5402 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5403 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5404 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 }
5406 }
5407 if(pCommand->u.roamCmd.fReassoc)
5408 {
5409 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5410 }
5411 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5412 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5413 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5414 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5415 }
5416 else
5417 {
5418 if(pCommand->u.roamCmd.fReassoc)
5419 {
5420 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5421 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5422 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5423 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5424 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5425 }
5426 }
5427#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5428 // Indicate SME-QOS with reassoc success event, only after
5429 // copying the frames
5430 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5431#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005432 roamInfo.pBssDesc = pSirBssDesc;
5433 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5434 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5435#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5436 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5437#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5438 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5440 //It may be better to let QoS do this????
5441 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5442 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005443 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5445 pmcStartUapsd( pMac, NULL, NULL );
5446 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305447 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5449 if( pSession->bRefAssocStartCnt > 0 )
5450 {
5451 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005452 //Remove this code once SLM_Sessionization is supported
5453 //BMPS_WORKAROUND_NOT_NEEDED
5454 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005455 {
5456 pMac->roam.configParam.doBMPSWorkaround = 1;
5457 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005458 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5459 }
5460
5461 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 // reset the PMKID candidate list
5463 csrResetPMKIDCandidateList( pMac, sessionId );
5464 //Update TL's AC weight base on the current EDCA parameters
5465 //These parameters may change in the course of the connection, that sictuation
5466 //is not taken care here. This change is mainly to address a WIFI WMM test where
5467 //BE has a equal or higher TX priority than VI.
5468 //We only do this for infra link
5469 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5470 {
5471 csrCheckAndUpdateACWeight(pMac, pIes);
5472 }
5473#ifdef FEATURE_WLAN_WAPI
5474 // reset the BKID candidate list
5475 csrResetBKIDCandidateList( pMac, sessionId );
5476#endif /* FEATURE_WLAN_WAPI */
5477 }
5478 else
5479 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005480 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005481 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 csrScanCancelIdleScan(pMac);
5483 //Not to signal link up because keys are yet to be set.
5484 //The linkup function will overwrite the sub-state that we need to keep at this point.
5485 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5486 {
5487 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5490 //enough to let security and DHCP handshake succeed before entry into BMPS
5491 if (pmcShouldBmpsTimerRun(pMac))
5492 {
Abhishek Singh65d939e2014-04-25 13:33:07 +05305493 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5494 * until keys are set before going into BMPS.
5495 */
5496 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5497 {
5498 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5499 smsLog(pMac, LOG1, FL("Set remainInPowerActiveTillDHCP "
5500 "to make sure we wait until keys are set before"
5501 " going to BMPS"));
5502 }
5503
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5505 != eHAL_STATUS_SUCCESS)
5506 {
5507 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5508 }
5509 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 break;
5512
Jeff Johnson295189b2012-06-20 16:38:30 -07005513 case eCsrStartBssSuccess:
5514 // on the StartBss Response, LIM is returning the Bss Description that we
5515 // are beaconing. Add this Bss Description to our scan results and
5516 // chain the Profile to this Bss Description. On a Start BSS, there was no
5517 // detected Bss description (no partner) so we issued the Start Bss to
5518 // start the Ibss without any Bss description. Lim was kind enough to return
5519 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005520 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005521 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005522 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305523 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005524 if( CSR_IS_IBSS( pProfile ) )
5525 {
5526 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005528 else if (CSR_IS_INFRA_AP(pProfile))
5529 {
5530 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 else
5533 {
5534 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5535 }
5536 if( !CSR_IS_WDS_STA( pProfile ) )
5537 {
5538 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5541 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305542 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005543 roamInfo.pBssDesc = pSirBssDesc;
5544 //We need to associate_complete it first, becasue Associate_start already indicated.
5545 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5546 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5547 break;
5548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005549 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005551 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 }
5553 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5554 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5555 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5556 if(pSirBssDesc)
5557 {
5558 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305559 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5560 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 }
5562 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305563 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005564#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5565 {
5566 vos_log_ibss_pkt_type *pIbssLog;
5567 tANI_U32 bi;
5568
5569 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5570 if(pIbssLog)
5571 {
5572 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5573 {
5574 //We start the IBSS (didn't find any matched IBSS out there)
5575 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5576 }
5577 else
5578 {
5579 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5580 }
5581 if(pSirBssDesc)
5582 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305583 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005584 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5585 }
5586 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5587 {
5588 //***U8 is not enough for beacon interval
5589 pIbssLog->beaconInterval = (v_U8_t)bi;
5590 }
5591 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5592 }
5593 }
5594#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5595 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5596 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5598 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005599 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5600 csrRoamIssueSetContextReq( pMac, sessionId,
5601 pProfile->negotiatedMCEncryptionType,
5602 pSirBssDesc, &BroadcastMac,
5603 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5604 }
5605 }
5606 else
5607 {
5608 //Keep the state to eCSR_ROAMING_STATE_JOINING
5609 //Need to send join_req.
5610 if(pCommand->u.roamCmd.pRoamBssEntry)
5611 {
5612 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5613 {
5614 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5615 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5616 // Set the roaming substate to 'join attempt'...
5617 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005618 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005619 }
5620 }
5621 else
5622 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005623 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005624 VOS_ASSERT( 0 );
5625 }
5626 }
5627 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5628 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5629 //trigger the connection start indication in Vista
5630 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5631 {
5632 roamStatus = eCSR_ROAM_IBSS_IND;
5633 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5634 if( CSR_IS_WDS( pProfile ) )
5635 {
5636 roamStatus = eCSR_ROAM_WDS_IND;
5637 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 if( CSR_IS_INFRA_AP( pProfile ) )
5640 {
5641 roamStatus = eCSR_ROAM_INFRA_IND;
5642 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005644
5645 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5646 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5647 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305648 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005649 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5650 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005651 //We start the IBSS (didn't find any matched IBSS out there)
5652 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305654 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5655 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005656 //Remove this code once SLM_Sessionization is supported
5657 //BMPS_WORKAROUND_NOT_NEEDED
5658 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005659 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005660 {
5661 pMac->roam.configParam.doBMPSWorkaround = 1;
5662 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005663
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5665 }
5666
5667 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005668
5669 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 {
5671 //need to send stop BSS because we fail to send join_req
5672 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5673 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5674 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005676 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 case eCsrStartBssFailure:
5678#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5679 {
5680 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005681 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5682 if(pIbssLog)
5683 {
5684 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5685 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5686 }
5687 }
5688#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 roamStatus = eCSR_ROAM_IBSS_IND;
5690 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5691 if( CSR_IS_WDS( pProfile ) )
5692 {
5693 roamStatus = eCSR_ROAM_WDS_IND;
5694 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 if( CSR_IS_INFRA_AP( pProfile ) )
5697 {
5698 roamStatus = eCSR_ROAM_INFRA_IND;
5699 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 if(Context)
5702 {
5703 pSirBssDesc = (tSirBssDescription *)Context;
5704 }
5705 else
5706 {
5707 pSirBssDesc = NULL;
5708 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305709 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005710 roamInfo.pBssDesc = pSirBssDesc;
5711 //We need to associate_complete it first, becasue Associate_start already indicated.
5712 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5713 csrSetDefaultDot11Mode( pMac );
5714 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005715 case eCsrSilentlyStopRoaming:
5716 // We are here because we try to start the same IBSS
5717 //No message to PE
5718 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005719 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005720 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5721 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305722 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5724 if( roamInfo.pBssDesc )
5725 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305726 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5727 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005728 }
5729 //Since there is no change in the current state, simply pass back no result otherwise
5730 //HDD may be mistakenly mark to disconnected state.
5731 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5732 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005733 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005734 case eCsrSilentlyStopRoamingSaveState:
5735 //We are here because we try to connect to the same AP
5736 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005737 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305738 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005739
5740 //to aviod resetting the substate to NONE
5741 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5742 //No need to change substate to wai_for_key because there is no state change
5743 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5744 if( roamInfo.pBssDesc )
5745 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305746 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5747 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5750 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5751 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5752 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5753 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5754 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5755 roamInfo.staId = pSession->connectedInfo.staId;
5756 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005758 pSession->bRefAssocStartCnt--;
5759 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5760 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5761 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5762 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005763 case eCsrReassocFailure:
5764#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5765 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5766#endif
5767 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005768 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005769 csrFreeConnectBssDesc(pMac, sessionId);
5770 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5771 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305772 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005773 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5774 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5775 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5776 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5777 eCSR_ROAM_WDS_IND,
5778 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5779 //Need to issue stop_bss
5780 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 case eCsrJoinFailure:
5782 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005783 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 default:
5785 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005786 smsLog(pMac, LOGW, FL("receives no association indication"));
5787 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005788 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5790 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5791 {
5792 //do not free for the other profiles as we need to send down stop BSS later
5793 csrFreeConnectBssDesc(pMac, sessionId);
5794 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5795 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5796 csrSetDefaultDot11Mode( pMac );
5797 }
5798
5799 switch( pCommand->u.roamCmd.roamReason )
5800 {
5801 // If this transition is because of an 802.11 OID, then we transition
5802 // back to INIT state so we sit waiting for more OIDs to be issued and
5803 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005804 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 case eCsrSmeIssuedAssocToSimilarAP:
5806 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005807 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305809 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5811 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5812 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305813 vos_mem_copy(&roamInfo.bssid,
5814 &pSession->joinFailStatusCode.bssId,
5815 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005816
Jeff Johnson295189b2012-06-20 16:38:30 -07005817 /* Defeaturize this later if needed */
5818#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5819 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5820 if (csrRoamIsHandoffInProgress(pMac))
5821 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 /* Should indicate neighbor roam algorithm about the connect failure here */
5823 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005825#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 if(pSession->bRefAssocStartCnt > 0)
5827 {
5828 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005829 if(eCsrJoinFailureDueToConcurrency == Result)
5830 {
5831 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5832 eCSR_ROAM_ASSOCIATION_COMPLETION,
5833 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5834 }
5835 else
5836 {
5837 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 eCSR_ROAM_ASSOCIATION_COMPLETION,
5839 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005840 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005842 else
5843 {
5844 /* bRefAssocStartCnt is not incremented when
5845 * eRoamState == eCsrStopRoamingDueToConcurrency
5846 * in csrRoamJoinNextBss API. so handle this in
5847 * else case by sending assoc failure
5848 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005849 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005850 pCommand->u.scanCmd.roamId,
5851 eCSR_ROAM_ASSOCIATION_FAILURE,
5852 eCSR_ROAM_RESULT_FAILURE);
5853 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005854 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005855#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05305856 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5858#endif
5859 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5860 csrScanStartIdleScan(pMac);
5861#ifdef FEATURE_WLAN_BTAMP_UT_RF
5862 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5863 //BT activity and not able to recevie WLAN traffic. Retry the join
5864 if( CSR_IS_WDS_STA(pProfile) )
5865 {
5866 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5867 }
5868#endif
5869 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 case eCsrHddIssuedReassocToSameAP:
5871 case eCsrSmeIssuedReassocToSameAP:
5872 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5873
5874 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5875#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5876 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5877#endif
5878 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5879 csrScanStartIdleScan(pMac);
5880 break;
5881 case eCsrForcedDisassoc:
5882 case eCsrForcedDeauth:
5883 case eCsrSmeIssuedIbssJoinFailure:
5884 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5885
5886 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5887 {
5888 // Notify HDD that IBSS join failed
5889 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5890 }
5891 else
5892 {
5893 csrRoamCallCallback(pMac, sessionId, NULL,
5894 pCommand->u.roamCmd.roamId,
5895 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5896 }
5897#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5898 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5899#endif
5900 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08005901 /*
5902 *DelSta not done FW still in conneced state so dont
5903 *issue IMPS req
5904 */
5905 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
5906 {
5907 smsLog(pMac, LOGW, FL("FW still in connected state "));
5908 break;
5909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 csrScanStartIdleScan(pMac);
5911 break;
5912 case eCsrForcedIbssLeave:
5913 csrRoamCallCallback(pMac, sessionId, NULL,
5914 pCommand->u.roamCmd.roamId,
5915 eCSR_ROAM_IBSS_LEAVE,
5916 eCSR_ROAM_RESULT_IBSS_STOP);
5917 break;
5918 case eCsrForcedDisassocMICFailure:
5919 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5920
5921 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5922#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5923 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5924#endif
5925 csrScanStartIdleScan(pMac);
5926 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 case eCsrStopBss:
5928 csrRoamCallCallback(pMac, sessionId, NULL,
5929 pCommand->u.roamCmd.roamId,
5930 eCSR_ROAM_INFRA_IND,
5931 eCSR_ROAM_RESULT_INFRA_STOPPED);
5932 break;
5933 case eCsrForcedDisassocSta:
5934 case eCsrForcedDeauthSta:
5935 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5936 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5937 {
5938 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005939
5940 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5941 {
5942 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05305943 vos_mem_copy(roamInfo.peerMac,
5944 pCommand->u.roamCmd.peerMac,
5945 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5947 roamInfo.statusCode = eSIR_SME_SUCCESS;
5948 status = csrRoamCallCallback(pMac, sessionId,
5949 &roamInfo, pCommand->u.roamCmd.roamId,
5950 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5951 }
5952 }
5953 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005954 case eCsrLostLink1:
5955 // if lost link roam1 failed, then issue lost link Scan2 ...
5956 csrScanRequestLostLink2(pMac, sessionId);
5957 break;
5958 case eCsrLostLink2:
5959 // if lost link roam2 failed, then issue lost link scan3 ...
5960 csrScanRequestLostLink3(pMac, sessionId);
5961 break;
5962 case eCsrLostLink3:
5963 default:
5964 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5965
5966 //We are done with one round of lostlink roaming here
5967 csrScanHandleFailedLostlink3(pMac, sessionId);
5968 break;
5969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 break;
5971 }
5972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005973 return ( fReleaseCommand );
5974}
5975
Jeff Johnson295189b2012-06-20 16:38:30 -07005976eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5977{
5978 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 return (status);
5980}
5981
Jeff Johnson295189b2012-06-20 16:38:30 -07005982eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5983{
5984 eHalStatus status = eHAL_STATUS_SUCCESS;
5985 tANI_U32 size = 0;
5986
5987 do
5988 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305989 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005990 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5991 {
5992 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305993 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
5994 if ( NULL == pDstProfile->BSSIDs.bssid )
5995 status = eHAL_STATUS_FAILURE;
5996 else
5997 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 if(!HAL_STATUS_SUCCESS(status))
5999 {
6000 break;
6001 }
6002 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306003 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6004 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006005 }
6006 if(pSrcProfile->SSIDs.numOfSSIDs)
6007 {
6008 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306009 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6010 if ( NULL == pDstProfile->SSIDs.SSIDList )
6011 status = eHAL_STATUS_FAILURE;
6012 else
6013 status = eHAL_STATUS_SUCCESS;
6014 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 {
6016 break;
6017 }
6018 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306019 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6020 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 }
6022 if(pSrcProfile->nWPAReqIELength)
6023 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306024 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6025 if ( NULL == pDstProfile->pWPAReqIE )
6026 status = eHAL_STATUS_FAILURE;
6027 else
6028 status = eHAL_STATUS_SUCCESS;
6029
6030 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 {
6032 break;
6033 }
6034 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306035 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6036 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 }
6038 if(pSrcProfile->nRSNReqIELength)
6039 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306040 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6041 if ( NULL == pDstProfile->pRSNReqIE )
6042 status = eHAL_STATUS_FAILURE;
6043 else
6044 status = eHAL_STATUS_SUCCESS;
6045
6046 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 {
6048 break;
6049 }
6050 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306051 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6052 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006053 }
6054#ifdef FEATURE_WLAN_WAPI
6055 if(pSrcProfile->nWAPIReqIELength)
6056 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306057 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6058 if ( NULL == pDstProfile->pWAPIReqIE )
6059 status = eHAL_STATUS_FAILURE;
6060 else
6061 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 if(!HAL_STATUS_SUCCESS(status))
6063 {
6064 break;
6065 }
6066 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306067 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6068 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 }
6070#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 if(pSrcProfile->nAddIEScanLength)
6072 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306073 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6074 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006075 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306076 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306077 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306078 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6079 }
6080 else
6081 {
6082 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6083 FL(" AddIEScanLength is not valid %u"),
6084 pSrcProfile->nAddIEScanLength);
6085 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 if(pSrcProfile->nAddIEAssocLength)
6088 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306089 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6090 if ( NULL == pDstProfile->pAddIEAssoc )
6091 status = eHAL_STATUS_FAILURE;
6092 else
6093 status = eHAL_STATUS_SUCCESS;
6094
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 if(!HAL_STATUS_SUCCESS(status))
6096 {
6097 break;
6098 }
6099 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306100 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6101 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006103 if(pSrcProfile->ChannelInfo.ChannelList)
6104 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306105 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6106 pSrcProfile->ChannelInfo.numOfChannels);
6107 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6108 status = eHAL_STATUS_FAILURE;
6109 else
6110 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 if(!HAL_STATUS_SUCCESS(status))
6112 {
6113 break;
6114 }
6115 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306116 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6117 pSrcProfile->ChannelInfo.ChannelList,
6118 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 pDstProfile->AuthType = pSrcProfile->AuthType;
6121 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6122 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6123 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6124 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6125 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006126#ifdef WLAN_FEATURE_11W
6127 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6128 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6129 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6130#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006131 pDstProfile->BSSType = pSrcProfile->BSSType;
6132 pDstProfile->phyMode = pSrcProfile->phyMode;
6133 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6134
6135#ifdef FEATURE_WLAN_WAPI
6136 if(csrIsProfileWapi(pSrcProfile))
6137 {
6138 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6139 {
6140 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6141 }
6142 }
6143#endif /* FEATURE_WLAN_WAPI */
6144 pDstProfile->CBMode = pSrcProfile->CBMode;
6145 /*Save the WPS info*/
6146 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006147 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006148 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 pDstProfile->privacy = pSrcProfile->privacy;
6151 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6152 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6153 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6154 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6155 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6156 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6157 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6158 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6159 pDstProfile->wps_state = pSrcProfile->wps_state;
6160 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306161 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6162 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006163#ifdef WLAN_FEATURE_VOWIFI_11R
6164 if (pSrcProfile->MDID.mdiePresent)
6165 {
6166 pDstProfile->MDID.mdiePresent = 1;
6167 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6168 }
6169#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 }while(0);
6171
6172 if(!HAL_STATUS_SUCCESS(status))
6173 {
6174 csrReleaseProfile(pMac, pDstProfile);
6175 pDstProfile = NULL;
6176 }
6177
6178 return (status);
6179}
Jeff Johnson295189b2012-06-20 16:38:30 -07006180eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6181{
6182 eHalStatus status = eHAL_STATUS_SUCCESS;
6183 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6184 do
6185 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306186 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006187 if(pSrcProfile->bssid)
6188 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306189 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6190 if ( NULL == pDstProfile->BSSIDs.bssid )
6191 status = eHAL_STATUS_FAILURE;
6192 else
6193 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006194 if(!HAL_STATUS_SUCCESS(status))
6195 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306196 smsLog( pMac, LOGE,
6197 FL("failed to allocate memory for BSSID"
6198 "%02x:%02x:%02x:%02x:%02x:%02x"),
6199 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6200 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 break;
6202 }
6203 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306204 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6205 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006206 }
6207 if(pSrcProfile->SSID.ssId)
6208 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306209 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6210 if ( NULL == pDstProfile->SSIDs.SSIDList )
6211 status = eHAL_STATUS_FAILURE;
6212 else
6213 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006214 if(!HAL_STATUS_SUCCESS(status))
6215 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306216 smsLog( pMac, LOGE,
6217 FL("failed to allocate memory for SSIDList"
6218 "%02x:%02x:%02x:%02x:%02x:%02x"),
6219 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6220 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 break;
6222 }
6223 pDstProfile->SSIDs.numOfSSIDs = 1;
6224 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6225 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306226 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6227 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006229 if(pSrcProfile->nAddIEAssocLength)
6230 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306231 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6232 if ( NULL == pDstProfile->pAddIEAssoc)
6233 status = eHAL_STATUS_FAILURE;
6234 else
6235 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006236 if(!HAL_STATUS_SUCCESS(status))
6237 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006238 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006239 break;
6240 }
6241 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306242 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6243 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006244 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306245 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6246 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6247 status = eHAL_STATUS_FAILURE;
6248 else
6249 status = eHAL_STATUS_SUCCESS;
6250
Jeff Johnson295189b2012-06-20 16:38:30 -07006251 if(!HAL_STATUS_SUCCESS(status))
6252 {
6253 break;
6254 }
6255 pDstProfile->ChannelInfo.numOfChannels = 1;
6256 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 pDstProfile->AuthType.numEntries = 1;
6258 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6259 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6260 pDstProfile->EncryptionType.numEntries = 1;
6261 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6262 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6263 pDstProfile->mcEncryptionType.numEntries = 1;
6264 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6265 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6266 pDstProfile->BSSType = pSrcProfile->BSSType;
6267 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306268 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6269 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006270#ifdef WLAN_FEATURE_VOWIFI_11R
6271 if (pSrcProfile->MDID.mdiePresent)
6272 {
6273 pDstProfile->MDID.mdiePresent = 1;
6274 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6275 }
6276#endif
6277
6278 }while(0);
6279
6280 if(!HAL_STATUS_SUCCESS(status))
6281 {
6282 csrReleaseProfile(pMac, pDstProfile);
6283 pDstProfile = NULL;
6284 }
6285
6286 return (status);
6287}
6288
Jeff Johnson295189b2012-06-20 16:38:30 -07006289eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6290 tScanResultHandle hBSSList,
6291 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6292 tANI_BOOLEAN fClearScan)
6293{
6294 eHalStatus status = eHAL_STATUS_SUCCESS;
6295 tSmeCmd *pCommand;
6296
6297 pCommand = csrGetCommandBuffer(pMac);
6298 if(NULL == pCommand)
6299 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006300 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 status = eHAL_STATUS_RESOURCES;
6302 }
6303 else
6304 {
6305 if( fClearScan )
6306 {
6307 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306308 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 }
6310 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6311 if(NULL == pProfile)
6312 {
6313 //We can roam now
6314 //Since pProfile is NULL, we need to build our own profile, set everything to default
6315 //We can only support open and no encryption
6316 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6317 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6318 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6319 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6320 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6321 }
6322 else
6323 {
6324 //make a copy of the profile
6325 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6326 if(HAL_STATUS_SUCCESS(status))
6327 {
6328 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6329 }
6330 }
6331 pCommand->command = eSmeCommandRoam;
6332 pCommand->sessionId = (tANI_U8)sessionId;
6333 pCommand->u.roamCmd.hBSSList = hBSSList;
6334 pCommand->u.roamCmd.roamId = roamId;
6335 pCommand->u.roamCmd.roamReason = reason;
6336 //We need to free the BssList when the command is done
6337 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6338 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6340 FL("CSR PERSONA=%d"),
6341 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6343 if( !HAL_STATUS_SUCCESS( status ) )
6344 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006345 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006346 csrReleaseCommandRoam( pMac, pCommand );
6347 }
6348 }
6349
6350 return (status);
6351}
Jeff Johnson295189b2012-06-20 16:38:30 -07006352eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6353 tCsrRoamModifyProfileFields *pMmodProfileFields,
6354 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6355{
6356 eHalStatus status = eHAL_STATUS_SUCCESS;
6357 tSmeCmd *pCommand;
6358
6359 pCommand = csrGetCommandBuffer(pMac);
6360 if(NULL == pCommand)
6361 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006362 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006363 status = eHAL_STATUS_RESOURCES;
6364 }
6365 else
6366 {
6367 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306368 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006369 if(pProfile)
6370 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 //This is likely trying to reassoc to different profile
6372 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6373 //make a copy of the profile
6374 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6375 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006376 }
6377 else
6378 {
6379 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6380 //how to update WPA/WPA2 info in roamProfile??
6381 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006383 if(HAL_STATUS_SUCCESS(status))
6384 {
6385 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6386 }
6387 pCommand->command = eSmeCommandRoam;
6388 pCommand->sessionId = (tANI_U8)sessionId;
6389 pCommand->u.roamCmd.roamId = roamId;
6390 pCommand->u.roamCmd.roamReason = reason;
6391 //We need to free the BssList when the command is done
6392 //For reassoc there is no BSS list, so the boolean set to false
6393 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6394 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6395 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006396 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6397 if( !HAL_STATUS_SUCCESS( status ) )
6398 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006399 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006400 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6401 csrReleaseCommandRoam( pMac, pCommand );
6402 }
6403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 return (status);
6405}
6406
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006407eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6408 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306409// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006410{
6411 eHalStatus status = eHAL_STATUS_SUCCESS;
6412 tSmeCmd *pCommand;
6413
6414 pCommand = csrGetCommandBuffer(pMac);
6415 if(NULL == pCommand)
6416 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006417 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006418 status = eHAL_STATUS_RESOURCES;
6419 }
6420 else
6421 {
6422 if(pBssDescription)
6423 {
6424 //copy over the parameters we need later
6425 pCommand->command = eSmeCommandRoam;
6426 pCommand->sessionId = (tANI_U8)sessionId;
6427 pCommand->u.roamCmd.roamReason = reason;
6428 //this is the important parameter
6429 //in this case we are using this field for the "next" BSS
6430 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6431 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6432 if( !HAL_STATUS_SUCCESS( status ) )
6433 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006434 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006435 csrReleaseCommandPreauth( pMac, pCommand );
6436 }
6437 }
6438 else
6439 {
6440 //Return failure
6441 status = eHAL_STATUS_RESOURCES;
6442 }
6443 }
6444 return (status);
6445}
6446
6447eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6448{
6449 tListElem *pEntry;
6450 tSmeCmd *pCommand;
6451 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6452 if ( pEntry )
6453 {
6454 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6455 if ( (eSmeCommandRoam == pCommand->command) &&
6456 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6457 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006458 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006459 pCommand->command, pCommand->u.roamCmd.roamReason);
6460 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6461 csrReleaseCommandPreauth( pMac, pCommand );
6462 }
6463 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006464 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006465 pCommand->command, pCommand->u.roamCmd.roamReason);
6466 }
6467 }
6468 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006469 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006470 }
6471 smeProcessPendingQueue( pMac );
6472 return eHAL_STATUS_SUCCESS;
6473}
6474
Jeff Johnson295189b2012-06-20 16:38:30 -07006475eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6476 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6477{
6478 eHalStatus status = eHAL_STATUS_FAILURE;
6479 tScanResultHandle hBSSList;
6480 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006481 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6482 if(HAL_STATUS_SUCCESS(status))
6483 {
6484 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6485 if(pRoamId)
6486 {
6487 *pRoamId = roamId;
6488 }
6489 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6490 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6491 if(!HAL_STATUS_SUCCESS(status))
6492 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006493 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006494 csrScanResultPurge(pMac, hBSSList);
6495 }
6496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006497 return (status);
6498}
6499
Jeff Johnson295189b2012-06-20 16:38:30 -07006500eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6501 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6502{
6503 eHalStatus status = eHAL_STATUS_SUCCESS;
6504 tScanResultHandle hBSSList;
6505 tCsrScanResultFilter *pScanFilter;
6506 tANI_U32 roamId = 0;
6507 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6508 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006509 if (NULL == pProfile)
6510 {
6511 smsLog(pMac, LOGP, FL("No profile specified"));
6512 return eHAL_STATUS_FAILURE;
6513 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006514 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006515 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006516 if( CSR_IS_WDS( pProfile ) &&
6517 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6518 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006519 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006520 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006521 return status;
6522 }
6523 csrRoamCancelRoaming(pMac, sessionId);
6524 csrScanRemoveFreshScanCommand(pMac, sessionId);
6525 csrScanCancelIdleScan(pMac);
6526 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306527 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006528 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6529 {
6530 csrScanDisable(pMac);
6531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006532 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6533 //Check whether ssid changes
6534 if(csrIsConnStateConnected(pMac, sessionId))
6535 {
6536 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6537 {
6538 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6539 }
6540 }
6541#ifdef FEATURE_WLAN_BTAMP_UT_RF
6542 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6543#endif
6544 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6545 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006546 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006547 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6548 if(pRoamId)
6549 {
6550 roamId = *pRoamId;
6551 }
6552 if(!HAL_STATUS_SUCCESS(status))
6553 {
6554 fCallCallback = eANI_BOOLEAN_TRUE;
6555 }
6556 }
6557 else
6558 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306559 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6560 if ( NULL == pScanFilter )
6561 status = eHAL_STATUS_FAILURE;
6562 else
6563 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006564 if(HAL_STATUS_SUCCESS(status))
6565 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306566 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006567 //Try to connect to any BSS
6568 if(NULL == pProfile)
6569 {
6570 //No encryption
6571 pScanFilter->EncryptionType.numEntries = 1;
6572 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6573 }//we don't have a profile
6574 else
6575 {
6576 //Here is the profile we need to connect to
6577 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6578 }//We have a profile
6579 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6580 if(pRoamId)
6581 {
6582 *pRoamId = roamId;
6583 }
6584
6585 if(HAL_STATUS_SUCCESS(status))
6586 {
6587 /*Save the WPS info*/
6588 if(NULL != pProfile)
6589 {
6590 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006591 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006592 }
6593 else
6594 {
6595 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006596 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006597 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006598 do
6599 {
6600 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006601 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006602 )
6603 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006604 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6606 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6607 if(!HAL_STATUS_SUCCESS(status))
6608 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006609 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006610 fCallCallback = eANI_BOOLEAN_TRUE;
6611 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006612 else
6613 {
6614 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006616 break;
6617 }
6618 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006619 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 if(HAL_STATUS_SUCCESS(status))
6621 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006622 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6623 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6624 if(!HAL_STATUS_SUCCESS(status))
6625 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006626 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006627 csrScanResultPurge(pMac, hBSSList);
6628 fCallCallback = eANI_BOOLEAN_TRUE;
6629 }
6630 }//Have scan result
6631 else if(NULL != pProfile)
6632 {
6633 //Check whether it is for start ibss
6634 if(CSR_IS_START_IBSS(pProfile))
6635 {
6636 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6637 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6638 if(!HAL_STATUS_SUCCESS(status))
6639 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006640 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 fCallCallback = eANI_BOOLEAN_TRUE;
6642 }
6643 }
6644 else
6645 {
6646 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006647 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006648 if(!HAL_STATUS_SUCCESS(status))
6649 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006650 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006651 fCallCallback = eANI_BOOLEAN_TRUE;
6652 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006653 else
6654 {
6655 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006657 }
6658 }
6659 else
6660 {
6661 fCallCallback = eANI_BOOLEAN_TRUE;
6662 }
6663 } while (0);
6664 if(NULL != pProfile)
6665 {
6666 //we need to free memory for filter if profile exists
6667 csrFreeScanFilter(pMac, pScanFilter);
6668 }
6669 }//Got the scan filter from profile
6670
Kiet Lam64c1b492013-07-12 13:56:44 +05306671 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006672 }//allocated memory for pScanFilter
6673 }//No Bsslist coming in
6674 //tell the caller if we fail to trigger a join request
6675 if( fCallCallback )
6676 {
6677 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6678 }
6679
6680 return (status);
6681}
Jeff Johnson295189b2012-06-20 16:38:30 -07006682eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6683 tCsrRoamModifyProfileFields modProfileFields,
6684 tANI_U32 *pRoamId)
6685{
6686 eHalStatus status = eHAL_STATUS_SUCCESS;
6687 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6688 tANI_U32 roamId = 0;
6689 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 if (NULL == pProfile)
6691 {
6692 smsLog(pMac, LOGP, FL("No profile specified"));
6693 return eHAL_STATUS_FAILURE;
6694 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006695 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"), pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006696 csrRoamCancelRoaming(pMac, sessionId);
6697 csrScanRemoveFreshScanCommand(pMac, sessionId);
6698 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306699 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006700 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006701 if(csrIsConnStateConnected(pMac, sessionId))
6702 {
6703 if(pProfile)
6704 {
6705 if(pProfile->SSIDs.numOfSSIDs &&
6706 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6707 {
6708 fCallCallback = eANI_BOOLEAN_FALSE;
6709 }
6710 else
6711 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006712 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006713 }
6714 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306715 else if (!vos_mem_compare(&modProfileFields,
6716 &pSession->connectedProfile.modifyProfileFields,
6717 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 {
6719 fCallCallback = eANI_BOOLEAN_FALSE;
6720 }
6721 else
6722 {
6723 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006724 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006725 }
6726 }
6727 else
6728 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006729 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006731 if(!fCallCallback)
6732 {
6733 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6734 if(pRoamId)
6735 {
6736 *pRoamId = roamId;
6737 }
6738
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6740 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 }
6742 else
6743 {
6744 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6745 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6746 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006747 return status;
6748}
Jeff Johnson295189b2012-06-20 16:38:30 -07006749eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6750{
6751 eHalStatus status = eHAL_STATUS_FAILURE;
6752 tScanResultHandle hBSSList = NULL;
6753 tCsrScanResultFilter *pScanFilter = NULL;
6754 tANI_U32 roamId;
6755 tCsrRoamProfile *pProfile = NULL;
6756 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006757
6758 if(!pSession)
6759 {
6760 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6761 return eHAL_STATUS_FAILURE;
6762 }
6763
Jeff Johnson295189b2012-06-20 16:38:30 -07006764 do
6765 {
6766 if(pSession->pCurRoamProfile)
6767 {
6768 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306769 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006770 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306771 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6772 if ( NULL == pProfile )
6773 status = eHAL_STATUS_FAILURE;
6774 else
6775 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006776 if(!HAL_STATUS_SUCCESS(status))
6777 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306778 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306780 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006781 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306782 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6783 if ( NULL == pScanFilter )
6784 status = eHAL_STATUS_FAILURE;
6785 else
6786 status = eHAL_STATUS_SUCCESS;
6787
Jeff Johnson295189b2012-06-20 16:38:30 -07006788 if(!HAL_STATUS_SUCCESS(status))
6789 {
6790 break;
6791 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306792 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006793 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6794 if(!HAL_STATUS_SUCCESS(status))
6795 {
6796 break;
6797 }
6798 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6799 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6800 if(HAL_STATUS_SUCCESS(status))
6801 {
6802 //we want to put the last connected BSS to the very beginning, if possible
6803 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6804 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6805 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6806 if(!HAL_STATUS_SUCCESS(status))
6807 {
6808 csrScanResultPurge(pMac, hBSSList);
6809 break;
6810 }
6811 }
6812 else
6813 {
6814 //Do a scan on this profile
6815 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006816 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006817 if(!HAL_STATUS_SUCCESS(status))
6818 {
6819 break;
6820 }
6821 }
6822 }//We have a profile
6823 else
6824 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006825 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006826 break;
6827 }
6828 }while(0);
6829 if(pScanFilter)
6830 {
6831 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306832 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006833 }
6834 if(NULL != pProfile)
6835 {
6836 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306837 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006838 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006839 return (status);
6840}
Jeff Johnson295189b2012-06-20 16:38:30 -07006841eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6842{
6843 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006844 if(csrIsConnStateConnected(pMac, sessionId))
6845 {
6846 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6847 if(HAL_STATUS_SUCCESS(status))
6848 {
6849 status = csrRoamJoinLastProfile(pMac, sessionId);
6850 }
6851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006852 return (status);
6853}
6854
Jeff Johnson295189b2012-06-20 16:38:30 -07006855eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6856{
6857 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006858 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006859 csrRoamCancelRoaming(pMac, sessionId);
6860 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6861 if(csrIsConnStateDisconnected(pMac, sessionId))
6862 {
6863 status = csrRoamJoinLastProfile(pMac, sessionId);
6864 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006865 return (status);
6866}
6867
Jeff Johnson295189b2012-06-20 16:38:30 -07006868eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6869{
6870 eHalStatus status = eHAL_STATUS_SUCCESS;
6871 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6872 eCsrRoamSubState NewSubstate;
6873 tANI_U32 sessionId = pCommand->sessionId;
6874
6875 // change state to 'Roaming'...
6876 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6877
6878 if ( csrIsConnStateIbss( pMac, sessionId ) )
6879 {
6880 // If we are in an IBSS, then stop the IBSS...
6881 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6882 fComplete = (!HAL_STATUS_SUCCESS(status));
6883 }
6884 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6885 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006886 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 -07006887 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6888 //Restore AC weight in case we change it
6889 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6890 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6891 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6892 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6893 {
6894 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6895 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05306896 else
6897 {
6898 // If we are in neighbor preauth done state then on receiving
6899 // disassoc or deauth we dont roam instead we just disassoc
6900 // from current ap and then go to disconnected state
6901 // This happens for ESE and 11r FT connections ONLY.
6902#ifdef WLAN_FEATURE_VOWIFI_11R
6903 if (csrRoamIs11rAssoc(pMac) &&
6904 (csrNeighborRoamStatePreauthDone(pMac)))
6905 {
6906 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6907 }
6908#endif
6909#ifdef FEATURE_WLAN_ESE
6910 if (csrRoamIsESEAssoc(pMac) &&
6911 (csrNeighborRoamStatePreauthDone(pMac)))
6912 {
6913 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6914 }
6915#endif
6916#ifdef FEATURE_WLAN_LFR
6917 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
6918 (csrNeighborRoamStatePreauthDone(pMac)))
6919 {
6920 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6921 }
6922#endif
6923 }
6924
Jeff Johnson295189b2012-06-20 16:38:30 -07006925 if( fDisassoc )
6926 {
6927 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6928 }
6929 else
6930 {
6931 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6932 }
6933 fComplete = (!HAL_STATUS_SUCCESS(status));
6934 }
6935 else if ( csrIsConnStateWds( pMac, sessionId ) )
6936 {
6937 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6938 {
6939 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6940 fComplete = (!HAL_STATUS_SUCCESS(status));
6941 }
6942 //This has to be WDS station
6943 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6944 {
6945
6946 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6947 if( fDisassoc )
6948 {
6949 status = csrRoamIssueDisassociate( pMac, sessionId,
6950 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6951 fComplete = (!HAL_STATUS_SUCCESS(status));
6952 }
6953 }
6954 } else {
6955 // we got a dis-assoc request while not connected to any peer
6956 // just complete the command
6957 fComplete = eANI_BOOLEAN_TRUE;
6958 status = eHAL_STATUS_FAILURE;
6959 }
6960 if(fComplete)
6961 {
6962 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6963 }
6964
6965 if(HAL_STATUS_SUCCESS(status))
6966 {
6967 if ( csrIsConnStateInfra( pMac, sessionId ) )
6968 {
6969 //Set the state to disconnect here
6970 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6971 }
6972 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006973 else
6974 {
6975 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6976 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006977 return (status);
6978}
6979
Jeff Johnson295189b2012-06-20 16:38:30 -07006980/* This is been removed from latest code base */
6981/*
6982static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6983{
6984 eHalStatus status;
6985 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006986 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6987 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006988 return ( status );
6989}
6990*/
6991
Jeff Johnson295189b2012-06-20 16:38:30 -07006992eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6993{
6994 eHalStatus status = eHAL_STATUS_SUCCESS;
6995 tSmeCmd *pCommand;
6996 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006997 do
6998 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006999 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007000 pCommand = csrGetCommandBuffer( pMac );
7001 if ( !pCommand )
7002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007003 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007004 status = eHAL_STATUS_RESOURCES;
7005 break;
7006 }
7007 //Change the substate in case it is wait-for-key
7008 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7009 {
7010 csrRoamStopWaitForKeyTimer( pMac );
7011 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7012 }
7013 pCommand->command = eSmeCommandRoam;
7014 pCommand->sessionId = (tANI_U8)sessionId;
7015 switch ( reason )
7016 {
7017 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7018 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7019 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007020 case eCSR_DISCONNECT_REASON_DEAUTH:
7021 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7022 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007023 case eCSR_DISCONNECT_REASON_HANDOFF:
7024 fHighPriority = eANI_BOOLEAN_TRUE;
7025 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7026 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007027 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7028 case eCSR_DISCONNECT_REASON_DISASSOC:
7029 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7030 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007031 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7032 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7033 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007034 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7035 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7036 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007037 default:
7038 break;
7039 }
7040 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7041 if( !HAL_STATUS_SUCCESS( status ) )
7042 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007043 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007044 csrReleaseCommandRoam( pMac, pCommand );
7045 }
7046 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007047 return( status );
7048}
7049
Jeff Johnson295189b2012-06-20 16:38:30 -07007050eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7051{
7052 eHalStatus status = eHAL_STATUS_SUCCESS;
7053 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007054 pCommand = csrGetCommandBuffer( pMac );
7055 if ( NULL != pCommand )
7056 {
7057 //Change the substate in case it is wait-for-key
7058 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7059 {
7060 csrRoamStopWaitForKeyTimer( pMac );
7061 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7062 }
7063 pCommand->command = eSmeCommandRoam;
7064 pCommand->sessionId = (tANI_U8)sessionId;
7065 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7066 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7067 if( !HAL_STATUS_SUCCESS( status ) )
7068 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007069 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007070 csrReleaseCommandRoam( pMac, pCommand );
7071 }
7072 }
7073 else
7074 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007075 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007076 status = eHAL_STATUS_RESOURCES;
7077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007078 return ( status );
7079}
7080
Jeff Johnson295189b2012-06-20 16:38:30 -07007081eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7082{
7083 eHalStatus status = eHAL_STATUS_SUCCESS;
7084 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007085
7086 if(!pSession)
7087 {
7088 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7089 return eHAL_STATUS_FAILURE;
7090 }
7091
Jeff Johnson295189b2012-06-20 16:38:30 -07007092#ifdef FEATURE_WLAN_BTAMP_UT_RF
7093 //Stop te retry
7094 pSession->maxRetryCount = 0;
7095 csrRoamStopJoinRetryTimer(pMac, sessionId);
7096#endif
7097 //Not to call cancel roaming here
7098 //Only issue disconnect when necessary
7099 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7100 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7101 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7102
7103 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007104 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007105 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7106 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307107 else
7108 {
7109 smsLog( pMac, LOGE, FL("Roam command is not present"));
7110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007111 return (status);
7112}
7113
Jeff Johnson295189b2012-06-20 16:38:30 -07007114eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7115{
7116 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007117
7118 if(!pSession)
7119 {
7120 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7121 return eHAL_STATUS_FAILURE;
7122 }
7123
Jeff Johnson295189b2012-06-20 16:38:30 -07007124 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007125 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7126
7127 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7128}
7129
Jeff Johnson295189b2012-06-20 16:38:30 -07007130eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7131 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7132{
7133 eHalStatus status = eHAL_STATUS_SUCCESS;
7134 tDot11fBeaconIEs *pIesTemp = pIes;
7135 tANI_U8 index;
7136 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7137 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007138
7139 if(!pSession)
7140 {
7141 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7142 return eHAL_STATUS_FAILURE;
7143 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007144 if(pConnectProfile->pAddIEAssoc)
7145 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307146 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007147 pConnectProfile->pAddIEAssoc = NULL;
7148 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307149 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007150 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7151 pConnectProfile->AuthInfo = pProfile->AuthType;
7152 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7153 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7154 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7155 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7156 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7157 pConnectProfile->BSSType = pProfile->BSSType;
7158 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7159 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007160 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307161 if (!pConnectProfile->beaconInterval)
7162 {
7163 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7164 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307165 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007166 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7167 if(pProfile->nAddIEAssocLength)
7168 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307169 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7170 if ( NULL == pConnectProfile->pAddIEAssoc )
7171 status = eHAL_STATUS_FAILURE;
7172 else
7173 status = eHAL_STATUS_SUCCESS;
7174 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007175 {
7176 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7177 return eHAL_STATUS_FAILURE;
7178 }
7179 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307180 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7181 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007182 }
7183
Jeff Johnson295189b2012-06-20 16:38:30 -07007184 //Save bssid
7185 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7186#ifdef WLAN_FEATURE_VOWIFI_11R
7187 if (pSirBssDesc->mdiePresent)
7188 {
7189 pConnectProfile->MDID.mdiePresent = 1;
7190 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7191 }
7192#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007193 if( NULL == pIesTemp )
7194 {
7195 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7196 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007197#ifdef FEATURE_WLAN_ESE
7198 if ((csrIsProfileESE(pProfile) ||
7199 ((pIesTemp->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +05307200 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007201 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007202 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007203 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007204 }
7205#endif
7206 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007207 if(HAL_STATUS_SUCCESS(status))
7208 {
7209 if(pIesTemp->SSID.present)
7210 {
7211 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307212 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7213 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007214 }
7215
7216 //Save the bss desc
7217 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307218
7219 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007220 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307221 //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 -07007222 pConnectProfile->qap = TRUE;
7223 }
7224 else
7225 {
7226 pConnectProfile->qap = FALSE;
7227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007228 if ( NULL == pIes )
7229 {
7230 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307231 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007232 }
7233 }
7234 //Save Qos connection
7235 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7236
7237 if(!HAL_STATUS_SUCCESS(status))
7238 {
7239 csrFreeConnectBssDesc(pMac, sessionId);
7240 }
7241 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7242 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307243 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7244 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7245 pConnectProfile->SSID.ssId,
7246 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007247 {
7248 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7249 break;
7250 }
7251 pConnectProfile->handoffPermitted = FALSE;
7252 }
7253
7254 return (status);
7255}
7256
Jeff Johnson295189b2012-06-20 16:38:30 -07007257static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7258{
7259 tListElem *pEntry = NULL;
7260 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007261 //The head of the active list is the request we sent
7262 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7263 if(pEntry)
7264 {
7265 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7266 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007267 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7268 {
7269 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7270 {
7271#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7272 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7273#endif
7274 }
7275 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7276 }
7277 else
7278 {
7279 tANI_U32 roamId = 0;
7280 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007281 if(!pSession)
7282 {
7283 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7284 return;
7285 }
7286
Jeff Johnson295189b2012-06-20 16:38:30 -07007287
7288 //The head of the active list is the request we sent
7289 //Try to get back the same profile and roam again
7290 if(pCommand)
7291 {
7292 roamId = pCommand->u.roamCmd.roamId;
7293 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007294 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7295 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007296 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007297#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7298 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7299 if (csrRoamIsHandoffInProgress(pMac))
7300 {
7301 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7302 /* Should indicate neighbor roam algorithm about the connect failure here */
7303 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7304 }
7305#endif
7306 if (pCommand)
7307 {
7308 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7309 {
7310 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7311 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7312 csrRoamReissueRoamCommand(pMac);
7313 }
7314 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7315 {
7316 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7317 }
7318 else
7319 {
7320 csrRoam(pMac, pCommand);
7321 }
7322 }
7323 else
7324 {
7325 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7326 }
7327 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7328}
7329
Jeff Johnson295189b2012-06-20 16:38:30 -07007330eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7331 tDot11fBeaconIEs *pIes,
7332 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7333{
7334 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007335 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7336 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007337
7338 // Set the roaming substate to 'join attempt'...
7339 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007340 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007341 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007342 return (status);
7343}
7344
Jeff Johnson295189b2012-06-20 16:38:30 -07007345static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7346 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7347{
7348 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007349 // Set the roaming substate to 'join attempt'...
7350 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7351
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307352 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7353 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007354
7355 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007356 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007357}
7358
Jeff Johnson295189b2012-06-20 16:38:30 -07007359void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7360{
7361 tListElem *pEntry;
7362 tSmeCmd *pCommand;
7363 tCsrRoamInfo roamInfo;
7364 tANI_U32 sessionId;
7365 tCsrRoamSession *pSession;
7366
7367 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7368 if(pEntry)
7369 {
7370 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7371 if ( eSmeCommandRoam == pCommand->command )
7372 {
7373 sessionId = pCommand->sessionId;
7374 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007375
7376 if(!pSession)
7377 {
7378 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7379 return;
7380 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307381 /* While switching between two AP, csr will reissue roam command again
7382 to the nextbss if it was interrupted by the dissconnect req for the
7383 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7384 so reset the bRefAssocStartCnt.
7385 */
7386 if(pSession->bRefAssocStartCnt > 0)
7387 {
7388 pSession->bRefAssocStartCnt--;
7389 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007390 if( pCommand->u.roamCmd.fStopWds )
7391 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307392 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007393 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7394 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7395 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007396 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007397 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7398 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7399 eCSR_ROAM_WDS_IND,
7400 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007401 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7402 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7403 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7404 eCSR_ROAM_INFRA_IND,
7405 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7406 }
7407
Jeff Johnson295189b2012-06-20 16:38:30 -07007408
Jeff Johnson295189b2012-06-20 16:38:30 -07007409 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7410 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007411 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007412 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7413 }
7414 }
7415 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7416 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007417 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007418 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7419 }
7420 }
7421 else
7422 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007423 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007424 }
7425 }
7426 else
7427 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007428 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007429 }
7430}
7431
Jeff Johnson295189b2012-06-20 16:38:30 -07007432tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7433{
7434 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7435 tListElem *pEntry;
7436 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007437 //alwasy lock active list before locking pending list
7438 csrLLLock( &pMac->sme.smeCmdActiveList );
7439 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7440 if(pEntry)
7441 {
7442 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7443 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7444 {
7445 fRet = eANI_BOOLEAN_TRUE;
7446 }
7447 }
7448 if(eANI_BOOLEAN_FALSE == fRet)
7449 {
7450 csrLLLock(&pMac->sme.smeCmdPendingList);
7451 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7452 while(pEntry)
7453 {
7454 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7455 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7456 {
7457 fRet = eANI_BOOLEAN_TRUE;
7458 break;
7459 }
7460 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7461 }
7462 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7463 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307464 if (eANI_BOOLEAN_FALSE == fRet)
7465 {
7466 csrLLLock(&pMac->roam.roamCmdPendingList);
7467 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7468 while (pEntry)
7469 {
7470 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7471 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7472 {
7473 fRet = eANI_BOOLEAN_TRUE;
7474 break;
7475 }
7476 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7477 }
7478 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007480 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007481 return (fRet);
7482}
7483
Jeff Johnson295189b2012-06-20 16:38:30 -07007484tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7485{
7486 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7487 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007488 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7489 {
7490 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7491 {
7492 break;
7493 }
7494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007495 return ( fRet );
7496}
7497
Jeff Johnson295189b2012-06-20 16:38:30 -07007498tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7499{
7500 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 //alwasy lock active list before locking pending list
7502 csrLLLock( &pMac->sme.smeCmdActiveList );
7503 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7504 if(eANI_BOOLEAN_FALSE == fRet)
7505 {
7506 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7507 }
7508 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007509 return (fRet);
7510}
7511
Jeff Johnson295189b2012-06-20 16:38:30 -07007512tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7513{
7514 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7515 tListElem *pEntry;
7516 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007517 //alwasy lock active list before locking pending list
7518 csrLLLock( &pMac->sme.smeCmdActiveList );
7519 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7520 if( pEntry )
7521 {
7522 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7523 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7524 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7525 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7526 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7527 {
7528 fRet = eANI_BOOLEAN_TRUE;
7529 }
7530 }
7531 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007532 return (fRet);
7533}
Jeff Johnson295189b2012-06-20 16:38:30 -07007534eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7535{
7536 eHalStatus status = eHAL_STATUS_SUCCESS;
7537 tSmeCmd *pCommand = NULL;
7538 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7539 tANI_BOOLEAN fRemoveCmd = FALSE;
7540 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007541 // Delete the old assoc command. All is setup for reassoc to be serialized
7542 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7543 if ( pEntry )
7544 {
7545 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7546 if ( !pCommand )
7547 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007548 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007549 return eHAL_STATUS_RESOURCES;
7550 }
7551 if ( eSmeCommandRoam == pCommand->command )
7552 {
7553 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7554 {
7555 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7556 }
7557 else
7558 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007559 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007560 }
7561 if (fRemoveCmd == FALSE)
7562 {
7563 // Implies we did not get the serialized assoc command we
7564 // were expecting
7565 pCommand = NULL;
7566 }
7567 }
7568 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007569 if(NULL == pCommand)
7570 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007571 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007572 return eHAL_STATUS_RESOURCES;
7573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007574 do
7575 {
7576 //Change the substate in case it is wait-for-key
7577 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7578 {
7579 csrRoamStopWaitForKeyTimer( pMac );
7580 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7581 }
7582 pCommand->command = eSmeCommandRoam;
7583 pCommand->sessionId = (tANI_U8)sessionId;
7584 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007585 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7586 if( !HAL_STATUS_SUCCESS( status ) )
7587 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007588 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007589 csrReleaseCommandRoam( pMac, pCommand );
7590 }
7591 } while( 0 );
7592
Jeff Johnson295189b2012-06-20 16:38:30 -07007593 return( status );
7594}
7595static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7596{
7597 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7598 tCsrScanResult *pScanResult = NULL;
7599 tSirBssDescription *pBssDesc = NULL;
7600 tSmeCmd *pCommand = NULL;
7601 tANI_U32 sessionId;
7602 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007603 if(NULL == pEntry)
7604 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307605 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007606 return;
7607 }
7608 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7609 sessionId = pCommand->sessionId;
7610 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007611
7612 if(!pSession)
7613 {
7614 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7615 return;
7616 }
7617
Jeff Johnson295189b2012-06-20 16:38:30 -07007618 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7619 {
7620 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007621 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007622 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7623 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007624 /* If the roaming has stopped, not to continue the roaming command*/
7625 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7626 {
7627 //No need to complete roaming here as it already completes
7628 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7629 pCommand->u.roamCmd.roamReason);
7630 csrSetAbortRoamingCommand( pMac, pCommand );
7631 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007633 else
7634 {
7635 if ( CCM_IS_RESULT_SUCCESS(result) )
7636 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007637 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007638 // Successfully set the configuration parameters for the new Bss. Attempt to
7639 // join the roaming Bss.
7640 if(pCommand->u.roamCmd.pRoamBssEntry)
7641 {
7642 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7643 pBssDesc = &pScanResult->Result.BssDescriptor;
7644 }
7645 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7646 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007648 )
7649 {
7650 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7651 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7652 pBssDesc, pCommand->u.roamCmd.roamId )))
7653 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307654 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007655 //We need to complete the command
7656 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7657 }
7658 }
7659 else
7660 {
7661 if (!pCommand->u.roamCmd.pRoamBssEntry)
7662 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307663 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007664 //We need to complete the command
7665 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7666 return;
7667 }
7668 // If we are roaming TO an Infrastructure BSS...
7669 VOS_ASSERT(pScanResult != NULL);
7670 if ( csrIsInfraBssDesc( pBssDesc ) )
7671 {
7672 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007673 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7674 {
7675 // ..and currently in an Infrastructure connection....
7676 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7677 {
7678 // ...and the SSIDs are equal, then we Reassoc.
7679 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7680 pIesLocal ) )
7681 // ..and currently in an infrastructure connection
7682 {
7683 // then issue a Reassoc.
7684 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7685 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7686 &pCommand->u.roamCmd.roamProfile );
7687 }
7688 else
7689 {
7690
7691 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7692 // previously associated AP.
7693 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7694 pIesLocal,
7695 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7696 {
7697 //try something else
7698 csrRoam( pMac, pCommand );
7699 }
7700 }
7701 }
7702 else
7703 {
7704 eHalStatus status = eHAL_STATUS_SUCCESS;
7705
7706 /* We need to come with other way to figure out that this is because of HO in BMP
7707 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007708 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 * use join request */
7710#ifdef WLAN_FEATURE_VOWIFI_11R
7711 if (csrRoamIsHandoffInProgress(pMac) &&
7712 csrRoamIs11rAssoc(pMac))
7713 {
7714 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7715 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7716 }
7717 else
7718#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007719#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007720 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007721 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07007722 {
7723 // Now serialize the reassoc command.
7724 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7725 }
7726 else
7727#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007728#ifdef FEATURE_WLAN_LFR
7729 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307730 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007731 {
7732 // Now serialize the reassoc command.
7733 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7734 }
7735 else
7736#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007737 // else we are not connected and attempting to Join. Issue the
7738 // Join request.
7739 {
7740 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7741 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7742 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7743 }
7744 if(!HAL_STATUS_SUCCESS(status))
7745 {
7746 //try something else
7747 csrRoam( pMac, pCommand );
7748 }
7749 }
7750 if( !pScanResult->Result.pvIes )
7751 {
7752 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307753 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007754 }
7755 }
7756 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7757 else
7758 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007759 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007760 }
7761 }//else
7762 }//if ( WNI_CFG_SUCCESS == result )
7763 else
7764 {
7765 // In the event the configuration failed, for infra let the roam processor
7766 //attempt to join something else...
7767 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7768 {
7769 csrRoam(pMac, pCommand);
7770 }
7771 else
7772 {
7773 //We need to complete the command
7774 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7775 {
7776 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7777 }
7778 else
7779 {
7780 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7781 }
7782 }
7783 }
7784 }//we have active entry
7785}
7786
Jeff Johnson295189b2012-06-20 16:38:30 -07007787static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7788{
7789 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007790 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007791 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7792 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007793 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007794 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7795 // join the new one...
7796 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007797 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7798 }
7799 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007800 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007801 /***profHandleLostLinkAfterReset(pAdapter);
7802 // In the event the authenticate fails, let the roam processor attempt to join something else...
7803 roamRoam( pAdapter );***/
7804 }
7805}
7806
Jeff Johnson295189b2012-06-20 16:38:30 -07007807static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7808{
7809 eCsrRoamCompleteResult result;
7810 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7811 tCsrRoamInfo roamInfo;
7812 tANI_U32 roamId = 0;
7813
7814 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7815 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007816 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007817 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007818 /* Defeaturize this part later if needed */
7819#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7820 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7821 * we need the response contents while processing the result in csrRoamProcessResults() */
7822 if (csrRoamIsHandoffInProgress(pMac))
7823 {
7824 /* Need to dig more on indicating events to SME QoS module */
7825 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7826 csrRoamComplete( pMac, result, pSmeJoinRsp);
7827 }
7828 else
7829#endif
7830 {
7831 csrRoamComplete( pMac, result, NULL );
7832 }
7833 }
7834 /* Should we handle this similar to handling the join failure? Is it ok
7835 * to call csrRoamComplete() with state as CsrJoinFailure */
7836 else
7837 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007838 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007839 result = eCsrReassocFailure;
7840#ifdef WLAN_FEATURE_VOWIFI_11R
7841 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7842 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7843 {
7844 // Inform HDD to turn off FT flag in HDD
7845 if (pNeighborRoamInfo)
7846 {
7847 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7848 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7849 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007850 /*
7851 * Since the above callback sends a disconnect
7852 * to HDD, we should clean-up our state
7853 * machine as well to be in sync with the upper
7854 * layers. There is no need to send a disassoc
7855 * since: 1) we will never reassoc to the current
7856 * AP in LFR, and 2) there is no need to issue a
7857 * disassoc to the AP with which we were trying
7858 * to reassoc.
7859 */
7860 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7861 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007862 }
7863 }
7864#endif
7865 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7866 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7867 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7868 //The disassoc rsp message will remove the command from active list
7869 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7870 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7871 {
7872 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7873 }
7874 }
7875}
7876
Jeff Johnson295189b2012-06-20 16:38:30 -07007877static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7878{
Jeff Johnson295189b2012-06-20 16:38:30 -07007879#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7880 {
7881 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007882 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7883 if(pIbssLog)
7884 {
7885 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7886 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7887 {
7888 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7889 }
7890 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7891 }
7892 }
7893#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007894 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7895 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7896 {
7897 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7898 }
7899 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7900 {
7901 csrRoamReissueRoamCommand(pMac);
7902 }
7903}
7904
Jeff Johnson295189b2012-06-20 16:38:30 -07007905void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7906{
7907 tSirResultCodes statusCode;
7908#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7909 tScanResultHandle hBSSList;
7910 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7911 eHalStatus status;
7912 tCsrRoamInfo roamInfo;
7913 tCsrScanResultFilter *pScanFilter = NULL;
7914 tANI_U32 roamId = 0;
7915 tCsrRoamProfile *pCurRoamProfile = NULL;
7916 tListElem *pEntry = NULL;
7917 tSmeCmd *pCommand = NULL;
7918#endif
7919 tANI_U32 sessionId;
7920 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007921
Jeff Johnson295189b2012-06-20 16:38:30 -07007922 tSirSmeDisassocRsp SmeDisassocRsp;
7923
7924 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7925 sessionId = SmeDisassocRsp.sessionId;
7926 statusCode = SmeDisassocRsp.statusCode;
7927
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007928 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007929
7930 if ( csrIsConnStateInfra( pMac, sessionId ) )
7931 {
7932 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007934 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007935
7936 if(!pSession)
7937 {
7938 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7939 return;
7940 }
7941
Jeff Johnson295189b2012-06-20 16:38:30 -07007942 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7943 {
7944 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7945 }
7946 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7947 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7948 {
7949 if ( eSIR_SME_SUCCESS == statusCode )
7950 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007951 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007952 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7953 }
7954 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7955 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007956 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7957 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307958 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
7959 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007960#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007961 /*
7962 * First ensure if the roam profile is in the scan cache.
7963 * If not, post a reassoc failure and disconnect.
7964 */
Kiet Lam64c1b492013-07-12 13:56:44 +05307965 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7966 if ( NULL == pScanFilter )
7967 status = eHAL_STATUS_FAILURE;
7968 else
7969 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007970 if(HAL_STATUS_SUCCESS(status))
7971 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307972 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007973 status = csrRoamPrepareFilterFromProfile(pMac,
7974 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7975 if(!HAL_STATUS_SUCCESS(status))
7976 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007977 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007978 __func__, status);
7979 goto POST_ROAM_FAILURE;
7980 }
7981 else
7982 {
7983 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7984 if (!HAL_STATUS_SUCCESS(status))
7985 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007986 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007987 __func__, status);
7988 goto POST_ROAM_FAILURE;
7989 }
7990 }
7991 }
7992 else
7993 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007994 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007995 __func__, status);
7996 goto POST_ROAM_FAILURE;
7997 }
7998
7999 /*
8000 * After ensuring that the roam profile is in the scan result list,
8001 * dequeue the command from the active list.
8002 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008003 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8004 if ( pEntry )
8005 {
8006 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008007 /* If the head of the queue is Active and it is a ROAM command, remove
8008 * and put this on the Free queue.
8009 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008010 if ( eSmeCommandRoam == pCommand->command )
8011 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008012
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008013 /*
8014 * we need to process the result first before removing it from active list
8015 * because state changes still happening insides roamQProcessRoamResults so
8016 * no other roam command should be issued.
8017 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008018 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8019 if(pCommand->u.roamCmd.fReleaseProfile)
8020 {
8021 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8022 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8023 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008024 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008025 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008026 else
8027 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008028 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008029 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008030 }
8031 }
8032 else
8033 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008034 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008035 }
8036 }
8037 else
8038 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008039 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008040 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008041
8042 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008043 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8044
Kiet Lam64c1b492013-07-12 13:56:44 +05308045 vos_mem_copy(roamInfo.bssid,
8046 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8047 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008048
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008049 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8050 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008051
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008052 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308053 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8054 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008055 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308056 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008057 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8058 //make sure to put it at the head of the cmd queue
8059 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8060 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8061 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8062
Jeff Johnson295189b2012-06-20 16:38:30 -07008063 if(!HAL_STATUS_SUCCESS(status))
8064 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008065 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008066 __func__, status);
8067 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008068 }
8069
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008070 /* Notify sub-modules like QoS etc. that handoff happening */
8071 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008072 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308073 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008074 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308075 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008076 return;
8077 }
8078
8079POST_ROAM_FAILURE:
8080 if (pScanFilter)
8081 {
8082 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308083 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008084 }
8085 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308086 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008087
8088 /* Inform the upper layers that the reassoc failed */
8089 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8090 csrRoamCallCallback(pMac, sessionId,
8091 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8092
8093 /*
8094 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8095 * Upon success, we would re-enter this routine after receiving the disassoc
8096 * response and will fall into the reassoc fail sub-state. And, eventually
8097 * call csrRoamComplete which would remove the roam command from SME active
8098 * queue.
8099 */
8100 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8101 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8102 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008103 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008104 __func__, status);
8105 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008106 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008107#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008108
Jeff Johnson295189b2012-06-20 16:38:30 -07008109 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8110 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8111 {
8112 // Disassoc due to Reassoc failure falls into this codepath....
8113 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8114 }
8115 else
8116 {
8117 if ( eSIR_SME_SUCCESS == statusCode )
8118 {
8119 // Successfully disassociated from the 'old' Bss...
8120 //
8121 // We get Disassociate response in three conditions.
8122 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8123 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8124 // Infrastructure network.
8125 // - Third is where we are doing an Infra to Infra roam between networks with different
8126 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8127
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008128 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008129 }
8130 else
8131 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008132 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008133 }
8134 //We are not done yet. Get the data and continue roaming
8135 csrRoamReissueRoamCommand(pMac);
8136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008137}
8138
Jeff Johnson295189b2012-06-20 16:38:30 -07008139static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8140{
8141 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008142 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008143 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008144 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008145 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008146 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8147 {
8148 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8149 }
8150 else
8151 {
8152 if ( eSIR_SME_SUCCESS == statusCode )
8153 {
8154 // Successfully deauth from the 'old' Bss...
8155 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008156 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008157 }
8158 else
8159 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008160 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008161 }
8162 //We are not done yet. Get the data and continue roaming
8163 csrRoamReissueRoamCommand(pMac);
8164 }
8165}
8166
Jeff Johnson295189b2012-06-20 16:38:30 -07008167static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8168{
8169 eCsrRoamCompleteResult result;
8170
8171 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8172 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008173 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008174 result = eCsrStartBssSuccess;
8175 }
8176 else
8177 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008178 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008179 //Let csrRoamComplete decide what to do
8180 result = eCsrStartBssFailure;
8181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008182 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008183}
8184
Jeff Johnson295189b2012-06-20 16:38:30 -07008185/*
8186 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8187 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8188 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8189 For the messages where sender allocates memory for specific structures, then it can be
8190 cast accordingly.
8191*/
8192void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8193{
8194 tSirSmeRsp *pSmeRsp;
8195 tSmeIbssPeerInd *pIbssPeerInd;
8196 tCsrRoamInfo roamInfo;
8197 // TODO Session Id need to be acquired in this function
8198 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008199 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308200 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8201 pSmeRsp->messageType, pSmeRsp->messageType,
8202 macTraceGetcsrRoamSubState(
8203 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008204 pSmeRsp->messageType = (pSmeRsp->messageType);
8205 pSmeRsp->length = (pSmeRsp->length);
8206 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008207 switch (pSmeRsp->messageType)
8208 {
8209
8210 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8211 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8212 {
8213 //We sent a JOIN_REQ
8214 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8215 }
8216 break;
8217
8218 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8219 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8220 {
8221 //We sent a AUTH_REQ
8222 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8223 }
8224 break;
8225
8226 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8227 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8228 {
8229 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8230 }
8231 break;
8232
8233 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8234 {
8235 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8236 }
8237 break;
8238
8239 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8240 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8241 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8242 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8243 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8244 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8245//HO
8246 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8247 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308248 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8249 macTraceGetcsrRoamSubState(
8250 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008251 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
8252 }
8253 break;
8254
8255 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8256 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8257 {
8258 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8259 }
8260 break;
8261
8262 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8263 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8264 {
8265 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8266 }
8267 break;
8268
8269 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8270 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8271 {
8272 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008274 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008275 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8276 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8277 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008278 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308279 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8280 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008281 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8282 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308283 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8284 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008285 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8286 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8287 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8288 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008289 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308290 smsLog(pMac, LOG1,
8291 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8292 pSmeRsp->messageType, pSmeRsp->messageType,
8293 macTraceGetcsrRoamSubState(
8294 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008295
8296 //If we are connected, check the link status change
8297 if(!csrIsConnStateDisconnected(pMac, sessionId))
8298 {
8299 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8300 }
8301 break;
8302 }
8303}
8304
Jeff Johnson295189b2012-06-20 16:38:30 -07008305void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8306{
8307 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008308 switch (pSirMsg->messageType)
8309 {
8310 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008311 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008312 csrRoamStatsRspProcessor( pMac, pSirMsg );
8313 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008314 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8315 {
8316 tCsrRoamSession *pSession;
8317 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8318 tCsrRoamInfo roamInfo;
8319 tCsrRoamInfo *pRoamInfo = NULL;
8320 tANI_U32 sessionId;
8321 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008322 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308323 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008324 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008325 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8326 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8327 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008328
8329 if(!pSession)
8330 {
8331 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8332 return;
8333 }
8334
Jeff Johnson295189b2012-06-20 16:38:30 -07008335 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8336 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008337 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8338 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8339 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008340 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8341 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308342 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8343 sizeof(tSirMacAddr));
8344 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8345 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008346 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008347 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8348 {
8349 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8350 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8351 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8352 }
8353 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8354 {
8355 vos_sleep( 100 );
8356 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8357 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8358 }
8359
Jeff Johnson295189b2012-06-20 16:38:30 -07008360 }
8361 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 default:
8363 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8364 break;
8365 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008366}
8367
Jeff Johnson295189b2012-06-20 16:38:30 -07008368eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8369 tSirBssDescription *pBssDescription,
8370 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8371 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8372 tANI_U8 keyId, tANI_U16 keyLength,
8373 tANI_U8 *pKey, tANI_U8 paeRole )
8374{
8375 eHalStatus status = eHAL_STATUS_SUCCESS;
8376 tAniEdType edType;
8377
8378 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8379 {
8380 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8381 }
8382
8383 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8384
8385 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8386 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8387 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8388 addKey )
8389 {
8390 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008391 setKey.encType = EncryptType;
8392 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308393 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008394 setKey.paeRole = paeRole; //0 for supplicant
8395 setKey.keyId = keyId; // Kye index
8396 setKey.keyLength = keyLength;
8397 if( keyLength )
8398 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308399 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008400 }
8401 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008403 return (status);
8404}
8405
Jeff Johnson295189b2012-06-20 16:38:30 -07008406static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8407 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8408{
8409 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8410 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008411#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008412 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008413#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008414
8415 do
8416 {
8417 pCommand = csrGetCommandBuffer(pMac);
8418 if(NULL == pCommand)
8419 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008420 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008421 status = eHAL_STATUS_RESOURCES;
8422 break;
8423 }
8424 pCommand->command = eSmeCommandSetKey;
8425 pCommand->sessionId = (tANI_U8)sessionId;
8426 // validate the key length, Adjust if too long...
8427 // for static WEP the keys are not set thru' SetContextReq
8428 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8429 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8430 {
8431 //KeyLength maybe 0 for static WEP
8432 if( pSetKey->keyLength )
8433 {
8434 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8435 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008436 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008437 break;
8438 }
8439
8440 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308441 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8442 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008443 }
8444 }
8445 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8446 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8447 {
8448 //KeyLength maybe 0 for static WEP
8449 if( pSetKey->keyLength )
8450 {
8451 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8452 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008453 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008454 break;
8455 }
8456
8457 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308458 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8459 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008460 }
8461 }
8462 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8463 {
8464 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8465 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008466 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008467 break;
8468 }
8469 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308470 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8471 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008472 }
8473 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8474 {
8475 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8476 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008477 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008478 break;
8479 }
8480 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308481 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8482 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008483 }
8484#ifdef FEATURE_WLAN_WAPI
8485 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8486 {
8487 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8488 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008489 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008490 break;
8491 }
8492 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308493 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8494 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008495 }
8496#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008497#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008498 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8499 {
8500 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8501 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008502 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008503 break;
8504 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008505 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308506 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008507 pSession->eseCckmInfo.reassoc_req_num=1;
8508 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008509 status = eHAL_STATUS_SUCCESS;
8510 break;
8511 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008512#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008513
Jeff Johnson295189b2012-06-20 16:38:30 -07008514#ifdef WLAN_FEATURE_11W
8515 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008516 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008517 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008518 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008520 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008521 break;
8522 }
8523 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308524 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008525 }
8526#endif
8527 status = eHAL_STATUS_SUCCESS;
8528 pCommand->u.setKeyCmd.roamId = roamId;
8529 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8530 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308531 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8532 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008533 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8534 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308535 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008536 //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
8537
8538 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8539 if( !HAL_STATUS_SUCCESS( status ) )
8540 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008541 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008542 }
8543 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008544 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008545 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008546 if ( ( NULL != pCommand ) &&
8547 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008548#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008549 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008550#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008551 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008552 {
8553 csrReleaseCommandSetKey( pMac, pCommand );
8554 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008555 return( status );
8556}
8557
Jeff Johnson295189b2012-06-20 16:38:30 -07008558eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8559 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8560{
8561 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8562 tSmeCmd *pCommand = NULL;
8563 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008564 do
8565 {
8566 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8567 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008568 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008569 status = eHAL_STATUS_CSR_WRONG_STATE;
8570 break;
8571 }
8572 pCommand = csrGetCommandBuffer(pMac);
8573 if(NULL == pCommand)
8574 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008575 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008576 status = eHAL_STATUS_RESOURCES;
8577 break;
8578 }
8579 pCommand->command = eSmeCommandRemoveKey;
8580 pCommand->sessionId = (tANI_U8)sessionId;
8581 pCommand->u.removeKeyCmd.roamId = roamId;
8582 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308583 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8584 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008585 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8586 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8587 {
8588 //in this case, put it to the end of the Q incase there is a set key pending.
8589 fImediate = eANI_BOOLEAN_FALSE;
8590 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008591 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008592 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008593 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008594 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8595 if( !HAL_STATUS_SUCCESS( status ) )
8596 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008597 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008598 break;
8599 }
8600 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008601 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8602 {
8603 csrReleaseCommandRemoveKey( pMac, pCommand );
8604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008605 return (status );
8606}
8607
Jeff Johnson295189b2012-06-20 16:38:30 -07008608eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8609{
8610 eHalStatus status;
8611 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8612 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8613 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8614 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008615#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8616 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8617 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008618 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008619 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308620 vos_mem_set(&setKeyEvent,
8621 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008622 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8623 {
8624 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8625 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8626 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8627 }
8628 else
8629 {
8630 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8631 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8632 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8633 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308634 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008635 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008636 {
8637 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008638 //It has to be static WEP here
8639 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8640 {
8641 setKeyEvent.keyId = (v_U8_t)defKeyId;
8642 }
8643 }
8644 else
8645 {
8646 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8647 }
8648 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8649 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8650 }
8651#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008652 if( csrIsSetKeyAllowed(pMac, sessionId) )
8653 {
8654 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8655 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8656 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8657 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8658 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8659 pCommand->u.setKeyCmd.keyRsc);
8660 }
8661 else
8662 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008663 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008664 //Set this status so the error handling take care of the case.
8665 status = eHAL_STATUS_CSR_WRONG_STATE;
8666 }
8667 if( !HAL_STATUS_SUCCESS(status) )
8668 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008669 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008670 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008671#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008672 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008673 {
8674 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8675 {
8676 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8677 }
8678 else
8679 {
8680 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8681 }
8682 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8683 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8684 }
8685#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008687 return ( status );
8688}
8689
Jeff Johnson295189b2012-06-20 16:38:30 -07008690eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8691{
8692 eHalStatus status;
8693 tpSirSmeRemoveKeyReq pMsg = NULL;
8694 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8695 tANI_U8 *p;
8696 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008697#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8698 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8699 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05308700 vos_mem_set(&removeKeyEvent,
8701 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008702 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8703 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8704 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308705 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008706 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8707 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8708 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8709#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008710 if( csrIsSetKeyAllowed(pMac, sessionId) )
8711 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308712 pMsg = vos_mem_malloc(wMsgLen);
8713 if ( NULL == pMsg )
8714 status = eHAL_STATUS_FAILURE;
8715 else
8716 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008717 }
8718 else
8719 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008720 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008721 //Set the error status so error handling kicks in below
8722 status = eHAL_STATUS_CSR_WRONG_STATE;
8723 }
8724 if( HAL_STATUS_SUCCESS( status ) )
8725 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308726 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008727 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8728 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008729 pMsg->sessionId = (tANI_U8)sessionId;
8730 pMsg->transactionId = 0;
8731 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8732 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8733 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308734 vos_mem_copy(p,
8735 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8736 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008737 p += sizeof(tSirMacAddr);
8738 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308739 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008740 p += sizeof(tSirMacAddr);
8741 // edType
8742 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8743 p++;
8744 // weptype
8745 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8746 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8747 {
8748 *p = (tANI_U8)eSIR_WEP_STATIC;
8749 }
8750 else
8751 {
8752 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8753 }
8754 p++;
8755 //keyid
8756 *p = pCommand->u.removeKeyCmd.keyId;
8757 p++;
8758 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008759 status = palSendMBMessage(pMac->hHdd, pMsg);
8760 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008761 if( !HAL_STATUS_SUCCESS( status ) )
8762 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008763 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008764#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8765 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008766 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008767 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8768#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008769 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008771 return ( status );
8772}
8773
Jeff Johnson295189b2012-06-20 16:38:30 -07008774eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8775{
8776 eHalStatus status;
8777
8778 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8779 {
8780 status = eHAL_STATUS_CSR_WRONG_STATE;
8781 }
8782 else
8783 {
8784 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8785 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 return ( status );
8787}
8788
Jeff Johnson295189b2012-06-20 16:38:30 -07008789/*
8790 Prepare a filter base on a profile for parsing the scan results.
8791 Upon successful return, caller MUST call csrFreeScanFilter on
8792 pScanFilter when it is done with the filter.
8793*/
8794eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8795 tCsrScanResultFilter *pScanFilter)
8796{
8797 eHalStatus status = eHAL_STATUS_SUCCESS;
8798 tANI_U32 size = 0;
8799 tANI_U8 index = 0;
8800
8801 do
8802 {
8803 if(pProfile->BSSIDs.numOfBSSIDs)
8804 {
8805 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308806 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8807 if ( NULL == pScanFilter->BSSIDs.bssid )
8808 status = eHAL_STATUS_FAILURE;
8809 else
8810 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008811 if(!HAL_STATUS_SUCCESS(status))
8812 {
8813 break;
8814 }
8815 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308816 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008817 }
8818 if(pProfile->SSIDs.numOfSSIDs)
8819 {
8820 if( !CSR_IS_WDS_STA( pProfile ) )
8821 {
8822 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8823 }
8824 else
8825 {
8826 //For WDS station
8827 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8828 pScanFilter->SSIDs.numOfSSIDs = 1;
8829 }
8830 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308831 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8832 if ( NULL == pScanFilter->SSIDs.SSIDList )
8833 status = eHAL_STATUS_FAILURE;
8834 else
8835 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008836 if(!HAL_STATUS_SUCCESS(status))
8837 {
8838 break;
8839 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308840 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8841 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008842 }
8843 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8844 {
8845 pScanFilter->ChannelInfo.numOfChannels = 0;
8846 pScanFilter->ChannelInfo.ChannelList = NULL;
8847 }
8848 else if(pProfile->ChannelInfo.numOfChannels)
8849 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308850 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8851 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8852 pProfile->ChannelInfo.numOfChannels);
8853 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8854 status = eHAL_STATUS_FAILURE;
8855 else
8856 status = eHAL_STATUS_SUCCESS;
8857
Jeff Johnson295189b2012-06-20 16:38:30 -07008858 pScanFilter->ChannelInfo.numOfChannels = 0;
8859 if(HAL_STATUS_SUCCESS(status))
8860 {
8861 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8862 {
8863 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8864 {
8865 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8866 = pProfile->ChannelInfo.ChannelList[index];
8867 pScanFilter->ChannelInfo.numOfChannels++;
8868 }
8869 else
8870 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008871 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008872 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008873 }
8874 }
8875 else
8876 {
8877 break;
8878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 }
8880 else
8881 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308882 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008883 status = eHAL_STATUS_FAILURE;
8884 break;
8885 }
8886 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8887 pScanFilter->authType = pProfile->AuthType;
8888 pScanFilter->EncryptionType = pProfile->EncryptionType;
8889 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8890 pScanFilter->BSSType = pProfile->BSSType;
8891 pScanFilter->phyMode = pProfile->phyMode;
8892#ifdef FEATURE_WLAN_WAPI
8893 //check if user asked for WAPI with 11n or auto mode, in that case modify
8894 //the phymode to 11g
8895 if(csrIsProfileWapi(pProfile))
8896 {
8897 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8898 {
8899 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8900 }
8901 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8902 {
8903 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8904 }
8905 if(!pScanFilter->phyMode)
8906 {
8907 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8908 }
8909 }
8910#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008911 /*Save the WPS info*/
8912 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07008913 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008914 if( pProfile->countryCode[0] )
8915 {
8916 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05308917 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
8918 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008919 }
8920#ifdef WLAN_FEATURE_VOWIFI_11R
8921 if (pProfile->MDID.mdiePresent)
8922 {
8923 pScanFilter->MDID.mdiePresent = 1;
8924 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8925 }
8926#endif
8927
8928 }while(0);
8929
8930 if(!HAL_STATUS_SUCCESS(status))
8931 {
8932 csrFreeScanFilter(pMac, pScanFilter);
8933 }
8934
8935 return(status);
8936}
8937
Jeff Johnson295189b2012-06-20 16:38:30 -07008938tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8939 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8940{
8941 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8942 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008943 do
8944 {
8945 // Validate the type is ok...
8946 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8947 pCommand = csrGetCommandBuffer( pMac );
8948 if ( !pCommand )
8949 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008950 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008951 break;
8952 }
8953 //Change the substate in case it is waiting for key
8954 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8955 {
8956 csrRoamStopWaitForKeyTimer( pMac );
8957 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8958 }
8959 pCommand->command = eSmeCommandWmStatusChange;
8960 pCommand->sessionId = (tANI_U8)sessionId;
8961 pCommand->u.wmStatusChangeCmd.Type = Type;
8962 if ( eCsrDisassociated == Type )
8963 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308964 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
8965 pSmeRsp,
8966 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008967 }
8968 else
8969 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308970 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
8971 pSmeRsp,
8972 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008973 }
8974 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8975 {
8976 fCommandQueued = eANI_BOOLEAN_TRUE;
8977 }
8978 else
8979 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008980 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008981 csrReleaseCommandWmStatusChange( pMac, pCommand );
8982 }
8983
Jeff Johnson295189b2012-06-20 16:38:30 -07008984 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8985 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008986 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008987 return( fCommandQueued );
8988}
8989
Jeff Johnson295189b2012-06-20 16:38:30 -07008990static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8991{
8992 v_S7_t rssi = 0;
8993 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8994 if(pGetRssiReq)
8995 {
8996 if(NULL != pGetRssiReq->pVosContext)
8997 {
8998 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8999 }
9000 else
9001 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009002 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009003 return;
9004 }
9005
9006 if(NULL != pGetRssiReq->rssiCallback)
9007 {
9008 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9009 }
9010 else
9011 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009012 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009013 return;
9014 }
9015 }
9016 else
9017 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009018 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009019 }
9020 return;
9021}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309022
9023static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9024{
9025 tANI_S8 snr = 0;
9026 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9027
9028 if (pGetSnrReq)
9029 {
9030 if (VOS_STATUS_SUCCESS !=
9031 WDA_GetSnr(pGetSnrReq->staId, &snr))
9032 {
9033 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9034 return;
9035 }
9036
9037 if (pGetSnrReq->snrCallback)
9038 {
9039 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9040 pGetSnrReq->pDevContext);
9041 }
9042 else
9043 {
9044 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9045 return;
9046 }
9047 }
9048 else
9049 {
9050 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9051 }
9052 return;
9053}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009054#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009055void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9056{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009057 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9058
Jeff Johnson36d483b2013-04-08 11:08:53 -07009059 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009060 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009061 /* Get roam Rssi request is backed up and passed back to the response,
9062 Extract the request message to fetch callback */
9063 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9064 v_S7_t rssi = pRoamRssiRsp->rssi;
9065
9066 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009067 {
9068 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9069 reqBkp->rssiCallback = NULL;
9070 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009071 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009072 }
9073 else
9074 {
9075 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9076 if (NULL != reqBkp)
9077 {
9078 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009079 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009080 }
9081 }
9082 }
9083 else
9084 {
9085 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9086 }
9087 return;
9088}
9089#endif
9090
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009091
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009092#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009093void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9094{
9095 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9096
9097 if (NULL != pTsmStatsRsp)
9098 {
9099 /* Get roam Rssi request is backed up and passed back to the response,
9100 Extract the request message to fetch callback */
9101 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9102
9103 if (NULL != reqBkp)
9104 {
9105 if (NULL != reqBkp->tsmStatsCallback)
9106 {
9107 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9108 pTsmStatsRsp->staId, reqBkp->pDevContext);
9109 reqBkp->tsmStatsCallback = NULL;
9110 }
9111 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009112 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009113 }
9114 else
9115 {
9116 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9117 if (NULL != reqBkp)
9118 {
9119 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009120 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009121 }
9122 }
9123 }
9124 else
9125 {
9126 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9127 }
9128 return;
9129}
9130
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009131void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009132{
9133 tANI_U32 roamTS2 = 0;
9134 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009135 tpPESession pSessionEntry = NULL;
9136 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009137
9138 if (NULL == pSession)
9139 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009140 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009141 return;
9142 }
9143
9144 roamTS2 = vos_timer_get_system_time();
9145 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009146 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9147 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009148 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009149
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009150 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9151 if (NULL == pSessionEntry)
9152 {
9153 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9154 return;
9155 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009156 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009157 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009158 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009159}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009160#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009161
Jeff Johnsone7245742012-09-05 17:12:55 -07009162static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9163{
9164 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9165 if(pTlRssiInd)
9166 {
9167 if(NULL != pTlRssiInd->tlCallback)
9168 {
9169 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009170 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009171 }
9172 else
9173 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009174 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009175 }
9176 }
9177 else
9178 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009179 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009180 }
9181 return;
9182}
Jeff Johnson295189b2012-06-20 16:38:30 -07009183
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309184eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9185{
9186 tpSirResetAPCapsChange pMsg;
9187 tANI_U16 len;
9188 eHalStatus status = eHAL_STATUS_SUCCESS;
9189
9190 /* Create the message and send to lim */
9191 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309192 pMsg = vos_mem_malloc(len);
9193 if ( NULL == pMsg )
9194 status = eHAL_STATUS_FAILURE;
9195 else
9196 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309197 if (HAL_STATUS_SUCCESS(status))
9198 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309199 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309200 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9201 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309202 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009203 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9204 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309205 status = palSendMBMessage(pMac->hHdd, pMsg);
9206 }
9207 else
9208 {
9209 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9210 }
9211 return status;
9212}
9213
Jeff Johnson295189b2012-06-20 16:38:30 -07009214void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9215{
9216 tSirSmeAssocInd *pAssocInd;
9217 tSirSmeDisassocInd *pDisassocInd;
9218 tSirSmeDeauthInd *pDeauthInd;
9219 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9220 tSirSmeNewBssInfo *pNewBss;
9221 tSmeIbssPeerInd *pIbssPeerInd;
9222 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9223 tSirSmeApNewCaps *pApNewCaps;
9224 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9225 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9226 tCsrRoamInfo *pRoamInfo = NULL;
9227 tCsrRoamInfo roamInfo;
9228 eHalStatus status;
9229 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9230 tCsrRoamSession *pSession = NULL;
9231 tpSirSmeSwitchChannelInd pSwitchChnInd;
9232 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309233 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009234
9235
9236 if (NULL == pSirMsg)
9237 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9238 return;
9239 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009240 switch( pSirMsg->messageType )
9241 {
9242 case eWNI_SME_ASSOC_IND:
9243 {
9244 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009245 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009246 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9247 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9248 if( HAL_STATUS_SUCCESS( status ) )
9249 {
9250 pSession = CSR_GET_SESSION(pMac, sessionId);
9251
Jeff Johnson32d95a32012-09-10 13:15:23 -07009252 if(!pSession)
9253 {
9254 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9255 return;
9256 }
9257
Jeff Johnson295189b2012-06-20 16:38:30 -07009258 pRoamInfo = &roamInfo;
9259
9260 // Required for indicating the frames to upper layer
9261 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9262 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9263
9264 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9265 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9266 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9267 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9268
9269 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9270 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9271 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9272
9273 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9274 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309275 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9276 sizeof(tSirMacAddr));
9277 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9278 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009279 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9280 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009281 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009282 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9283 {
9284 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9285 {
9286 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9287 pSession->pConnectBssDesc,
9288 &(pRoamInfo->peerMac),
9289 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9290 pRoamInfo->fAuthRequired = FALSE;
9291 }
9292 else
9293 {
9294 pRoamInfo->fAuthRequired = TRUE;
9295 }
9296 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9297 if (!HAL_STATUS_SUCCESS(status))
9298 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9299 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009300 /* Send Association completion message to PE */
9301 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9302
9303 /* send a message to CSR itself just to avoid the EAPOL frames going
9304 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009305 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9306 {
9307 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009309 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9310 {
9311 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9312 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9313 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9314 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009315 }
9316 }
9317 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009318 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009319 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309320 // Check if AP dis-associated us because of MIC failure. If so,
9321 // then we need to take action immediately and not wait till the
9322 // the WmStatusChange requests is pushed and processed
9323 tSmeCmd *pCommand;
9324
9325 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9326 status = csrRoamGetSessionIdFromBSSID( pMac,
9327 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9328 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009329 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309330 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9331 " for session %d "), sessionId);
9332 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9333 MAC_ADDRESS_STR " "
9334 " reason = %d status = %d "),
9335 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9336 pDisassocInd->reasonCode,
9337 pDisassocInd->statusCode);
9338 // If we are in neighbor preauth done state then on receiving
9339 // disassoc or deauth we dont roam instead we just disassoc
9340 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009341 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309342#ifdef WLAN_FEATURE_VOWIFI_11R
9343 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9344 {
9345 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009347#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009348#ifdef FEATURE_WLAN_ESE
9349 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309350 {
9351 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9352 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009353#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009354#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309355 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9356 {
9357 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9358 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009359#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309360 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009361
Agarwal Ashish4f616132013-12-30 23:32:50 +05309362 if (!pSession)
9363 {
9364 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9365 return;
9366 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009367
Agarwal Ashish4f616132013-12-30 23:32:50 +05309368 if ( csrIsConnStateInfra( pMac, sessionId ) )
9369 {
9370 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009372#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309373 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009374#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309375 csrRoamLinkDown(pMac, sessionId);
9376 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9377 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9378 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309379 pRoamInfo = &roamInfo;
9380 pRoamInfo->statusCode = pDisassocInd->statusCode;
9381 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9382 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009383
Agarwal Ashish4f616132013-12-30 23:32:50 +05309384 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9385 sizeof(tSirMacAddr));
9386 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9387 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009388
Agarwal Ashish4f616132013-12-30 23:32:50 +05309389 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9390 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009391
Agarwal Ashish4f616132013-12-30 23:32:50 +05309392 /*
9393 * STA/P2P client got disassociated so remove any pending deauth
9394 * commands in sme pending list
9395 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309396 pCommand = csrGetCommandBuffer(pMac);
9397 if (NULL == pCommand)
9398 {
9399 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9400 status = eHAL_STATUS_RESOURCES;
9401 return;
9402 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309403 pCommand->command = eSmeCommandRoam;
9404 pCommand->sessionId = (tANI_U8)sessionId;
9405 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9406 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9407 pDisassocInd->peerMacAddr,
9408 sizeof(tSirMacAddr));
9409 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9410 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009411
Agarwal Ashish4f616132013-12-30 23:32:50 +05309412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009413 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309414 else
9415 {
9416 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9417 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9418 }
Kiet Lam82004c62013-11-11 13:24:28 +05309419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009420 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009421 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009422 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009423 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9424 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9425 if( HAL_STATUS_SUCCESS( status ) )
9426 {
9427 // If we are in neighbor preauth done state then on receiving
9428 // disassoc or deauth we dont roam instead we just disassoc
9429 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009430 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009431#ifdef WLAN_FEATURE_VOWIFI_11R
9432 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9433 {
9434 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9435 }
9436#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009437#ifdef FEATURE_WLAN_ESE
9438 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009439 {
9440 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9441 }
9442#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009443#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309444 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009445 {
9446 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9447 }
9448#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009449 pSession = CSR_GET_SESSION( pMac, sessionId );
9450
Jeff Johnson32d95a32012-09-10 13:15:23 -07009451 if(!pSession)
9452 {
9453 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9454 return;
9455 }
9456
Jeff Johnson295189b2012-06-20 16:38:30 -07009457 if ( csrIsConnStateInfra( pMac, sessionId ) )
9458 {
9459 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009461#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9462 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9463#endif
9464 csrRoamLinkDown(pMac, sessionId);
9465 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009466 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9467 {
9468
9469 pRoamInfo = &roamInfo;
9470
9471 pRoamInfo->statusCode = pDeauthInd->statusCode;
9472 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9473
9474 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9475
Kiet Lam64c1b492013-07-12 13:56:44 +05309476 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9477 sizeof(tSirMacAddr));
9478 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9479 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009480
9481 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009483 }
9484 break;
9485
9486 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 -08009487 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009488 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9489 //Update with the new channel id.
9490 //The channel id is hidden in the statusCode.
9491 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9492 if( HAL_STATUS_SUCCESS( status ) )
9493 {
9494 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009495 if(!pSession)
9496 {
9497 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9498 return;
9499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009500 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9501 if(pSession->pConnectBssDesc)
9502 {
9503 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9504 }
9505 }
9506 break;
9507
9508 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009509 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009510 {
9511 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9512 sessionId = pDeauthRsp->sessionId;
9513 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9514 {
9515 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009516 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9517 {
9518 pRoamInfo = &roamInfo;
9519 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309520 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9521 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009522 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9523 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9524 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9525 }
9526 }
9527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009528 break;
9529
9530 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009531 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009532 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009533 {
9534 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9535 sessionId = pDisassocRsp->sessionId;
9536 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9537 {
9538 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009539 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9540 {
9541 pRoamInfo = &roamInfo;
9542 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309543 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9544 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009545 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9546 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9547 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9548 }
9549 }
9550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009551 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009552 case eWNI_SME_MIC_FAILURE_IND:
9553 {
9554 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9555 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9556 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009557
9558 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9559 if( HAL_STATUS_SUCCESS( status ) )
9560 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309561 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009562 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9563 pRoamInfo = &roamInfo;
9564 if(pMicInd->info.multicast)
9565 {
9566 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9567 }
9568 else
9569 {
9570 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9571 }
9572 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9573 }
9574
Jeff Johnson295189b2012-06-20 16:38:30 -07009575#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9576 {
lukez3c809222013-05-03 10:23:02 -07009577 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009578 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009579 if(!pSession)
9580 {
9581 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9582 return;
9583 }
lukez3c809222013-05-03 10:23:02 -07009584
Kiet Lam64c1b492013-07-12 13:56:44 +05309585 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009586 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9587 secEvent.encryptionModeMulticast =
9588 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9589 secEvent.encryptionModeUnicast =
9590 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9591 secEvent.authMode =
9592 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309593 vos_mem_copy(secEvent.bssid,
9594 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009595 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9596 }
9597#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009598 }
9599 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009600 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9601 {
9602 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9603 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009604 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009605
9606 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9607 if( HAL_STATUS_SUCCESS( status ) )
9608 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309609 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009610 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9611 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9612 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9613 }
9614 }
9615 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009616
Jeff Johnson295189b2012-06-20 16:38:30 -07009617 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9618 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9619 switch( pStatusChangeMsg->statusChangeCode )
9620 {
9621 case eSIR_SME_IBSS_ACTIVE:
9622 sessionId = csrFindIbssSession( pMac );
9623 if( CSR_SESSION_ID_INVALID != sessionId )
9624 {
9625 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009626 if(!pSession)
9627 {
9628 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9629 return;
9630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009631 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9632 if(pSession->pConnectBssDesc)
9633 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309634 vos_mem_copy(&roamInfo.bssid,
9635 pSession->pConnectBssDesc->bssId,
9636 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009637 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9638 pRoamInfo = &roamInfo;
9639 }
9640 else
9641 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009642 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 }
9644 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9645 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9646 }
9647 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 case eSIR_SME_IBSS_INACTIVE:
9649 sessionId = csrFindIbssSession( pMac );
9650 if( CSR_SESSION_ID_INVALID != sessionId )
9651 {
9652 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009653 if(!pSession)
9654 {
9655 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9656 return;
9657 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009658 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9659 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9660 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9661 }
9662 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009663 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9664 sessionId = csrFindIbssSession( pMac );
9665 if( CSR_SESSION_ID_INVALID != sessionId )
9666 {
9667 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009668 if(!pSession)
9669 {
9670 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9671 return;
9672 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009673 // update the connection state information
9674 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009675#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9676 {
9677 vos_log_ibss_pkt_type *pIbssLog;
9678 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009679 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9680 if(pIbssLog)
9681 {
9682 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9683 if(pNewBss)
9684 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309685 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009686 if(pNewBss->ssId.length)
9687 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309688 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9689 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009690 }
9691 pIbssLog->operatingChannel = pNewBss->channelNumber;
9692 }
9693 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9694 {
9695 //***U8 is not enough for beacon interval
9696 pIbssLog->beaconInterval = (v_U8_t)bi;
9697 }
9698 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9699 }
9700 }
9701#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009702 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009703
9704 if ((eCSR_ENCRYPT_TYPE_NONE ==
9705 pSession->connectedProfile.EncryptionType ))
9706 {
9707 csrRoamIssueSetContextReq( pMac, sessionId,
9708 pSession->connectedProfile.EncryptionType,
9709 pSession->pConnectBssDesc,
9710 &Broadcastaddr,
9711 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9712 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009713 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9714 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309715 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9716 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009717 pRoamInfo = &roamInfo;
9718 //This BSSID is th ereal BSSID, let's save it
9719 if(pSession->pConnectBssDesc)
9720 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309721 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9722 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009723 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009724 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009725 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009726 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009727 // detection by LIM that the capabilities of the associated AP have changed.
9728 case eSIR_SME_AP_CAPS_CHANGED:
9729 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009730 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009731 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9732 if( HAL_STATUS_SUCCESS( status ) )
9733 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009734 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9735 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309736 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009737 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9738 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9739 )
9740 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309741 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9742 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009743 }
9744 else
9745 {
9746 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309747 FL("Skipping csrScanForCapabilityChange as "
9748 "CSR is in state %s and sub-state %s"),
9749 macTraceGetcsrRoamState(
9750 pMac->roam.curState[sessionId]),
9751 macTraceGetcsrRoamSubState(
9752 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309753 /* We ignore the caps change event if CSR is not in full connected state.
9754 * Send one event to PE to reset limSentCapsChangeNtf
9755 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9756 * otherwise lim cannot send any CAPS change events to SME */
9757 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009758 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009759 }
9760 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309761
Jeff Johnson295189b2012-06-20 16:38:30 -07009762 default:
9763 roamStatus = eCSR_ROAM_FAILED;
9764 result = eCSR_ROAM_RESULT_NONE;
9765 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009766 } // end switch on statusChangeCode
9767 if(eCSR_ROAM_RESULT_NONE != result)
9768 {
9769 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9770 }
9771 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009772 case eWNI_SME_IBSS_NEW_PEER_IND:
9773 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009774#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9775 {
9776 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009777 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9778 if(pIbssLog)
9779 {
9780 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309781 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009782 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9783 }
9784 }
9785#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 sessionId = csrFindIbssSession( pMac );
9787 if( CSR_SESSION_ID_INVALID != sessionId )
9788 {
9789 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009790
9791 if(!pSession)
9792 {
9793 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9794 return;
9795 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9797 if(pSession->pConnectBssDesc)
9798 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309799 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9800 sizeof(tCsrBssid));
9801 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9802 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009803 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9804 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309805 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9806 - sizeof(tSmeIbssPeerInd)));
9807 if ( NULL == roamInfo.pbFrames )
9808 status = eHAL_STATUS_FAILURE;
9809 else
9810 status = eHAL_STATUS_SUCCESS;
9811 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009812 {
9813 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309814 vos_mem_copy(roamInfo.pbFrames,
9815 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9816 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009817 }
9818 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9819 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9820 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309821 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9822 if ( NULL == roamInfo.pBssDesc )
9823 status = eHAL_STATUS_FAILURE;
9824 else
9825 status = eHAL_STATUS_SUCCESS;
9826 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009827 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309828 vos_mem_copy(roamInfo.pBssDesc,
9829 pSession->pConnectBssDesc,
9830 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009831 }
9832 if(HAL_STATUS_SUCCESS(status))
9833 {
9834 pRoamInfo = &roamInfo;
9835 }
9836 else
9837 {
9838 if(roamInfo.pbFrames)
9839 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309840 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009841 }
9842 if(roamInfo.pBssDesc)
9843 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309844 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009845 }
9846 }
9847 }
9848 else
9849 {
9850 pRoamInfo = &roamInfo;
9851 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009852 if ((eCSR_ENCRYPT_TYPE_NONE ==
9853 pSession->connectedProfile.EncryptionType ))
9854 {
9855 csrRoamIssueSetContextReq( pMac, sessionId,
9856 pSession->connectedProfile.EncryptionType,
9857 pSession->pConnectBssDesc,
9858 &(pIbssPeerInd->peerAddr),
9859 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009861 }
9862 else
9863 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009864 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009865 }
9866 //send up the sec type for the new peer
9867 if (pRoamInfo)
9868 {
9869 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9870 }
9871 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9872 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9873 if(pRoamInfo)
9874 {
9875 if(roamInfo.pbFrames)
9876 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309877 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009878 }
9879 if(roamInfo.pBssDesc)
9880 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309881 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 }
9883 }
9884 }
9885 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009886 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9887 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9888 sessionId = csrFindIbssSession( pMac );
9889 if( CSR_SESSION_ID_INVALID != sessionId )
9890 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009891#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9892 {
9893 vos_log_ibss_pkt_type *pIbssLog;
9894
9895 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9896 if(pIbssLog)
9897 {
9898 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9899 if(pIbssPeerInd)
9900 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309901 vos_mem_copy(pIbssLog->peerMacAddr,
9902 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009903 }
9904 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9905 }
9906 }
9907#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009908 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009909 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9910 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9911 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309912 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9913 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009914 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9915 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9916 }
9917 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 case eWNI_SME_SETCONTEXT_RSP:
9919 {
9920 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9921 tListElem *pEntry;
9922 tSmeCmd *pCommand;
9923
9924 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9925 if ( pEntry )
9926 {
9927 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9928 if ( eSmeCommandSetKey == pCommand->command )
9929 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +05309930 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009931 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009932
9933 if(!pSession)
9934 {
9935 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9936 return;
9937 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009938
9939#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9940 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9941 {
9942 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309943 vos_mem_set(&setKeyEvent,
9944 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009945 if( pRsp->peerMacAddr[0] & 0x01 )
9946 {
9947 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9948 }
9949 else
9950 {
9951 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9952 }
9953 setKeyEvent.encryptionModeMulticast =
9954 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9955 setKeyEvent.encryptionModeUnicast =
9956 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309957 vos_mem_copy(setKeyEvent.bssid,
9958 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 setKeyEvent.authMode =
9960 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009961 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009962 {
9963 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9964 }
9965 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9966 }
9967#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9968 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9969 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009970 csrRoamStopWaitForKeyTimer( pMac );
9971
Jeff Johnson295189b2012-06-20 16:38:30 -07009972 //We are done with authentication, whethere succeed or not
9973 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009974 //We do it here because this linkup function is not called after association
9975 //when a key needs to be set.
9976 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9977 {
9978 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9979 }
9980 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009981 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009982 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309983 vos_mem_copy(&roamInfo.peerMac,
9984 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07009985 //Make sure we install the GTK before indicating to HDD as authenticated
9986 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +05309987 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
9988 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009989 {
Yathish9f22e662012-12-10 14:21:35 -08009990#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9991 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9992 {
9993 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +05309994 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -08009995 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9996 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9997 pMsg->seesionId = sessionId;
9998 status = palSendMBMessage(pMac->hHdd, pMsg );
9999 }
10000#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010001 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010002 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
10003 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE )
10004 {
10005 tpSirSmeHT40OBSSScanInd pMsg;
10006 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10007 pMsg->messageType =
10008 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10009 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010010 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10011 vos_mem_copy(pMsg->peerMacAddr,
10012 pSession->connectedProfile.bssid,
10013 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010014 status = palSendMBMessage(pMac->hHdd,
10015 pMsg );
10016 }
10017 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010018 }
10019 else
10020 {
10021 result = eCSR_ROAM_RESULT_NONE;
10022 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010023 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010024 }
10025 else
10026 {
10027 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010028 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10029 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10030 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010031 }
10032 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10033 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010034 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10035 // can go ahead and initiate the TSPEC if any are pending
10036 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010037#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010038 //Send Adjacent AP repot to new AP.
10039 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10040 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010041 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010042 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010043#ifdef FEATURE_WLAN_ESE_UPLOAD
10044 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010045#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010046 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010047#endif
10048 pSession->isPrevApInfoValid = FALSE;
10049 }
10050#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010051 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10052 {
10053 csrReleaseCommandSetKey( pMac, pCommand );
10054 }
10055 }
10056 else
10057 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010058 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010059 }
10060 }
10061 else
10062 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010063 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010064 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010065 smeProcessPendingQueue( pMac );
10066 }
10067 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010068 case eWNI_SME_REMOVEKEY_RSP:
10069 {
10070 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10071 tListElem *pEntry;
10072 tSmeCmd *pCommand;
10073
10074 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10075 if ( pEntry )
10076 {
10077 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10078 if ( eSmeCommandRemoveKey == pCommand->command )
10079 {
10080 sessionId = pCommand->sessionId;
10081 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010082
10083 if(!pSession)
10084 {
10085 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10086 return;
10087 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010088#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10089 {
10090 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010091 vos_mem_set(&removeKeyEvent,
10092 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010093 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10094 removeKeyEvent.encryptionModeMulticast =
10095 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10096 removeKeyEvent.encryptionModeUnicast =
10097 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010098 vos_mem_copy( removeKeyEvent.bssid,
10099 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010100 removeKeyEvent.authMode =
10101 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010102 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 {
10104 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10105 }
10106 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10107 }
10108#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010109 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010110 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010111 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10112 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010113 result = eCSR_ROAM_RESULT_NONE;
10114 pRoamInfo = &roamInfo;
10115 }
10116 else
10117 {
10118 result = eCSR_ROAM_RESULT_FAILURE;
10119 }
10120 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10121 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10122 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10123 {
10124 csrReleaseCommandRemoveKey( pMac, pCommand );
10125 }
10126 }
10127 else
10128 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010129 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010130 }
10131 }
10132 else
10133 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010134 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010135 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010136 smeProcessPendingQueue( pMac );
10137 }
10138 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010139 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010140 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010141 csrRoamStatsRspProcessor( pMac, pSirMsg );
10142 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010143#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010144 case eWNI_SME_GET_ROAM_RSSI_RSP:
10145 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10146 csrRoamRssiRspProcessor( pMac, pSirMsg );
10147 break;
10148#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010149#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010150 case eWNI_SME_GET_TSM_STATS_RSP:
10151 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10152 csrTsmStatsRspProcessor( pMac, pSirMsg );
10153 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010154#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010155 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010156 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010157 csrUpdateRssi( pMac, pSirMsg );
10158 break;
10159
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010160 case eWNI_SME_GET_SNR_REQ:
10161 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10162 csrUpdateSnr(pMac, pSirMsg);
10163 break;
10164
Jeff Johnson295189b2012-06-20 16:38:30 -070010165#ifdef WLAN_FEATURE_VOWIFI_11R
10166 case eWNI_SME_FT_PRE_AUTH_RSP:
10167 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10168 break;
10169#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010170 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10171 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010172 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 -070010173 sessionId = pSmeMaxAssocInd->sessionId;
10174 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010175 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10176 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010177 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10178 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10179 break;
10180
10181 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010182 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010183 btampEstablishLogLinkHdlr( pSirMsg );
10184 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010185 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010186 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010187 csrRoamRssiIndHdlr( pMac, pSirMsg );
10188 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010189#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10190 case eWNI_SME_CANDIDATE_FOUND_IND:
10191 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10192 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10193 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010194 case eWNI_SME_HANDOFF_REQ:
10195 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10196 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10197 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010198#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010199
10200 default:
10201 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010202 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010203}
10204
Jeff Johnson295189b2012-06-20 16:38:30 -070010205void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10206 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10207{
10208 if(pSession)
10209 {
10210 if(pSession->bRefAssocStartCnt)
10211 {
10212 pSession->bRefAssocStartCnt--;
10213 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10214 //Need to call association_completion because there is an assoc_start pending.
10215 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10216 eCSR_ROAM_ASSOCIATION_COMPLETION,
10217 eCSR_ROAM_RESULT_FAILURE);
10218 }
10219 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10220 }
10221 else
10222 {
10223 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10224 }
10225}
10226
10227
10228eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10229{
10230 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010231 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10232 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10233 {
10234 status = csrScanRequestLostLink1( pMac, sessionId );
10235 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010236 return(status);
10237}
10238
Jeff Johnson295189b2012-06-20 16:38:30 -070010239//return a boolean to indicate whether roaming completed or continue.
10240tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10241 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10242{
10243 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10244 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10245 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10246 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010247 if(!pSession)
10248 {
10249 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10250 return eANI_BOOLEAN_FALSE;
10251 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010252 //Check whether time is up
10253 if(pSession->fCancelRoaming || fForce ||
10254 ((curTime - pSession->roamingStartTime) > roamTime) ||
10255 eCsrReassocRoaming == pSession->roamingReason ||
10256 eCsrDynamicRoaming == pSession->roamingReason)
10257 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010258 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010259 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10260 {
10261 //roaming is cancelled, tell HDD to indicate disconnect
10262 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10263 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10264 //to be eSIR_BEACON_MISSED
10265 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10266 {
10267 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10268 }
10269 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10270 {
10271 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10272 }
10273 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10274 {
10275 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10276 }
10277 else
10278 {
10279 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10280 }
10281 }
10282 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10283 pSession->roamingReason = eCsrNotRoaming;
10284 }
10285 else
10286 {
10287 pSession->roamResult = roamResult;
10288 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10289 {
10290 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10291 pSession->roamingReason = eCsrNotRoaming;
10292 }
10293 else
10294 {
10295 fCompleted = eANI_BOOLEAN_FALSE;
10296 }
10297 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010298 return(fCompleted);
10299}
10300
Jeff Johnson295189b2012-06-20 16:38:30 -070010301void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10302{
10303 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010304
10305 if(!pSession)
10306 {
10307 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10308 return;
10309 }
10310
Jeff Johnson295189b2012-06-20 16:38:30 -070010311 if(CSR_IS_ROAMING(pSession))
10312 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010313 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010314 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10315 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10316 {
10317 //No need to do anything in here because the handler takes care of it
10318 }
10319 else
10320 {
10321 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10322 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10323 //Roaming is stopped after here
10324 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10325 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010326 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010327 csrRoamStopRoamingTimer(pMac, sessionId);
10328 }
10329 }
10330}
10331
Jeff Johnson295189b2012-06-20 16:38:30 -070010332void csrRoamRoamingTimerHandler(void *pv)
10333{
10334 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10335 tpAniSirGlobal pMac = pInfo->pMac;
10336 tANI_U32 sessionId = pInfo->sessionId;
10337 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010338
10339 if(!pSession)
10340 {
10341 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10342 return;
10343 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010344
10345 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10346 {
10347 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10348 {
10349 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10350 pSession->roamingReason = eCsrNotRoaming;
10351 }
10352 }
10353}
10354
Jeff Johnson295189b2012-06-20 16:38:30 -070010355eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10356{
10357 eHalStatus status;
10358 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010359
10360 if(!pSession)
10361 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010362 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010363 return eHAL_STATUS_FAILURE;
10364 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010365
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010366 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010367 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010368 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010369
10370 return (status);
10371}
10372
Jeff Johnson295189b2012-06-20 16:38:30 -070010373eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10374{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010375 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010376}
10377
Jeff Johnson295189b2012-06-20 16:38:30 -070010378void csrRoamWaitForKeyTimeOutHandler(void *pv)
10379{
10380 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10381 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010382 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010383 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010384
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010385 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10386 macTraceGetNeighbourRoamState(
10387 pMac->roam.neighborRoamInfo.neighborRoamState),
10388 macTraceGetcsrRoamSubState(
10389 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010390
Jeff Johnson295189b2012-06-20 16:38:30 -070010391 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10392 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010393#ifdef FEATURE_WLAN_LFR
10394 if (csrNeighborRoamIsHandoffInProgress(pMac))
10395 {
10396 /*
10397 * Enable heartbeat timer when hand-off is in progress
10398 * and Key Wait timer expired.
10399 */
10400 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010401 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010402 pMac->roam.configParam.HeartbeatThresh24);
10403 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10404 pMac->roam.configParam.HeartbeatThresh24,
10405 NULL, eANI_BOOLEAN_FALSE);
10406 }
10407#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010408 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010409
Jeff Johnson295189b2012-06-20 16:38:30 -070010410 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010411 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10412 {
10413 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10414 pInfo->sessionId);
10415 }
10416
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010417 if (pSession)
10418 {
10419 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10420 {
10421 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10422 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010423 if( (pSession->connectedProfile.AuthType ==
10424 eCSR_AUTH_TYPE_SHARED_KEY) &&
10425 ( (pSession->connectedProfile.EncryptionType ==
10426 eCSR_ENCRYPT_TYPE_WEP40) ||
10427 (pSession->connectedProfile.EncryptionType ==
10428 eCSR_ENCRYPT_TYPE_WEP104) ))
10429 {
10430 status = sme_AcquireGlobalLock( &pMac->sme );
10431 if ( HAL_STATUS_SUCCESS( status ) )
10432 {
10433 csrRoamDisconnect( pMac, pInfo->sessionId,
10434 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10435 sme_ReleaseGlobalLock( &pMac->sme );
10436 }
10437 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010438 }
10439 else
10440 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010441 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010442 __func__);
10443 }
10444 }
10445 else
10446 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010447 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010448 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010449 }
10450
10451}
10452
Jeff Johnson295189b2012-06-20 16:38:30 -070010453eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10454{
10455 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010456#ifdef FEATURE_WLAN_LFR
10457 if (csrNeighborRoamIsHandoffInProgress(pMac))
10458 {
10459 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010460 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10461 macTraceGetNeighbourRoamState(
10462 pMac->roam.neighborRoamInfo.neighborRoamState),
10463 macTraceGetcsrRoamSubState(
10464 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10465 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010466 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10467 }
10468#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010469 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010470 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010471
10472 return (status);
10473}
10474
Jeff Johnson295189b2012-06-20 16:38:30 -070010475eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10476{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010477 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10478 macTraceGetNeighbourRoamState(
10479 pMac->roam.neighborRoamInfo.neighborRoamState),
10480 macTraceGetcsrRoamSubState(
10481 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010482#ifdef FEATURE_WLAN_LFR
10483 if (csrNeighborRoamIsHandoffInProgress(pMac))
10484 {
10485 /*
10486 * Enable heartbeat timer when hand-off is in progress
10487 * and Key Wait timer got stopped for some reason
10488 */
10489 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010490 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010491 pMac->roam.configParam.HeartbeatThresh24);
10492 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10493 pMac->roam.configParam.HeartbeatThresh24,
10494 NULL, eANI_BOOLEAN_FALSE);
10495 }
10496#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010497 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010498}
10499
Jeff Johnson295189b2012-06-20 16:38:30 -070010500void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10501 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10502{
10503 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10504 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010505 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10506 /* To silence the KW tool Null chaeck is added */
10507 if(!pSession)
10508 {
10509 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10510 return;
10511 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010512
10513 if(pCommand)
10514 {
10515 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010516 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010517 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010518 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10519 {
10520 //if success, force roaming completion
10521 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10522 }
10523 else
10524 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010525 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010526 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010527 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10528 }
10529}
10530
Jeff Johnson295189b2012-06-20 16:38:30 -070010531eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10532{
10533 eHalStatus status = eHAL_STATUS_SUCCESS;
10534 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10535 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10536 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10537 tCsrRoamInfo *pRoamInfo = NULL;
10538 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010539 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010540 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010541 /* To silence the KW tool Null chaeck is added */
10542 if(!pSession)
10543 {
10544 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10545 return eHAL_STATUS_FAILURE;
10546 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010547 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010548 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010549 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10550 if ( eWNI_SME_DISASSOC_IND == type )
10551 {
10552 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10553 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10554 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010555 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010556 }
10557 else if ( eWNI_SME_DEAUTH_IND == type )
10558 {
10559 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10560 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10561 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010562 /* Convert into proper reason code */
10563 pSession->joinFailStatusCode.reasonCode =
10564 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010565 0 : pDeauthIndMsg->reasonCode;
10566 /* cfg layer expects 0 as reason code if
10567 the driver dosent know the reason code
10568 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010569 }
10570 else
10571 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010572 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010573 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010574 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010575 }
10576
10577 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010578 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010579 {
10580 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10581 }
10582
10583 if ( eWNI_SME_DISASSOC_IND == type )
10584 {
10585 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10586 }
10587 else if ( eWNI_SME_DEAUTH_IND == type )
10588 {
10589 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10590 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010591 if(!HAL_STATUS_SUCCESS(status))
10592 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010593 //If fail to send confirmation to PE, not to trigger roaming
10594 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010595 }
10596
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010597 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010598 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010599 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10600 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010601 if( eWNI_SME_DISASSOC_IND == type)
10602 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010603 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010604 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10605 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010606 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10607 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010608 else if( eWNI_SME_DEAUTH_IND == type )
10609 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010610 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010611 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10612 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010613 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10614 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010615 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010616
10617 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10618 that we are roaming. But if we cannot possibly roam, or if we are unable to
10619 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010620 if(fToRoam)
10621 {
10622 //Only remove the connected BSS in infrastructure mode
10623 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10624 //Not to do anying for lostlink with WDS
10625 if( pMac->roam.configParam.nRoamingTime )
10626 {
10627 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10628 ( eWNI_SME_DEAUTH_IND == type ) ?
10629 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10630 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010631 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010632 //For IBSS, we need to give some more info to HDD
10633 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10634 {
10635 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10636 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10637 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10638 }
10639 else
10640 {
10641 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10642 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010643 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010644 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10645 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10646 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10647 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10648 }
10649 else
10650 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010651 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010652 fToRoam = eANI_BOOLEAN_FALSE;
10653 }
10654 }
10655 else
10656 {
10657 //We are told not to roam, indicate lostlink
10658 fToRoam = eANI_BOOLEAN_FALSE;
10659 }
10660 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010661 if(!fToRoam)
10662 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010663 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010664 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010665 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010666 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10667 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10668 * csrRoamCheckForLinkStatusChange API.
10669 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010670 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10671 }
10672
10673 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010674 Still enable idle scan for polling in case concurrent sessions are running */
10675 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10676 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010677 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010678 }
10679 }
10680
10681 return (status);
10682}
10683
Jeff Johnson295189b2012-06-20 16:38:30 -070010684eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10685{
10686 eHalStatus status = eHAL_STATUS_SUCCESS;
10687 tListElem *pEntry = NULL;
10688 tSmeCmd *pCommand = NULL;
10689 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010690
10691 if(!pSession)
10692 {
10693 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10694 return eHAL_STATUS_FAILURE;
10695 }
10696
Jeff Johnson295189b2012-06-20 16:38:30 -070010697 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010698 //Only remove the connected BSS in infrastructure mode
10699 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10700 if(pMac->roam.configParam.nRoamingTime)
10701 {
10702 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10703 {
10704 //before starting the lost link logic release the roam command for handoff
10705 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10706 if(pEntry)
10707 {
10708 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10709 }
10710 if(pCommand)
10711 {
10712 if (( eSmeCommandRoam == pCommand->command ) &&
10713 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10714 {
10715 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10716 {
10717 csrReleaseCommandRoam( pMac, pCommand );
10718 }
10719 }
10720 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010721 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010722 }
10723 }
10724 else
10725 {
10726 //We are told not to roam, indicate lostlink
10727 status = eHAL_STATUS_FAILURE;
10728 }
10729
10730 return (status);
10731}
Jeff Johnson295189b2012-06-20 16:38:30 -070010732void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10733{
10734 tListElem *pEntry;
10735 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010736 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10737 if ( pEntry )
10738 {
10739 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10740 if ( eSmeCommandWmStatusChange == pCommand->command )
10741 {
10742 // Nothing to process in a Lost Link completion.... It just kicks off a
10743 // roaming sequence.
10744 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10745 {
10746 csrReleaseCommandWmStatusChange( pMac, pCommand );
10747 }
10748 else
10749 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010750 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010751 }
10752
10753 }
10754 else
10755 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010756 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010757 }
10758 }
10759 else
10760 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010761 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010762 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010763 smeProcessPendingQueue( pMac );
10764}
10765
Jeff Johnson295189b2012-06-20 16:38:30 -070010766void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10767{
10768 eHalStatus status = eHAL_STATUS_FAILURE;
10769 tSirSmeRsp *pSirSmeMsg;
10770 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010771
10772 if(!pSession)
10773 {
10774 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10775 return;
10776 }
10777
Jeff Johnson295189b2012-06-20 16:38:30 -070010778 switch ( pCommand->u.wmStatusChangeCmd.Type )
10779 {
10780 case eCsrDisassociated:
10781 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10782 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10783 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010784 case eCsrDeauthenticated:
10785 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10786 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10787 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010788 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010789 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010790 break;
10791 }
10792 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10793 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10794 {
10795 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10796 {
10797 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010798 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010799 }
10800 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010801 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10802 // command here since there is nothing else to do.
10803 csrRoamWmStatusChangeComplete( pMac );
10804}
10805
Jeff Johnson295189b2012-06-20 16:38:30 -070010806//This function returns band and mode information.
10807//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10808//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010809static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10810 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010811{
Jeff Johnson295189b2012-06-20 16:38:30 -070010812 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10813 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10814 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010815 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010816
Jeff Johnson295189b2012-06-20 16:38:30 -070010817 //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 -070010818 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10819 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10820 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10821 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010822 {
10823 switch( pMac->roam.configParam.uCfgDot11Mode )
10824 {
10825 case eCSR_CFG_DOT11_MODE_11A:
10826 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10827 eBand = eCSR_BAND_5G;
10828 break;
10829 case eCSR_CFG_DOT11_MODE_11B:
10830 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10831 eBand = eCSR_BAND_24;
10832 break;
10833 case eCSR_CFG_DOT11_MODE_11G:
10834 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10835 eBand = eCSR_BAND_24;
10836 break;
10837 case eCSR_CFG_DOT11_MODE_11N:
10838 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010839 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10840 break;
10841#ifdef WLAN_FEATURE_11AC
10842 case eCSR_CFG_DOT11_MODE_11AC:
10843 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10844 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010845 /* If the operating channel is in 2.4 GHz band, check for
10846 * INI item to disable VHT operation in 2.4 GHz band
10847 */
10848 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10849 !pMac->roam.configParam.enableVhtFor24GHz)
10850 {
10851 /* Disable 11AC operation */
10852 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10853 }
10854 else
10855 {
10856 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10857 }
10858 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010859 }
10860 else
10861 {
10862 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10863 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10864 }
10865 break;
10866 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10867 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10868 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010869 /* If the operating channel is in 2.4 GHz band, check for
10870 * INI item to disable VHT operation in 2.4 GHz band
10871 */
10872 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10873 !pMac->roam.configParam.enableVhtFor24GHz)
10874 {
10875 /* Disable 11AC operation */
10876 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10877 }
10878 else
10879 {
10880 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10881 }
10882 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010883 }
10884 else
10885 {
10886 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10887 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10888 }
10889 break;
10890#endif
10891 case eCSR_CFG_DOT11_MODE_AUTO:
10892 eBand = pMac->roam.configParam.eBand;
10893 if (eCSR_BAND_24 == eBand)
10894 {
10895 // WiFi tests require IBSS networks to start in 11b mode
10896 // without any change to the default parameter settings
10897 // on the adapter. We use ACU to start an IBSS through
10898 // creation of a startIBSS profile. This startIBSS profile
10899 // has Auto MACProtocol and the adapter property setting
10900 // for dot11Mode is also AUTO. So in this case, let's
10901 // start the IBSS network in 11b mode instead of 11g mode.
10902 // So this is for Auto=profile->MacProtocol && Auto=Global.
10903 // dot11Mode && profile->channel is < 14, then start the IBSS
10904 // in b mode.
10905 //
10906 // Note: we used to have this start as an 11g IBSS for best
10907 // performance... now to specify that the user will have to
10908 // set the do11Mode in the property page to 11g to force it.
10909 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10910 }
10911 else
10912 {
10913#ifdef WLAN_FEATURE_11AC
10914 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10915 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010916 /* If the operating channel is in 2.4 GHz band, check for
10917 * INI item to disable VHT operation in 2.4 GHz band
10918 */
10919 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10920 !pMac->roam.configParam.enableVhtFor24GHz)
10921 {
10922 /* Disable 11AC operation */
10923 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10924 }
10925 else
10926 {
10927 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10928 }
10929 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010930 }
10931 else
10932 {
10933 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10934 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10935 }
10936#else
10937 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10938 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10939#endif
10940 }
10941 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010942 default:
10943 // Global dot11 Mode setting is 11a/b/g.
10944 // use the channel number to determine the Mode setting.
10945 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10946 {
10947 eBand = pMac->roam.configParam.eBand;
10948 if(eCSR_BAND_24 == eBand)
10949 {
10950 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10951 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10952 }
10953 else
10954 {
10955 //prefer 5GHz
10956 eBand = eCSR_BAND_5G;
10957 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10958 }
10959 }
10960 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10961 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010962 // WiFi tests require IBSS networks to start in 11b mode
10963 // without any change to the default parameter settings
10964 // on the adapter. We use ACU to start an IBSS through
10965 // creation of a startIBSS profile. This startIBSS profile
10966 // has Auto MACProtocol and the adapter property setting
10967 // for dot11Mode is also AUTO. So in this case, let's
10968 // start the IBSS network in 11b mode instead of 11g mode.
10969 // So this is for Auto=profile->MacProtocol && Auto=Global.
10970 // dot11Mode && profile->channel is < 14, then start the IBSS
10971 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010972 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010973 // Note: we used to have this start as an 11g IBSS for best
10974 // performance... now to specify that the user will have to
10975 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010976 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10977 eBand = eCSR_BAND_24;
10978 }
10979 else
10980 {
10981 // else, it's a 5.0GHz channel. Set mode to 11a.
10982 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10983 eBand = eCSR_BAND_5G;
10984 }
10985 break;
10986 }//switch
10987 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10988 else
10989 {
10990 //dot11 mode is set, lets pick the band
10991 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10992 {
10993 // channel is Auto also.
10994 eBand = pMac->roam.configParam.eBand;
10995 if(eCSR_BAND_ALL == eBand)
10996 {
10997 //prefer 5GHz
10998 eBand = eCSR_BAND_5G;
10999 }
11000 }
11001 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11002 {
11003 eBand = eCSR_BAND_24;
11004 }
11005 else
11006 {
11007 eBand = eCSR_BAND_5G;
11008 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011009 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011010 if(pBand)
11011 {
11012 *pBand = eBand;
11013 }
11014
11015 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011016 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011017 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11018 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011019
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011020 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11021 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 -070011022 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011023#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011024 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011025#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011026 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11027 {
11028 //We cannot do 11n here
11029 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11030 {
11031 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11032 }
11033 else
11034 {
11035 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11036 }
11037 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011038 return( cfgDot11Mode );
11039}
11040
Jeff Johnson295189b2012-06-20 16:38:30 -070011041eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11042{
11043 eHalStatus status;
11044 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011045
11046 if(!pSession)
11047 {
11048 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11049 return eHAL_STATUS_FAILURE;
11050 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011051
11052#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11053 {
11054 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011055 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11056 if(pIbssLog)
11057 {
11058 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11059 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11060 }
11061 }
11062#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011063 // Set the roaming substate to 'stop Bss request'...
11064 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11065
11066 // attempt to stop the Bss (reason code is ignored...)
11067 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011068 if(!HAL_STATUS_SUCCESS(status))
11069 {
11070 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11071 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011072 return (status);
11073}
11074
Jeff Johnson295189b2012-06-20 16:38:30 -070011075//pNumChan is a caller allocated space with the sizeof pChannels
11076eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11077{
11078
11079 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11080 (tANI_U8 *)pChannels,
11081 pNumChan));
11082}
11083
Kiran4a17ebe2013-01-31 10:43:43 -080011084tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11085{
11086 tANI_U32 cfgLength = 0;
11087 tANI_U16 cfgId = 0;
11088 tPowerdBm maxTxPwr = 0;
11089 tANI_U8 *pCountryInfo = NULL;
11090 eHalStatus status;
11091 tANI_U8 count = 0;
11092 tANI_U8 firstChannel;
11093 tANI_U8 maxChannels;
11094
11095 if (CSR_IS_CHANNEL_5GHZ(channel))
11096 {
11097 cfgId = WNI_CFG_MAX_TX_POWER_5;
11098 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11099 }
11100 else if (CSR_IS_CHANNEL_24GHZ(channel))
11101 {
11102 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11103 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11104 }
11105 else
11106 return maxTxPwr;
11107
Kiet Lam64c1b492013-07-12 13:56:44 +053011108 pCountryInfo = vos_mem_malloc(cfgLength);
11109 if ( NULL == pCountryInfo )
11110 status = eHAL_STATUS_FAILURE;
11111 else
11112 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011113 if (status != eHAL_STATUS_SUCCESS)
11114 {
11115 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011116 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011117 __FUNCTION__, status);
11118 goto error;
11119 }
11120 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11121 if (status != eHAL_STATUS_SUCCESS)
11122 {
11123 goto error;
11124 }
11125 /* Identify the channel and maxtxpower */
11126 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11127 {
11128 firstChannel = pCountryInfo[count++];
11129 maxChannels = pCountryInfo[count++];
11130 maxTxPwr = pCountryInfo[count++];
11131
11132 if ((channel >= firstChannel) &&
11133 (channel < (firstChannel + maxChannels)))
11134 {
11135 break;
11136 }
11137 }
11138
11139error:
11140 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011141 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011142
11143 return maxTxPwr;
11144}
11145
11146
Jeff Johnson295189b2012-06-20 16:38:30 -070011147tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11148{
11149 tANI_BOOLEAN fValid = FALSE;
11150 tANI_U32 idxValidChannels;
11151 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11152
11153 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11154 {
11155 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11156 {
11157 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11158 {
11159 fValid = TRUE;
11160 break;
11161 }
11162 }
11163 }
11164 pMac->roam.numValidChannels = len;
11165 return fValid;
11166}
11167
Jeff Johnson295189b2012-06-20 16:38:30 -070011168tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11169{
11170 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11171 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011172 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11173 {
11174 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11175 {
11176 fValid = eANI_BOOLEAN_TRUE;
11177 break;
11178 }
11179 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011180 return (fValid);
11181}
11182
Jeff Johnson295189b2012-06-20 16:38:30 -070011183//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011184 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011185{
Jeff Johnsone7245742012-09-05 17:12:55 -070011186 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011187 tANI_U8 centerChn;
11188 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011189
Jeff Johnson295189b2012-06-20 16:38:30 -070011190 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11191 {
11192 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11193 }
11194 else
11195 {
11196 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11197 }
11198 //Figure what the other side's CB mode
11199 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11200 {
11201 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11202 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011203 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11204 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11205 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11206 "\x00\x0f\xac\x02",4))
11207 //In Case WPA1 and TKIP is the only one cipher suite in Unicast.
11208 ||(pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
11209 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
11210 "\x00\x50\xf2\x02",4)))
11211
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011212 {
11213 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11214 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11215 }
11216
11217 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011218 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011219 /* This is called during INFRA STA/CLIENT and should use the merged value of
11220 * supported channel width and recommended tx width as per standard
11221 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011222 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011223 pIes->HTCaps.supportedChannelWidthSet,
11224 pIes->HTInfo.recommendedTxWidthSet,
11225 pIes->HTInfo.secondaryChannelOffset);
11226
11227 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11228 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011229 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011230 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11231 switch (eRet) {
11232 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11233 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11234 break;
11235 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11236 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11237 break;
11238 case PHY_SINGLE_CHANNEL_CENTERED:
11239 default:
11240 centerChn = primaryChn;
11241 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011242 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011243 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011244 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011245 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070011246 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011247 }
11248 }
11249 }
11250 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011251 return eRet;
11252}
Jeff Johnson295189b2012-06-20 16:38:30 -070011253tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11254{
11255 tANI_BOOLEAN fFound = FALSE;
11256 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011257 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11258 {
11259 if( pCipherList->encryptionType[idx] == encryptionType )
11260 {
11261 fFound = TRUE;
11262 break;
11263 }
11264 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011265 return fFound;
11266}
Jeff Johnson295189b2012-06-20 16:38:30 -070011267tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11268{
11269 tANI_BOOLEAN fFound = FALSE;
11270 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011271 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11272 {
11273 if( pAuthList->authType[idx] == authType )
11274 {
11275 fFound = TRUE;
11276 break;
11277 }
11278 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011279 return fFound;
11280}
Jeff Johnson295189b2012-06-20 16:38:30 -070011281tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11282{
11283 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11284 tCsrScanResultFilter *pScanFilter = NULL;
11285 eHalStatus status = eHAL_STATUS_SUCCESS;
11286
11287 if(pProfile1 && pProfile2)
11288 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011289 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11290 if ( NULL == pScanFilter )
11291 status = eHAL_STATUS_FAILURE;
11292 else
11293 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011294 if(HAL_STATUS_SUCCESS(status))
11295 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011296 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011297 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11298 if(HAL_STATUS_SUCCESS(status))
11299 {
11300 fCheck = eANI_BOOLEAN_FALSE;
11301 do
11302 {
11303 tANI_U32 i;
11304 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11305 {
11306 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11307 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11308 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11309 if ( fCheck ) break;
11310 }
11311 if(!fCheck)
11312 {
11313 break;
11314 }
11315 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11316 || pProfile2->BSSType != pProfile1->BSSType
11317 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11318 )
11319 {
11320 fCheck = eANI_BOOLEAN_FALSE;
11321 break;
11322 }
11323#ifdef WLAN_FEATURE_VOWIFI_11R
11324 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11325 {
11326 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11327 {
11328 fCheck = eANI_BOOLEAN_FALSE;
11329 break;
11330 }
11331 }
11332#endif
11333 //Match found
11334 fCheck = eANI_BOOLEAN_TRUE;
11335 }while(0);
11336 csrFreeScanFilter(pMac, pScanFilter);
11337 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011338 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011339 }
11340 }
11341
11342 return (fCheck);
11343}
11344
Jeff Johnson295189b2012-06-20 16:38:30 -070011345tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11346{
11347 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11348 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011349 do
11350 {
11351 //Only check for static WEP
11352 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11353 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11354 {
11355 fCheck = eANI_BOOLEAN_TRUE;
11356 break;
11357 }
11358 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11359 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11360 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11361 {
11362 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011363 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11364 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011365 {
11366 break;
11367 }
11368 }
11369 if( i == CSR_MAX_NUM_KEY)
11370 {
11371 fCheck = eANI_BOOLEAN_TRUE;
11372 }
11373 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011374 return (fCheck);
11375}
11376
Jeff Johnson295189b2012-06-20 16:38:30 -070011377//IBSS
11378
Jeff Johnson295189b2012-06-20 16:38:30 -070011379tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11380{
11381 tANI_U8 channel = 0;
11382 tANI_U32 idx;
11383 tANI_U32 idxValidChannels;
11384 tANI_BOOLEAN fFound = FALSE;
11385 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11386
11387 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11388 {
11389 channel = pMac->roam.configParam.AdHocChannel5G;
11390 if(!csrRoamIsChannelValid(pMac, channel))
11391 {
11392 channel = 0;
11393 }
11394 }
11395 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11396 {
11397 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11398 {
11399 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11400 {
11401 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11402 {
11403 fFound = TRUE;
11404 channel = csrStartIbssChannels50[ idx ];
11405 }
11406 }
11407 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011408 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11409 if (!fFound)
11410 {
11411 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11412 {
11413 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11414 {
11415 channel = csrStartIbssChannels50[ idx ];
11416 break;
11417 }
11418 }
11419 }
11420 }//if
11421
11422 return( channel );
11423}
11424
Jeff Johnson295189b2012-06-20 16:38:30 -070011425tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11426{
11427 tANI_U8 channel = 1;
11428 tANI_U32 idx;
11429 tANI_U32 idxValidChannels;
11430 tANI_BOOLEAN fFound = FALSE;
11431 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11432
11433 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11434 {
11435 channel = pMac->roam.configParam.AdHocChannel24;
11436 if(!csrRoamIsChannelValid(pMac, channel))
11437 {
11438 channel = 0;
11439 }
11440 }
11441
11442 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11443 {
11444 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11445 {
11446 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11447 {
11448 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11449 {
11450 fFound = TRUE;
11451 channel = csrStartIbssChannels24[ idx ];
11452 }
11453 }
11454 }
11455 }
11456
11457 return( channel );
11458}
11459
Jeff Johnson295189b2012-06-20 16:38:30 -070011460static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11461 tCsrRoamStartBssParams *pParam )
11462{
11463 eCsrCfgDot11Mode cfgDot11Mode;
11464 eCsrBand eBand;
11465 tANI_U8 channel = 0;
11466 tSirNwType nwType;
11467 tANI_U8 operationChannel = 0;
11468
11469 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11470 {
11471 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11472 }
11473
Jeff Johnson295189b2012-06-20 16:38:30 -070011474 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011475
Jeff Johnson295189b2012-06-20 16:38:30 -070011476 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11477 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11478 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11479 )
11480 {
11481 /* This should never happen */
11482 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011483 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011484 pProfile->csrPersona);
11485 VOS_ASSERT(0);
11486 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011487 switch( cfgDot11Mode )
11488 {
11489 case eCSR_CFG_DOT11_MODE_11G:
11490 nwType = eSIR_11G_NW_TYPE;
11491 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011492 case eCSR_CFG_DOT11_MODE_11B:
11493 nwType = eSIR_11B_NW_TYPE;
11494 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011495 case eCSR_CFG_DOT11_MODE_11A:
11496 nwType = eSIR_11A_NW_TYPE;
11497 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011498 default:
11499 case eCSR_CFG_DOT11_MODE_11N:
11500 case eCSR_CFG_DOT11_MODE_TAURUS:
11501 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11502 if(eCSR_BAND_24 == eBand)
11503 {
11504 nwType = eSIR_11G_NW_TYPE;
11505 }
11506 else
11507 {
11508 nwType = eSIR_11A_NW_TYPE;
11509 }
11510 break;
11511 }
11512
11513 pParam->extendedRateSet.numRates = 0;
11514
11515 switch ( nwType )
11516 {
11517 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011518 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011519 case eSIR_11A_NW_TYPE:
11520
11521 pParam->operationalRateSet.numRates = 8;
11522
11523 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11524 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11525 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11526 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11527 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11528 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11529 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11530 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11531
11532 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11533 {
11534 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11535 if( 0 == channel &&
11536 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11537 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11538 )
11539 {
11540 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11541 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11542 nwType = eSIR_11B_NW_TYPE;
11543 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11544 pParam->operationalRateSet.numRates = 4;
11545 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11546 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11547 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11548 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11549 }
11550 }
11551 else
11552 {
11553 channel = operationChannel;
11554 }
11555 break;
11556
11557 case eSIR_11B_NW_TYPE:
11558 pParam->operationalRateSet.numRates = 4;
11559 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11560 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11561 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11562 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011563 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11564 {
11565 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11566 }
11567 else
11568 {
11569 channel = operationChannel;
11570 }
11571
11572 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011573 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011574 /* For P2P Client and P2P GO, disable 11b rates */
11575 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11576 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11577 )
11578 {
11579 pParam->operationalRateSet.numRates = 8;
11580
11581 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11582 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11583 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11584 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11585 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11586 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11587 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11588 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11589 }
11590 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011591 {
11592 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011593 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11594 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11595 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11596 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11597
11598 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011599 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11600 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11601 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11602 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11603 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11604 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11605 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11606 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11607 }
11608
11609 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11610 {
11611 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11612 }
11613 else
11614 {
11615 channel = operationChannel;
11616 }
11617
11618 break;
11619 }
11620 pParam->operationChn = channel;
11621 pParam->sirNwType = nwType;
11622}
11623
Jeff Johnson295189b2012-06-20 16:38:30 -070011624static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11625 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11626{
11627
11628 if( pParam )
11629 {
11630 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011631 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011632 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011633 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011634
11635 if( pIes )
11636 {
11637 if(pIes->SuppRates.present)
11638 {
11639 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11640 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11641 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011642 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 -070011643 pIes->SuppRates.num_rates);
11644 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11645 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011646 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11647 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011648 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011649 if (pIes->ExtSuppRates.present)
11650 {
11651 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011652 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011653 {
11654 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11655 SIR_MAC_RATESET_EID_MAX, resetting to \
11656 SIR_MAC_RATESET_EID_MAX"),
11657 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011658 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011659 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011660 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011661 pIes->ExtSuppRates.rates,
11662 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11663 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011664 if( pIes->SSID.present )
11665 {
11666 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011667 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11668 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011669 }
11670 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011671 }
11672 else
11673 {
11674 pParam->ssId.length = 0;
11675 pParam->operationalRateSet.numRates = 0;
11676 }
11677 }
11678}
11679
Jeff Johnson295189b2012-06-20 16:38:30 -070011680static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11681{
11682 tANI_U8 MaxRate = 0;
11683 tANI_U32 i;
11684 tANI_U8 *pRate;
11685
11686 pRate = pSirRateSet->rate;
11687 for ( i = 0; i < pSirRateSet->numRates; i++ )
11688 {
11689 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11690 }
11691
11692 // Save the max rate in the connected state information...
11693
11694 // modify LastRates variable as well
11695
11696 return;
11697}
11698
Jeff Johnson295189b2012-06-20 16:38:30 -070011699eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11700 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11701{
11702 eHalStatus status = eHAL_STATUS_SUCCESS;
11703 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011704 // Set the roaming substate to 'Start BSS attempt'...
11705 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011706#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11707 //Need to figure out whether we need to log WDS???
11708 if( CSR_IS_IBSS( pProfile ) )
11709 {
11710 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011711 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11712 if(pIbssLog)
11713 {
11714 if(pBssDesc)
11715 {
11716 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011717 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011718 }
11719 else
11720 {
11721 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11722 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011723 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011724 if(pProfile->ChannelInfo.numOfChannels == 0)
11725 {
11726 pIbssLog->channelSetting = AUTO_PICK;
11727 }
11728 else
11729 {
11730 pIbssLog->channelSetting = SPECIFIED;
11731 }
11732 pIbssLog->operatingChannel = pParam->operationChn;
11733 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11734 }
11735 }
11736#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11737 //Put RSN information in for Starting BSS
11738 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11739 pParam->pRSNIE = pProfile->pRSNReqIE;
11740
Jeff Johnson295189b2012-06-20 16:38:30 -070011741 pParam->privacy = pProfile->privacy;
11742 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11743 pParam->authType = pProfile->csr80211AuthType;
11744 pParam->beaconInterval = pProfile->beaconInterval;
11745 pParam->dtimPeriod = pProfile->dtimPeriod;
11746 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11747 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11748 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11749 {
11750 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11751 {
11752 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11753 }
11754 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011755 pParam->protEnabled = pProfile->protEnabled;
11756 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11757 pParam->ht_protection = pProfile->cfg_protection;
11758 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011759
Jeff Johnson295189b2012-06-20 16:38:30 -070011760 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11761 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011762 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080011763
11764#ifdef WLAN_FEATURE_11W
11765 pParam->mfpCapable = (0 != pProfile->MFPCapable);
11766 pParam->mfpRequired = (0 != pProfile->MFPRequired);
11767#endif
11768
Jeff Johnson295189b2012-06-20 16:38:30 -070011769 // When starting an IBSS, start on the channel from the Profile.
11770 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011771 return (status);
11772}
11773
Jeff Johnson295189b2012-06-20 16:38:30 -070011774static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011775 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011776{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011777 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011778 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011779 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011780
11781 if(!pSession)
11782 {
11783 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11784 return;
11785 }
11786
Jeff Johnson295189b2012-06-20 16:38:30 -070011787 if( pBssDesc )
11788 {
11789 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11790 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11791 //The following code has to be do after that.
11792 //For WDS station, use selfMac as the self BSSID
11793 if( CSR_IS_WDS_STA( pProfile ) )
11794 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011795 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11796 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011797 }
11798 }
11799 else
11800 {
11801 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011802 //Use the first SSID
11803 if(pProfile->SSIDs.numOfSSIDs)
11804 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011805 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11806 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011807 }
11808 //For WDS station, use selfMac as the self BSSID
11809 if( CSR_IS_WDS_STA( pProfile ) )
11810 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011811 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11812 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011813 }
11814 //Use the first BSSID
11815 else if( pProfile->BSSIDs.numOfBSSIDs )
11816 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011817 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11818 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011819 }
11820 else
11821 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011822 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011823 }
11824 }
11825 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 //Set operating channel in pProfile which will be used
11827 //in csrRoamSetBssConfigCfg() to determine channel bonding
11828 //mode and will be configured in CFG later
11829 pProfile->operationChannel = Channel;
11830
11831 if(Channel == 0)
11832 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053011833 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011834 }
11835 else
11836 {
11837
11838 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011839 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011840 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011841 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011842 {
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053011843 /* TODO- SAP: HT40 Support in SAP 2.4Ghz mode is not enabled.
11844 so channel bonding in 2.4Ghz is configured as 20MHZ
11845 irrespective of the 'channelBondingMode24GHz' Parameter */
11846 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -070011847 }
11848 else
11849 {
11850 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11851 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011852 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011853 pBssConfig->cbMode = cbMode;
11854 pSession->bssParams.cbMode = cbMode;
11855 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011856 }
11857}
11858
Jeff Johnson295189b2012-06-20 16:38:30 -070011859static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11860 tANI_BOOLEAN *pfSameIbss )
11861{
11862 eHalStatus status = eHAL_STATUS_SUCCESS;
11863 tANI_BOOLEAN fSameIbss = FALSE;
11864
11865 if ( csrIsConnStateIbss( pMac, sessionId ) )
11866 {
11867 // Check if any profile parameter has changed ? If any profile parameter
11868 // has changed then stop old BSS and start a new one with new parameters
11869 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11870 {
11871 fSameIbss = TRUE;
11872 }
11873 else
11874 {
11875 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11876 }
11877 }
11878 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11879 {
11880 // Disassociate from the connected Infrastructure network...
11881 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11882 }
11883 else
11884 {
11885 tBssConfigParam *pBssConfig;
11886
Kiet Lam64c1b492013-07-12 13:56:44 +053011887 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11888 if ( NULL == pBssConfig )
11889 status = eHAL_STATUS_FAILURE;
11890 else
11891 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011892 if(HAL_STATUS_SUCCESS(status))
11893 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011894 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011895 // there is no Bss description before we start an IBSS so we need to adopt
11896 // all Bss configuration parameters from the Profile.
11897 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11898 if(HAL_STATUS_SUCCESS(status))
11899 {
11900 //save dotMode
11901 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11902 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011903 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011904 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11905 NULL, pBssConfig,
11906 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011907 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011908
11909 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011910 }//Allocate memory
11911 }
11912
11913 if(pfSameIbss)
11914 {
11915 *pfSameIbss = fSameIbss;
11916 }
11917 return( status );
11918}
11919
Jeff Johnson295189b2012-06-20 16:38:30 -070011920static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11921 tSirSmeNewBssInfo *pNewBss )
11922{
11923 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011924
11925 if(!pSession)
11926 {
11927 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11928 return;
11929 }
11930
Jeff Johnson295189b2012-06-20 16:38:30 -070011931 if( pNewBss )
11932 {
11933 // Set the operating channel.
11934 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11935 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011936 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11937 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011938 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011939 return;
11940}
11941
Jeff Johnson295189b2012-06-20 16:38:30 -070011942#ifdef FEATURE_WLAN_WAPI
11943eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11944 tANI_U32 numItems )
11945{
11946 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11947 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011948 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11949 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011950 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011951 return status;
11952 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011953 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011954 pSession = CSR_GET_SESSION( pMac, sessionId );
11955 if(numItems <= CSR_MAX_BKID_ALLOWED)
11956 {
11957 status = eHAL_STATUS_SUCCESS;
11958 //numItems may be 0 to clear the cache
11959 pSession->NumBkidCache = (tANI_U16)numItems;
11960 if(numItems && pBKIDCache)
11961 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011962 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
11963 sizeof(tBkidCacheInfo) * numItems);
11964 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011965 }
11966 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011967 return (status);
11968}
Jeff Johnson295189b2012-06-20 16:38:30 -070011969eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11970 tBkidCacheInfo *pBkidCache)
11971{
11972 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11973 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011974 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11975 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011976 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011977 return status;
11978 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011979 pSession = CSR_GET_SESSION( pMac, sessionId );
11980 if(pNum && pBkidCache)
11981 {
11982 if(pSession->NumBkidCache == 0)
11983 {
11984 *pNum = 0;
11985 status = eHAL_STATUS_SUCCESS;
11986 }
11987 else if(*pNum >= pSession->NumBkidCache)
11988 {
11989 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11990 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011991 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 -070011992 pSession->NumBkidCache);
11993 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11994 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011995 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
11996 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011997 *pNum = pSession->NumBkidCache;
11998 status = eHAL_STATUS_SUCCESS;
11999 }
12000 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012001 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012002}
Jeff Johnson295189b2012-06-20 16:38:30 -070012003tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12004{
12005 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012006}
12007#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012008eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
12009 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
12010{
12011 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12012 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012013
12014 if(!pSession)
12015 {
12016 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12017 return eHAL_STATUS_FAILURE;
12018 }
12019
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012020 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012021 if(numItems <= CSR_MAX_PMKID_ALLOWED)
12022 {
12023#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12024 {
12025 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012026 vos_mem_set(&secEvent,
12027 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012028 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12029 secEvent.encryptionModeMulticast =
12030 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12031 secEvent.encryptionModeUnicast =
12032 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012033 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012034 secEvent.authMode =
12035 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12036 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12037 }
12038#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012039 status = eHAL_STATUS_SUCCESS;
12040 //numItems may be 0 to clear the cache
12041 pSession->NumPmkidCache = (tANI_U16)numItems;
12042 if(numItems && pPMKIDCache)
12043 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012044 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12045 sizeof(tPmkidCacheInfo) * numItems);
12046 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012047 }
12048 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012049 return (status);
12050}
12051
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012052eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
12053 tANI_U8 *pBSSId )
12054{
12055 eHalStatus status = eHAL_STATUS_FAILURE;
12056 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12057 tANI_BOOLEAN fMatchFound = FALSE;
12058 tANI_U32 Index;
12059 if(!pSession)
12060 {
12061 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12062 return eHAL_STATUS_FAILURE;
12063 }
12064 do
12065 {
12066 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
12067 {
Arif Hussaina7c8e412013-11-20 11:06:42 -080012068 smsLog(pMac, LOGW, "Delete PMKID for "
12069 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Kiet Lamf2f201e2013-11-16 21:24:16 +053012070 if( vos_mem_compare( pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012071 {
12072 fMatchFound = TRUE;
12073 break;
12074 }
12075 }
12076 if( !fMatchFound ) break;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012077 vos_mem_set(pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid), 0);
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012078 status = eHAL_STATUS_SUCCESS;
12079 }
12080 while( 0 );
12081 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
12082 fMatchFound, status);
12083 return status;
12084}
Jeff Johnson295189b2012-06-20 16:38:30 -070012085tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12086{
12087 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12088}
12089
Jeff Johnson295189b2012-06-20 16:38:30 -070012090eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12091{
12092 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12093 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012094
12095 if(!pSession)
12096 {
12097 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12098 return eHAL_STATUS_FAILURE;
12099 }
12100
Jeff Johnson295189b2012-06-20 16:38:30 -070012101 if(pNum && pPmkidCache)
12102 {
12103 if(pSession->NumPmkidCache == 0)
12104 {
12105 *pNum = 0;
12106 status = eHAL_STATUS_SUCCESS;
12107 }
12108 else if(*pNum >= pSession->NumPmkidCache)
12109 {
12110 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12111 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012112 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 -070012113 pSession->NumPmkidCache);
12114 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12115 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012116 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
12117 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012118 *pNum = pSession->NumPmkidCache;
12119 status = eHAL_STATUS_SUCCESS;
12120 }
12121 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012122 return (status);
12123}
12124
Jeff Johnson295189b2012-06-20 16:38:30 -070012125eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12126{
12127 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12128 tANI_U32 len;
12129 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012130
12131 if(!pSession)
12132 {
12133 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12134 return eHAL_STATUS_FAILURE;
12135 }
12136
Jeff Johnson295189b2012-06-20 16:38:30 -070012137 if(pLen)
12138 {
12139 len = *pLen;
12140 *pLen = pSession->nWpaRsnReqIeLength;
12141 if(pBuf)
12142 {
12143 if(len >= pSession->nWpaRsnReqIeLength)
12144 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012145 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12146 pSession->nWpaRsnReqIeLength);
12147 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012148 }
12149 }
12150 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012151 return (status);
12152}
12153
Jeff Johnson295189b2012-06-20 16:38:30 -070012154eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12155{
12156 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12157 tANI_U32 len;
12158 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012159
12160 if(!pSession)
12161 {
12162 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12163 return eHAL_STATUS_FAILURE;
12164 }
12165
Jeff Johnson295189b2012-06-20 16:38:30 -070012166 if(pLen)
12167 {
12168 len = *pLen;
12169 *pLen = pSession->nWpaRsnRspIeLength;
12170 if(pBuf)
12171 {
12172 if(len >= pSession->nWpaRsnRspIeLength)
12173 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012174 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12175 pSession->nWpaRsnRspIeLength);
12176 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012177 }
12178 }
12179 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012180 return (status);
12181}
Jeff Johnson295189b2012-06-20 16:38:30 -070012182#ifdef FEATURE_WLAN_WAPI
12183eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12184{
12185 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12186 tANI_U32 len;
12187 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012188
12189 if(!pSession)
12190 {
12191 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12192 return eHAL_STATUS_FAILURE;
12193 }
12194
Jeff Johnson295189b2012-06-20 16:38:30 -070012195 if(pLen)
12196 {
12197 len = *pLen;
12198 *pLen = pSession->nWapiReqIeLength;
12199 if(pBuf)
12200 {
12201 if(len >= pSession->nWapiReqIeLength)
12202 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012203 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12204 pSession->nWapiReqIeLength);
12205 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012206 }
12207 }
12208 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012209 return (status);
12210}
Jeff Johnson295189b2012-06-20 16:38:30 -070012211eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12212{
12213 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12214 tANI_U32 len;
12215 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012216
12217 if(!pSession)
12218 {
12219 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12220 return eHAL_STATUS_FAILURE;
12221 }
12222
Jeff Johnson295189b2012-06-20 16:38:30 -070012223 if(pLen)
12224 {
12225 len = *pLen;
12226 *pLen = pSession->nWapiRspIeLength;
12227 if(pBuf)
12228 {
12229 if(len >= pSession->nWapiRspIeLength)
12230 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012231 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12232 pSession->nWapiRspIeLength);
12233 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012234 }
12235 }
12236 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012237 return (status);
12238}
12239#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012240eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12241{
12242 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12243 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012244
12245 if(!pSession)
12246 {
12247 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12248 return (retStatus);
12249 }
12250
Jeff Johnson295189b2012-06-20 16:38:30 -070012251 if(CSR_IS_ROAMING(pSession))
12252 {
12253 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12254 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12255 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012256 return (retStatus);
12257}
12258
Jeff Johnson295189b2012-06-20 16:38:30 -070012259//This function remove the connected BSS from te cached scan result
12260eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12261 tCsrRoamConnectedProfile *pConnProfile)
12262{
12263 eHalStatus status = eHAL_STATUS_FAILURE;
12264 tCsrScanResultFilter *pScanFilter = NULL;
12265 tListElem *pEntry;
12266 tCsrScanResult *pResult;
12267 tDot11fBeaconIEs *pIes;
12268 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012269 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12270 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12271 {
12272 do
12273 {
12274 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012275 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12276 if ( NULL == pScanFilter )
12277 status = eHAL_STATUS_FAILURE;
12278 else
12279 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012280 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012281 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12282 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12283 if ( NULL == pScanFilter->BSSIDs.bssid )
12284 status = eHAL_STATUS_FAILURE;
12285 else
12286 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012287 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012288 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12289 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012290 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12291 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12292 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012293 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12294 if ( NULL == pScanFilter->SSIDs.SSIDList )
12295 status = eHAL_STATUS_FAILURE;
12296 else
12297 status = eHAL_STATUS_SUCCESS;
12298 if (!HAL_STATUS_SUCCESS(status)) break;
12299 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12300 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012301 }
12302 pScanFilter->authType.numEntries = 1;
12303 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12304 pScanFilter->BSSType = pConnProfile->BSSType;
12305 pScanFilter->EncryptionType.numEntries = 1;
12306 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12307 pScanFilter->mcEncryptionType.numEntries = 1;
12308 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12309 //We ignore the channel for now, BSSID should be enough
12310 pScanFilter->ChannelInfo.numOfChannels = 0;
12311 //Also ignore the following fields
12312 pScanFilter->uapsd_mask = 0;
12313 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012314 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012315 pScanFilter->countryCode[0] = 0;
12316 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012317 csrLLLock(&pMac->scan.scanResultList);
12318 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12319 while( pEntry )
12320 {
12321 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12322 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12323 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12324 pScanFilter, NULL, NULL, NULL, &pIes);
12325 //Release the IEs allocated by csrMatchBSS is needed
12326 if( !pResult->Result.pvIes )
12327 {
12328 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012329 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012330 }
12331 if(fMatch)
12332 {
12333 //We found the one
12334 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12335 {
12336 //Free the memory
12337 csrFreeScanResultEntry( pMac, pResult );
12338 }
12339 break;
12340 }
12341 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12342 }//while
12343 csrLLUnlock(&pMac->scan.scanResultList);
12344 }while(0);
12345 if(pScanFilter)
12346 {
12347 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012348 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012349 }
12350 }
12351 return (status);
12352}
12353
Jeff Johnson295189b2012-06-20 16:38:30 -070012354//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012355eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12356{
12357 eHalStatus status = eHAL_STATUS_SUCCESS;
12358 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012359 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12360 {
12361 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12362 {
12363 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12364 {
12365 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012366 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012367 status = eHAL_STATUS_CSR_WRONG_STATE;
12368 break;
12369 }
12370 if( csrIsConnStateInfra( pMac, sessionId ) )
12371 {
12372 if( chnId &&
12373 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12374 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012375 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012376 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12377 status = eHAL_STATUS_CSR_WRONG_STATE;
12378 break;
12379 }
12380 }
12381 }
12382 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012383 return ( status );
12384}
12385
Jeff Johnson295189b2012-06-20 16:38:30 -070012386static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12387{
12388 eHalStatus status = eHAL_STATUS_SUCCESS;
12389 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12390 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012391
12392 if(!pSession)
12393 {
12394 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12395 return eHAL_STATUS_FAILURE;
12396 }
12397
Jeff Johnson295189b2012-06-20 16:38:30 -070012398 if ( csrIsConnStateIbss( pMac, sessionId ) )
12399 {
12400 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12401 }
12402 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12403 {
12404 // Disassociate from the connected Infrastructure network...
12405 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12406 }
12407 else
12408 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012409 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12410 //Otherwise we need to add code to handle the
12411 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12412 //send stop_bss to PE, before we can continue.
12413 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012414 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012415 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012416 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12417 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012418 // there is no Bss description before we start an WDS so we need
12419 // to adopt all Bss configuration parameters from the Profile.
12420 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12421 if(HAL_STATUS_SUCCESS(status))
12422 {
12423 //Save profile for late use
12424 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012425 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12426 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012427 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012428 vos_mem_set(pSession->pCurRoamProfile,
12429 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012430 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12431 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012432 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012433 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012434 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12435 NULL, &bssConfig,
12436 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012437 }
12438 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012439
Jeff Johnson295189b2012-06-20 16:38:30 -070012440 return( status );
12441}
12442
Jeff Johnson295189b2012-06-20 16:38:30 -070012443////////////////////Mail box
12444
Jeff Johnson295189b2012-06-20 16:38:30 -070012445//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12446//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012447static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12448 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012449 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12450{
12451 tCsrChannelSet channelGroup;
12452 tSirMacCapabilityInfo *pAP_capabilityInfo;
12453 tAniBool fTmp;
12454 tANI_BOOLEAN found = FALSE;
12455 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012456 tANI_S8 pwrLimit = 0;
12457 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012458 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12459 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12460 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12461 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012462 // 802.11h
12463 //We can do this because it is in HOST CPU order for now.
12464 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012465 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12466 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12467 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012468 fTmp = (tAniBool)pal_cpu_to_be32(1);
12469 }
12470 else
12471 fTmp = (tAniBool)0;
12472
12473 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012474 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012475 pBuf += sizeof(tAniBool);
12476 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012477 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012478 // This is required for 11k test VoWiFi Ent: Test 2.
12479 // We need the power capabilities for Assoc Req.
12480 // This macro is provided by the halPhyCfg.h. We pick our
12481 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012482 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12483 if (0 != pwrLimit)
12484 {
12485 *pBuf++ = pwrLimit;
12486 }
12487 else
12488 {
12489 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12490 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012491 size = sizeof(pMac->roam.validChannelList);
12492 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12493 {
12494 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12495 for ( i = 0; i < size; i++)
12496 {
12497 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12498
12499 }
12500 }
12501 else
12502 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012503 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012504 *pBuf++ = 0; //tSirSupChnl->numChnl
12505 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012506 //Check whether it is ok to enter UAPSD
12507#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12508 if( btcIsReadyForUapsd(pMac) )
12509#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12510 {
12511 *pBuf++ = uapsdMask;
12512 }
12513#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12514 else
12515 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012516 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012517 *pBuf++ = 0;
12518 }
12519#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12520
Jeff Johnson295189b2012-06-20 16:38:30 -070012521 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012522 vos_mem_copy(pBuf, pBssDescription,
12523 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012524 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12525}
12526
Jeff Johnson295189b2012-06-20 16:38:30 -070012527/*
12528 * The communication between HDD and LIM is thru mailbox (MB).
12529 * Both sides will access the data structure "tSirSmeJoinReq".
12530 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12531 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12532 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12533 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12534 */
12535eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012536 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012537{
12538 eHalStatus status = eHAL_STATUS_SUCCESS;
12539 tSirSmeJoinReq *pMsg;
12540 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012541 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012542 tANI_U16 msgLen, wTmp, ieLen;
12543 tSirMacRateSet OpRateSet;
12544 tSirMacRateSet ExRateSet;
12545 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12546 tANI_U32 dwTmp;
12547 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012548 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012549
12550 if(!pSession)
12551 {
12552 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12553 return eHAL_STATUS_FAILURE;
12554 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012555 /* To satisfy klockworks */
12556 if (NULL == pBssDescription)
12557 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012558 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012559 return eHAL_STATUS_FAILURE;
12560 }
12561
Jeff Johnson295189b2012-06-20 16:38:30 -070012562 do {
12563 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12564 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012565 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012566 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12567 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12568 // IE fields, but the length field in the bssDescription needs to be interpreted to
12569 // determine length of the IE fields.
12570 //
12571 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12572 // add in the length from the bssDescription (then add the size of the 'length' field
12573 // itself because that is NOT included in the length field).
12574 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12575 pBssDescription->length + sizeof( pBssDescription->length ) +
12576 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 +053012577 pMsg = vos_mem_malloc(msgLen);
12578 if (NULL == pMsg)
12579 status = eHAL_STATUS_FAILURE;
12580 else
12581 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012582 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012583 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012584 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012585 pMsg->length = pal_cpu_to_be16(msgLen);
12586 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012587 // sessionId
12588 *pBuf = (tANI_U8)sessionId;
12589 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012590 // transactionId
12591 *pBuf = 0;
12592 *( pBuf + 1 ) = 0;
12593 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012594 // ssId
12595 if( pIes->SSID.present && pIes->SSID.num_ssid )
12596 {
12597 // ssId len
12598 *pBuf = pIes->SSID.num_ssid;
12599 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012600 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012601 pBuf += pIes->SSID.num_ssid;
12602 }
12603 else
12604 {
12605 *pBuf = 0;
12606 pBuf++;
12607 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012608 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012609 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12610 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012611 pBuf += sizeof(tSirMacAddr);
12612 // bsstype
12613 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12614 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012615 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012616 pBuf += sizeof(tSirBssType);
12617 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012618 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12619 if (pBssDescription->channelId <= 14 &&
12620 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12621 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12622 {
12623 //Need to disable VHT operation in 2.4 GHz band
12624 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12625 }
12626 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012627 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012628 //Persona
12629 *pBuf = (tANI_U8)pProfile->csrPersona;
12630 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012631 //CBMode
12632 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12633 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012634
12635 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012636 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12637
Jeff Johnson295189b2012-06-20 16:38:30 -070012638 // uapsdPerAcBitmask
12639 *pBuf = pProfile->uapsd_mask;
12640 pBuf++;
12641
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012642
12643
Jeff Johnson295189b2012-06-20 16:38:30 -070012644 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012645 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012646 {
12647 // OperationalRateSet
12648 if (OpRateSet.numRates) {
12649 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012650 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012651 pBuf += OpRateSet.numRates;
12652 } else *pBuf++ = 0;
12653 // ExtendedRateSet
12654 if (ExRateSet.numRates) {
12655 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012656 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012657 pBuf += ExRateSet.numRates;
12658 } else *pBuf++ = 0;
12659 }
12660 else
12661 {
12662 *pBuf++ = 0;
12663 *pBuf++ = 0;
12664 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012665 // rsnIE
12666 if ( csrIsProfileWpa( pProfile ) )
12667 {
12668 // Insert the Wpa IE into the join request
12669 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12670 (tCsrWpaIe *)( wpaRsnIE ) );
12671 }
12672 else if( csrIsProfileRSN( pProfile ) )
12673 {
12674 // Insert the RSN IE into the join request
12675 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12676 (tCsrRSNIe *)( wpaRsnIE ) );
12677 }
12678#ifdef FEATURE_WLAN_WAPI
12679 else if( csrIsProfileWapi( pProfile ) )
12680 {
12681 // Insert the WAPI IE into the join request
12682 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12683 (tCsrWapiIe *)( wpaRsnIE ) );
12684 }
12685#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012686 else
12687 {
12688 ieLen = 0;
12689 }
12690 //remember the IE for future use
12691 if( ieLen )
12692 {
12693 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12694 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012695 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 -070012696 ieLen = DOT11F_IE_RSN_MAX_LEN;
12697 }
12698#ifdef FEATURE_WLAN_WAPI
12699 if( csrIsProfileWapi( pProfile ) )
12700 {
12701 //Check whether we need to allocate more memory
12702 if(ieLen > pSession->nWapiReqIeLength)
12703 {
12704 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12705 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012706 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012707 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012708 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12709 if (NULL == pSession->pWapiReqIE)
12710 status = eHAL_STATUS_FAILURE;
12711 else
12712 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012713 if(!HAL_STATUS_SUCCESS(status)) break;
12714 }
12715 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012716 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012717 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012718 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012719 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012720 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012721 pBuf += ieLen;
12722 }
12723 else//should be WPA/WPA2 otherwise
12724#endif /* FEATURE_WLAN_WAPI */
12725 {
12726 //Check whether we need to allocate more memory
12727 if(ieLen > pSession->nWpaRsnReqIeLength)
12728 {
12729 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12730 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012731 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012732 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012733 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12734 if (NULL == pSession->pWpaRsnReqIE)
12735 status = eHAL_STATUS_FAILURE;
12736 else
12737 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012738 if(!HAL_STATUS_SUCCESS(status)) break;
12739 }
12740 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012741 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012742 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012743 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012744 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012745 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012746 pBuf += ieLen;
12747 }
12748 }
12749 else
12750 {
12751 //free whatever old info
12752 pSession->nWpaRsnReqIeLength = 0;
12753 if(pSession->pWpaRsnReqIE)
12754 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012755 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012756 pSession->pWpaRsnReqIE = NULL;
12757 }
12758#ifdef FEATURE_WLAN_WAPI
12759 pSession->nWapiReqIeLength = 0;
12760 if(pSession->pWapiReqIE)
12761 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012762 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012763 pSession->pWapiReqIE = NULL;
12764 }
12765#endif /* FEATURE_WLAN_WAPI */
12766 //length is two bytes
12767 *pBuf = 0;
12768 *(pBuf + 1) = 0;
12769 pBuf += 2;
12770 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012771#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012772 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012773 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012774 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012775 //length is two bytes
12776 *pBuf = 0;
12777 *(pBuf + 1) = 0;
12778 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012779 }
12780 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012781 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012782 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012783 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012784 {
12785 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012786#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012787 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080012788 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012789 pSession->suppCckmIeInfo.cckmIe, ieLen);
12790#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012791 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012792 pSession,
12793 pProfile,
12794 pBssDescription,
12795 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012796 pSession->nWpaRsnReqIeLength,
12797 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012798#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012799 }
12800 else
12801 {
12802 ieLen = 0;
12803 }
12804 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12805 if( ieLen )
12806 {
12807 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12808 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012809 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012810 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012811 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012812 pBuf += ieLen;
12813 }
12814 else
12815 {
12816 //Indicate you have no CCKM IE
12817 //length is two bytes
12818 *pBuf = 0;
12819 *(pBuf + 1) = 0;
12820 pBuf += 2;
12821 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012822 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012823#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070012824 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053012825 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070012826 {
12827 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012828 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012829 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012830 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012831 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012832 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012833 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053012834 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012835 pBuf += ieLen;
12836 }
12837 else
12838 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053012839 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012840 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012841 *pBuf = 0;
12842 *(pBuf + 1) = 0;
12843 pBuf += 2;
12844 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012845 // addIEAssoc
12846 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12847 {
12848 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012849 if(ieLen > pSession->nAddIEAssocLength)
12850 {
12851 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012852 {
12853 vos_mem_free(pSession->pAddIEAssoc);
12854 }
12855 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12856 if (NULL == pSession->pAddIEAssoc)
12857 status = eHAL_STATUS_FAILURE;
12858 else
12859 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012860 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012861 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012862 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012863 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012864 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012865 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012866 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012867 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012868 pBuf += ieLen;
12869 }
12870 else
12871 {
12872 pSession->nAddIEAssocLength = 0;
12873 if(pSession->pAddIEAssoc)
12874 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012875 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012876 pSession->pAddIEAssoc = NULL;
12877 }
12878 *pBuf = 0;
12879 *(pBuf + 1) = 0;
12880 pBuf += 2;
12881 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012882
12883 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012884 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012885 //Unmask any AC in reassoc that is ACM-set
12886 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12887 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012888 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012889 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12890 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012891#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012892 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012893#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012894 }
12895 else
12896 {
12897 uapsd_mask = 0;
12898 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012899 }
12900 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012901
Jeff Johnson295189b2012-06-20 16:38:30 -070012902 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012903 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012904 pBuf += sizeof(tANI_U32);
12905
Jeff Johnson295189b2012-06-20 16:38:30 -070012906 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012907 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012908 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012909#ifdef WLAN_FEATURE_11W
12910 //MgmtEncryption
12911 if (pProfile->MFPEnabled)
12912 {
12913 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12914 }
12915 else
12916 {
12917 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12918 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012919 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012920 pBuf += sizeof(tANI_U32);
12921#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012922#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012923 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012924 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012925#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012926 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012927 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012928#endif
12929 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012930 {
12931 // is11Rconnection;
12932 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012933 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012934 pBuf += sizeof(tAniBool);
12935 }
12936 else
12937 {
12938 // is11Rconnection;
12939 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012940 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012941 pBuf += sizeof(tAniBool);
12942 }
12943#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012944#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012945
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012946 // isESEFeatureIniEnabled
12947 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012948 {
12949 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012950 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012951 pBuf += sizeof(tAniBool);
12952 }
12953 else
12954 {
12955 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080012956 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012957 pBuf += sizeof(tAniBool);
12958 }
12959
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012960 /* A profile can not be both ESE and 11R. But an 802.11R AP
12961 * may be advertising support for ESE as well. So if we are
12962 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012963 * If we are associating explictly 11R only then we will get
12964 * 11R.
12965 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012966 if ((csrIsProfileESE(pProfile) ||
12967 ((pIes->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +053012968 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012969 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012970 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012971 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012972 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012973 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012974 pBuf += sizeof(tAniBool);
12975 }
12976 else
12977 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012978 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012979 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012980 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012981 pBuf += sizeof(tAniBool);
12982 }
12983
12984 if (eWNI_SME_JOIN_REQ == messageType)
12985 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012986 tESETspecInfo eseTspec;
12987 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012988 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012989 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
12990 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
12991 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012992 }
12993 else if (eWNI_SME_REASSOC_REQ == messageType)
12994 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012995 if ((csrIsProfileESE(pProfile) ||
12996 ((pIes->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +053012997 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012998 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012999 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013000 tESETspecInfo eseTspec;
13001 // ESE Tspec information
13002 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13003 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13004 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013005 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013006 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013007 if (eseTspec.numTspecs) {
13008 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13009 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013010 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013011 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013012 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013013 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013014 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013015 tESETspecInfo eseTspec;
13016 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013017 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013018 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13019 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13020 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013021 }
13022 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013023#endif // FEATURE_WLAN_ESE
13024#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013025 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013026 if (pMac->roam.configParam.isFastTransitionEnabled
13027#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013028 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013029#endif
13030 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013031 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013032 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013033 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013034 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013035 }
13036 else
13037 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013038 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013039 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013040 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013041 }
13042#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013043#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013044 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013045 {
13046 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013047 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013048 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013049 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013050 }
13051 else
13052 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013053 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013054 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013055 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013056 }
13057#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013058
13059 // txLdpcIniFeatureEnabled
13060 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13061 pBuf++;
13062
Kiran4a17ebe2013-01-31 10:43:43 -080013063 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13064 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13065 {
13066 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13067 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13068 csrApplyPower2Current(pMac);
13069 }
13070
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013071#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013072 // txBFIniFeatureEnabled
13073 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13074 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013075
13076 // txBFCsnValue
13077 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13078 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013079#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013080 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13081 pBuf++;
13082
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013083 // WME
13084 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13085 {
13086 //WME enabled
13087 dwTmp = pal_cpu_to_be32(TRUE);
13088 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13089 pBuf += sizeof(tAniBool);
13090 }
13091 else
13092 {
13093 dwTmp = pal_cpu_to_be32(FALSE);
13094 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13095 pBuf += sizeof(tAniBool);
13096 }
13097
13098 // QOS
13099 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13100 {
13101 //QOS enabled
13102 dwTmp = pal_cpu_to_be32(TRUE);
13103 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13104 pBuf += sizeof(tAniBool);
13105 }
13106 else
13107 {
13108 dwTmp = pal_cpu_to_be32(FALSE);
13109 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13110 pBuf += sizeof(tAniBool);
13111 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013112 //BssDesc
13113 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13114 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013115
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013116 status = palSendMBMessage(pMac->hHdd, pMsg );
13117 if(!HAL_STATUS_SUCCESS(status))
13118 {
13119 break;
13120 }
13121 else
13122 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013123#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013124 if (eWNI_SME_JOIN_REQ == messageType)
13125 {
13126 //Tush-QoS: notify QoS module that join happening
13127 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13128 }
13129 else if (eWNI_SME_REASSOC_REQ == messageType)
13130 {
13131 //Tush-QoS: notify QoS module that reassoc happening
13132 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13133 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013134#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013135 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013136 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013137 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013138}
13139
Jeff Johnson295189b2012-06-20 16:38:30 -070013140//
13141eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13142{
13143 eHalStatus status = eHAL_STATUS_SUCCESS;
13144 tSirSmeDisassocReq *pMsg;
13145 tANI_U8 *pBuf;
13146 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013147 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13148 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13149 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013150 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013151 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13152 if (NULL == pMsg)
13153 status = eHAL_STATUS_FAILURE;
13154 else
13155 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013157 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013158 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13159 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013160 pBuf = &pMsg->sessionId;
13161 // sessionId
13162 *pBuf++ = (tANI_U8)sessionId;
13163 // transactionId
13164 *pBuf = 0;
13165 *( pBuf + 1 ) = 0;
13166 pBuf += sizeof(tANI_U16);
13167
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013168 if ( (pSession->pCurRoamProfile != NULL) &&
13169 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13170 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013171 {
13172 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013173 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13174 sizeof( tSirMacAddr ));
13175 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013176 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013177 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013178 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13179 //perMacAddr is passed as bssId for softAP
13180 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013181 pBuf = pBuf + sizeof ( tSirMacAddr );
13182 }
13183 else
13184 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013185 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013186 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13187 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013188 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013189 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13190 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013191 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013192 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013193 if(!HAL_STATUS_SUCCESS(status))
13194 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013195 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013196 break;
13197 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013198 // reasonCode
13199 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013200 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13201 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013202 if(!HAL_STATUS_SUCCESS(status))
13203 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013204 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013205 break;
13206 }
13207 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013208 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13209 Here we should not send the disassoc over the air to the AP */
13210 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13211#ifdef WLAN_FEATURE_VOWIFI_11R
13212 && csrRoamIs11rAssoc(pMac)
13213#endif
13214 )
13215 {
13216 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13217 }
13218 pBuf += sizeof(tANI_U8);
13219 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013220 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013221 return( status );
13222}
Jeff Johnson295189b2012-06-20 16:38:30 -070013223eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13224{
13225 eHalStatus status = eHAL_STATUS_SUCCESS;
13226 tSirSmeTkipCntrMeasReq *pMsg;
13227 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013228 do
13229 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013230 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13231 if ( NULL == pMsg )
13232 status = eHAL_STATUS_FAILURE;
13233 else
13234 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013235 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013236 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13238 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013239 pBuf = &pMsg->sessionId;
13240 // sessionId
13241 *pBuf++ = (tANI_U8)sessionId;
13242 // transactionId
13243 *pBuf = 0;
13244 *( pBuf + 1 ) = 0;
13245 pBuf += sizeof(tANI_U16);
13246 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013247 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13248 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013249 pBuf = pBuf + sizeof ( tSirMacAddr );
13250 // bEnable
13251 *pBuf = (tANI_BOOLEAN)bEnable;
13252 if(!HAL_STATUS_SUCCESS(status))
13253 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013254 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013255 break;
13256 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013257 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
13262csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13263 VOS_MODULE_ID modId, tSirMacAddr bssId,
13264 void *pUsrContext, void *pfnSapEventCallback,
13265 tANI_U8 *pAssocStasBuf )
13266{
13267 eHalStatus status = eHAL_STATUS_SUCCESS;
13268 tSirSmeGetAssocSTAsReq *pMsg;
13269 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13270 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013271 do
13272 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013273 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13274 if ( NULL == pMsg )
13275 status = eHAL_STATUS_FAILURE;
13276 else
13277 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013278 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013279 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013280 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013281 pBuf = (tANI_U8 *)&pMsg->bssId;
13282 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013283 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013284 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013285 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013286 // modId
13287 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013288 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013289 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013290 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013291 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13292 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013293 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013294 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13295 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013296 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013297 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13298 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013299 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013300 status = palSendMBMessage( pMac->hHdd, pMsg );
13301 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013302 return( status );
13303 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013304eHalStatus
13305csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13306 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13307 {
13308 eHalStatus status = eHAL_STATUS_SUCCESS;
13309 tSirSmeGetWPSPBCSessionsReq *pMsg;
13310 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013311
Jeff Johnson295189b2012-06-20 16:38:30 -070013312 do
13313 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013314 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13315 if ( NULL == pMsg )
13316 status = eHAL_STATUS_FAILURE;
13317 else
13318 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013319 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013320 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013321 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013322 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013323 VOS_ASSERT(pBuf);
13324
Jeff Johnson295189b2012-06-20 16:38:30 -070013325 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013326 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013327 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13328 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013329 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013330 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13331 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013332 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013333 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013334 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013335 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013336 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013337 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013339 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013340 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013341 return( status );
13342}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013343
13344eHalStatus
13345csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13346{
13347 tpSirChangeBIParams pMsg;
13348 tANI_U16 len = 0;
13349 eHalStatus status = eHAL_STATUS_SUCCESS;
13350 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13351
13352 if(!pSession)
13353 {
13354 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13355 return eHAL_STATUS_FAILURE;
13356 }
13357
13358 //NO need to update the Beacon Params if update beacon parameter flag is not set
13359 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13360 return eHAL_STATUS_SUCCESS;
13361
13362 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13363
13364 /* Create the message and send to lim */
13365 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013366 pMsg = vos_mem_malloc(len);
13367 if ( NULL == pMsg )
13368 status = eHAL_STATUS_FAILURE;
13369 else
13370 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013371 if(HAL_STATUS_SUCCESS(status))
13372 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013373 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013374 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13375 pMsg->length = len;
13376
13377 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013378 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13379 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013380 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13381 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013382 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013383 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013384 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13385 status = palSendMBMessage(pMac->hHdd, pMsg);
13386 }
13387 return status;
13388}
13389
Jeff Johnson295189b2012-06-20 16:38:30 -070013390eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13391{
13392 eHalStatus status = eHAL_STATUS_SUCCESS;
13393 tSirSmeDeauthReq *pMsg;
13394 tANI_U8 *pBuf;
13395 tANI_U16 wTmp;
13396 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13397 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13398 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013399 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013400 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13401 if ( NULL == pMsg )
13402 status = eHAL_STATUS_FAILURE;
13403 else
13404 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013405 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013406 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013407 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13408 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13409 //sessionId
13410 pBuf = &pMsg->sessionId;
13411 *pBuf++ = (tANI_U8)sessionId;
13412
13413 //tansactionId
13414 *pBuf = 0;
13415 *(pBuf + 1 ) = 0;
13416 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013417 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013418 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013419 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13420 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013421 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13422 sizeof( pMsg->peerMacAddr ) );
13423 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013424 pBuf = pBuf + sizeof(tSirMacAddr);
13425 }
13426 else
13427 {
13428 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013429 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13430 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013431 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013432 }
13433 if(!HAL_STATUS_SUCCESS(status))
13434 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013435 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013436 break;
13437 }
13438 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013439 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13440 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013441 pBuf = pBuf + sizeof(tSirMacAddr);
13442 if(!HAL_STATUS_SUCCESS(status))
13443 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013444 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013445 break;
13446 }
13447 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013448 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13449 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013450 if(!HAL_STATUS_SUCCESS(status))
13451 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013452 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013453 break;
13454 }
13455 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013456 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013457 return( status );
13458}
13459
Jeff Johnson295189b2012-06-20 16:38:30 -070013460eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13461{
13462 eHalStatus status = eHAL_STATUS_SUCCESS;
13463 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013464 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013465 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13466 if ( NULL == pMsg )
13467 status = eHAL_STATUS_FAILURE;
13468 else
13469 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013470 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013471 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013472 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13473 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13474 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013475 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13476 sizeof(pMsg->peerMacAddr));
13477 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013478 if(!HAL_STATUS_SUCCESS(status))
13479 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013480 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 break;
13482 }
13483//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013484 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13485 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013486 if(!HAL_STATUS_SUCCESS(status))
13487 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013488 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013489 break;
13490 }
13491//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013493 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013494 return( status );
13495}
13496
Jeff Johnson295189b2012-06-20 16:38:30 -070013497eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13498{
13499 eHalStatus status = eHAL_STATUS_SUCCESS;
13500 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013501 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013502 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13503 if ( NULL == pMsg )
13504 status = eHAL_STATUS_FAILURE;
13505 else
13506 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013507 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013508 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013509 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13510 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13511 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013512 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13513 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013514 if(!HAL_STATUS_SUCCESS(status))
13515 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013516 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013517 break;
13518 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013519 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13520 sizeof(pMsg->peerMacAddr));
13521 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013522 if(!HAL_STATUS_SUCCESS(status))
13523 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013524 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013525 break;
13526 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013527 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013528 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013529 return( status );
13530}
Jeff Johnson295189b2012-06-20 16:38:30 -070013531eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13532{
13533 eHalStatus status = eHAL_STATUS_SUCCESS;
13534 tSirSmeAssocCnf *pMsg;
13535 tANI_U8 *pBuf;
13536 tSirResultCodes statusCode;
13537 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013539 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13540 if ( NULL == pMsg )
13541 status = eHAL_STATUS_FAILURE;
13542 else
13543 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013544 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013545 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13547 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013548 pBuf = (tANI_U8 *)&pMsg->statusCode;
13549 if(HAL_STATUS_SUCCESS(Halstatus))
13550 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13551 else
13552 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013553 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013554 pBuf += sizeof(tSirResultCodes);
13555 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013556 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13557 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013558 pBuf += sizeof (tSirMacAddr);
13559 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013560 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13561 sizeof(tSirMacAddr));
13562 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013563 pBuf += sizeof (tSirMacAddr);
13564 // aid
13565 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013566 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013567 pBuf += sizeof (tANI_U16);
13568 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013569 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13570 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013571 pBuf += sizeof (tSirMacAddr);
13572 // alternateChannelId
13573 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013574 status = palSendMBMessage( pMac->hHdd, pMsg );
13575 if(!HAL_STATUS_SUCCESS(status))
13576 {
13577 //pMsg is freed by palSendMBMessage
13578 break;
13579 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013580 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013581 return( status );
13582}
Jeff Johnson295189b2012-06-20 16:38:30 -070013583eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13584 tpSirSmeAssocInd pAssocInd,
13585 eHalStatus Halstatus,
13586 tANI_U8 sessionId)
13587{
13588 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013589 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13590 tANI_U8 *pBuf;
13591 tSirResultCodes statusCode;
13592 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013593 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013594 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13595 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13596 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013597
Jeff Johnson295189b2012-06-20 16:38:30 -070013598 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13599 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13600
13601 pMsg->sessionId = sessionId;
13602
13603 pBuf = (tANI_U8 *)&pMsg->statusCode;
13604 if(HAL_STATUS_SUCCESS(Halstatus))
13605 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13606 else
13607 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013608 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013609 pBuf += sizeof(tSirResultCodes);
13610 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013611 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013612 pBuf += sizeof (tSirMacAddr);
13613 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013614 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13615 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013616 pBuf += sizeof (tSirMacAddr);
13617 // StaId
13618 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013619 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 pBuf += sizeof (tANI_U16);
13621 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013622 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013623 pBuf += sizeof (tSirMacAddr);
13624 // alternateChannelId
13625 *pBuf = 11;
13626 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013627 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013628 //Wmm
13629 *pBuf = pAssocInd->wmmEnabledSta;
13630 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013631 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013632 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013633 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013634 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013635 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013636 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013637 //reassocReq
13638 *pBuf = pAssocInd->reassocReq;
13639 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013640 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13641 msgQ.bodyptr = pMsg;
13642 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013644 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013645 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013646}
Jeff Johnson295189b2012-06-20 16:38:30 -070013647
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013648eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013649 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13650 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13651 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13652 tANI_U8 *pKeyRsc )
13653{
13654 tSirSmeSetContextReq *pMsg;
13655 tANI_U16 msgLen;
13656 eHalStatus status = eHAL_STATUS_FAILURE;
13657 tAniEdType tmpEdType;
13658 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013659 tANI_U8 *pBuf = NULL;
13660 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013661 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013662 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013663 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013664 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13665 // key set. Since we only support upto one key, we always allocate memory for 1 key
13666 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13667 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13668 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13669 ( sizeof( pMsg->keyMaterial.key ) );
13670
Kiet Lam64c1b492013-07-12 13:56:44 +053013671 pMsg = vos_mem_malloc(msgLen);
13672 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13673 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013674 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13675 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013676 //sessionId
13677 pBuf = &pMsg->sessionId;
13678 *pBuf = (tANI_U8)sessionId;
13679 pBuf++;
13680 // transactionId
13681 *pBuf = 0;
13682 *(pBuf + 1) = 0;
13683 pBuf += sizeof(tANI_U16);
13684 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013685 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013686
13687 pBuf += sizeof(tSirMacAddr);
13688
13689 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013690 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13691 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013692
13693 pBuf += sizeof(tSirMacAddr);
13694
13695 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013696 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13697 // in the tSirKeyMaterial keyMaterial; field).
13698 //
13699 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13700 // shorter than this max size. Is LIM interpreting this ok ?
13701 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 -070013702 // set pMsg->keyMaterial.edType
13703 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013704 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013705 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 // set the pMsg->keyMaterial.numKeys field
13707 *p = numKeys;
13708 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013709 // set pSirKey->keyId = keyId;
13710 *p = keyId;
13711 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013712 // set pSirKey->unicast = (tANI_U8)fUnicast;
13713 *p = (tANI_U8)fUnicast;
13714 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013715 // set pSirKey->keyDirection = aniKeyDirection;
13716 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013717 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013718 p += sizeof(tAniKeyDirection);
13719 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013720 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013721 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013722 // set pSirKey->paeRole
13723 *p = paeRole; // 0 is Supplicant
13724 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013725 // set pSirKey->keyLength = keyLength;
13726 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013727 if ( keyLength && pKey )
13728 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013729 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013730 if(keyLength == 16)
13731 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013732 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 -070013733 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13734 pKey[5], pKey[6], pKey[7], pKey[8],
13735 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13736 }
13737 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013738 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013740 return( status );
13741}
13742
Jeff Johnson295189b2012-06-20 16:38:30 -070013743eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13744 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13745{
13746 eHalStatus status;
13747 tSirSmeStartBssReq *pMsg;
13748 tANI_U8 *pBuf = NULL;
13749 tANI_U8 *wTmpBuf = NULL;
13750 tANI_U16 msgLen, wTmp;
13751 tANI_U32 dwTmp;
13752 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013753 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013754 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013755 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013756
13757 if(!pSession)
13758 {
13759 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13760 return eHAL_STATUS_FAILURE;
13761 }
13762
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 do {
13764 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13765 pSession->joinFailStatusCode.reasonCode = 0;
13766 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013767 pMsg = vos_mem_malloc(msgLen);
13768 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13769 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013770 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013771 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013773 //sessionId
13774 *pBuf = (tANI_U8)sessionId;
13775 pBuf++;
13776 // transactionId
13777 *pBuf = 0;
13778 *(pBuf + 1) = 0;
13779 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013780 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013781 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013782 pBuf += sizeof(tSirMacAddr);
13783 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013784 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013785 pBuf += sizeof(tSirMacAddr);
13786 // beaconInterval
13787 if( pBssDesc && pBssDesc->beaconInterval )
13788 {
13789 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13790 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013791 else if(pParam->beaconInterval)
13792 {
13793 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13794 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013795 else
13796 {
13797 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13798 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013799 if(csrIsconcurrentsessionValid (pMac, sessionId,
13800 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013801 == eHAL_STATUS_SUCCESS )
13802 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013803 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013804 pParam->bssPersona);
13805 //Update the beacon Interval
13806 pParam->beaconInterval = wTmp;
13807 }
13808 else
13809 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013810 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013811 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013812 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013813 return status;
13814 }
13815
Kiet Lam64c1b492013-07-12 13:56:44 +053013816 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013817 pBuf += sizeof(tANI_U16);
13818 // dot11mode
13819 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13820 pBuf += 1;
13821 // bssType
13822 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013823 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013824 pBuf += sizeof(tSirBssType);
13825 // ssId
13826 if( pParam->ssId.length )
13827 {
13828 // ssId len
13829 *pBuf = pParam->ssId.length;
13830 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013831 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013832 pBuf += pParam->ssId.length;
13833 }
13834 else
13835 {
13836 *pBuf = 0;
13837 pBuf++;
13838 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013839 // set the channel Id
13840 *pBuf = pParam->operationChn;
13841 pBuf++;
13842 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013843 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013844 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013845 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013846
Jeff Johnson295189b2012-06-20 16:38:30 -070013847 // Set privacy
13848 *pBuf = pParam->privacy;
13849 pBuf++;
13850
13851 //Set Uapsd
13852 *pBuf = pParam->ApUapsdEnable;
13853 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013854 //Set SSID hidden
13855 *pBuf = pParam->ssidHidden;
13856 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013857 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13858 pBuf++;
13859
13860 //Ht protection Enable/Disable
13861 *pBuf = (tANI_U8)pParam->protEnabled;
13862 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013863 //Enable Beacons to Receive for OBSS protection Enable/Disable
13864 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13865 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013866 //set cfg related to protection
13867 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013868 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013869 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013870 // Set Auth type
13871 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013872 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013873 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013874 // Set DTIM
13875 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013876 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013877 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013878 // Set wps_state
13879 *pBuf = pParam->wps_state;
13880 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080013881 // set isCoalesingInIBSSAllowed
13882 *pBuf = pMac->isCoalesingInIBSSAllowed;
13883 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013884 //Persona
13885 *pBuf = (tANI_U8)pParam->bssPersona;
13886 pBuf++;
13887
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013888 //txLdpcIniFeatureEnabled
13889 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13890 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013891
Chet Lanctot8cecea22014-02-11 19:09:36 -080013892#ifdef WLAN_FEATURE_11W
13893 // Set MFP capable/required
13894 *pBuf = (tANI_U8)pParam->mfpCapable;
13895 pBuf++;
13896 *pBuf = (tANI_U8)pParam->mfpRequired;
13897 pBuf++;
13898#endif
13899
krunal soni4f087d22013-07-29 16:32:26 -070013900 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013901 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13902 {
13903 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013904 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013905 break;
13906 }
13907 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013908 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013909 pBuf += sizeof(tANI_U16);
13910 if( wTmp )
13911 {
13912 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013913 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013914 pBuf += wTmp;
13915 }
13916 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013917 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013919 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13920 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013921 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13922 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013923 pBuf += pParam->operationalRateSet.numRates ;
13924 *pBuf++ = pParam->extendedRateSet.numRates;
13925 if(0 != pParam->extendedRateSet.numRates)
13926 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013927 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13928 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013929 pBuf += pParam->extendedRateSet.numRates;
13930 }
krunal sonie9002db2013-11-25 14:24:17 -080013931
Jeff Johnson295189b2012-06-20 16:38:30 -070013932 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13933 pMsg->length = pal_cpu_to_be16(msgLen);
13934
13935 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013936 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013937 return( status );
13938}
13939
Jeff Johnson295189b2012-06-20 16:38:30 -070013940eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13941{
13942 eHalStatus status = eHAL_STATUS_FAILURE;
13943 tSirSmeStopBssReq *pMsg;
13944 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13945 tANI_U8 *pBuf;
13946 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013947
13948 if(!pSession)
13949 {
13950 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13951 return eHAL_STATUS_FAILURE;
13952 }
13953
Jeff Johnson295189b2012-06-20 16:38:30 -070013954 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013955 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13956 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13957 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013958 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13959 pBuf = &pMsg->sessionId;
13960 //sessionId
13961 *pBuf = (tANI_U8)sessionId;
13962 pBuf++;
13963 // transactionId
13964 *pBuf = 0;
13965 pBuf += sizeof(tANI_U16);
13966 //reason code
13967 *pBuf = 0;
13968 pBuf += sizeof(tSirResultCodes);
13969 // bssid
13970 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13971 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13972 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013973 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
13974 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013975 }
13976 else
13977 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013978 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13979 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013980 }
13981 pBuf += sizeof(tSirMacAddr);
13982 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13983 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013984 status = palSendMBMessage( pMac->hHdd, pMsg );
13985#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053013986 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13987 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13988 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013989 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13990 pMsg->reasonCode = 0;
13991 // bssid
13992 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13993 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13994 {
13995 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13996 }
13997 else
13998 {
13999 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
14000 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014001 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014002 pMsg->transactionId = 0;
14003 pMsg->sessionId = (tANI_U8)sessionId;
14004 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
14005 status = palSendMBMessage( pMac->hHdd, pMsg );
14006#endif
14007 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014008 return( status );
14009}
14010
Jeff Johnson295189b2012-06-20 16:38:30 -070014011eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14012 tCsrRoamModifyProfileFields *pModProfileFields,
14013 tANI_U32 *pRoamId, v_BOOL_t fForce)
14014{
Jeff Johnson295189b2012-06-20 16:38:30 -070014015 eHalStatus status = eHAL_STATUS_FAILURE;
14016 tANI_U32 roamId = 0;
14017 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014018 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014019 (fForce || (!vos_mem_compare( &pModProfileFields,
14020 &pSession->connectedProfile.modifyProfileFields,
14021 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014022 {
14023 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14024 if(pRoamId)
14025 {
14026 *pRoamId = roamId;
14027 }
14028
Jeff Johnson295189b2012-06-20 16:38:30 -070014029 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14030 eCsrSmeIssuedReassocToSameAP, roamId,
14031 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014033 return status;
14034}
Jeff Johnson295189b2012-06-20 16:38:30 -070014035static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14036{
14037 eHalStatus status = eHAL_STATUS_SUCCESS;
14038 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014039 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014040 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14041 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14042 return (status);
14043}
Jeff Johnson295189b2012-06-20 16:38:30 -070014044eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14045{
14046 eHalStatus status = eHAL_STATUS_SUCCESS;
14047 tListElem *pEntry = NULL;
14048 tSmeCmd *pCommand = NULL;
14049 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014050 do
14051 {
14052 if(pMsg == NULL)
14053 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014054 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014055 status = eHAL_STATUS_FAILURE;
14056 break;
14057 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014058 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14059 if(pEntry)
14060 {
14061 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14062 if(eSmeCommandAddStaSession == pCommand->command)
14063 {
14064 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014065 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014066 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014067 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014068 //Remove this command out of the active list
14069 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14070 {
14071 //Now put this command back on the avilable command list
14072 csrReleaseCommand(pMac, pCommand);
14073 }
14074 smeProcessPendingQueue( pMac );
14075 }
14076 else
14077 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014078 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 -070014079 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014080 status = eHAL_STATUS_FAILURE;
14081 break;
14082 }
14083 }
14084 else
14085 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014086 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 -070014087 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014088 status = eHAL_STATUS_FAILURE;
14089 break;
14090 }
14091 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014092 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014093}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014094eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14095 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014096{
14097 tSirSmeAddStaSelfReq *pMsg;
14098 tANI_U16 msgLen;
14099 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014101 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014102 pMsg = vos_mem_malloc(msgLen);
14103 if ( NULL == pMsg ) break;
14104 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014105 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14106 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014107 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014108 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014109 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14110
14111 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14112
Arif Hussain24bafea2013-11-15 15:10:03 -080014113 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14114 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014115 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014116 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014117 return( status );
14118}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014119eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14120 tANI_U32 sessionId,
14121 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014122{
14123 eHalStatus status = eHAL_STATUS_SUCCESS;
14124 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014125 pCommand = csrGetCommandBuffer(pMac);
14126 if(NULL == pCommand)
14127 {
14128 status = eHAL_STATUS_RESOURCES;
14129 }
14130 else
14131 {
14132 pCommand->command = eSmeCommandAddStaSession;
14133 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014134 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14135 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014136 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014137 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14138 if( !HAL_STATUS_SUCCESS( status ) )
14139 {
14140 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014141 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014142 }
14143 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014144 return (status);
14145}
Jeff Johnson295189b2012-06-20 16:38:30 -070014146eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14147{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014148 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014149}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014150eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14151 csrRoamCompleteCallback callback,
14152 void *pContext, tANI_U8 *pSelfMacAddr,
14153 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014154{
14155 eHalStatus status = eHAL_STATUS_SUCCESS;
14156 tANI_U32 i;
14157 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014158 *pbSessionId = CSR_SESSION_ID_INVALID;
14159 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14160 {
14161 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14162 {
14163 pSession = CSR_GET_SESSION( pMac, i );
14164 status = eHAL_STATUS_SUCCESS;
14165 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14166 pSession->sessionId = (tANI_U8)i;
14167 pSession->callback = callback;
14168 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014169 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014170 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014171 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14172 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014173 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014174 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014175 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014176 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014177 break;
14178 }
14179#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014180 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14181 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014182 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014183 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014184 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014185 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014186 break;
14187 }
14188#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014189 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014190 break;
14191 }
14192 }
14193 if( CSR_ROAM_SESSION_MAX == i )
14194 {
14195 //No session is available
14196 status = eHAL_STATUS_RESOURCES;
14197 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014198 return ( status );
14199}
Jeff Johnson295189b2012-06-20 16:38:30 -070014200eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14201{
14202 eHalStatus status = eHAL_STATUS_SUCCESS;
14203 tListElem *pEntry = NULL;
14204 tSmeCmd *pCommand = NULL;
14205 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014206 do
14207 {
14208 if(pMsg == NULL)
14209 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014210 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014211 status = eHAL_STATUS_FAILURE;
14212 break;
14213 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014214 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14215 if(pEntry)
14216 {
14217 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14218 if(eSmeCommandDelStaSession == pCommand->command)
14219 {
14220 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014221 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014222 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014223 //This session is done.
14224 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014225 if(pCommand->u.delStaSessionCmd.callback)
14226 {
14227
14228 status = sme_ReleaseGlobalLock( &pMac->sme );
14229 if ( HAL_STATUS_SUCCESS( status ) )
14230 {
14231 pCommand->u.delStaSessionCmd.callback(
14232 pCommand->u.delStaSessionCmd.pContext);
14233 status = sme_AcquireGlobalLock( &pMac->sme );
14234 if (! HAL_STATUS_SUCCESS( status ) )
14235 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014236 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014237 return status;
14238 }
14239 }
14240 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014241 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014242 }
14243 }
14244
14245 //Remove this command out of the active list
14246 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14247 {
14248 //Now put this command back on the avilable command list
14249 csrReleaseCommand(pMac, pCommand);
14250 }
14251 smeProcessPendingQueue( pMac );
14252 }
14253 else
14254 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014255 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 -070014256 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014257 status = eHAL_STATUS_FAILURE;
14258 break;
14259 }
14260 }
14261 else
14262 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014263 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 -070014264 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014265 status = eHAL_STATUS_FAILURE;
14266 break;
14267 }
14268 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014269 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014270}
Jeff Johnson295189b2012-06-20 16:38:30 -070014271eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14272{
14273 tSirSmeDelStaSelfReq *pMsg;
14274 tANI_U16 msgLen;
14275 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014276 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014277 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14278 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014279 pMsg = vos_mem_malloc(msgLen);
14280 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14281 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014282 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14283 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014284 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014285 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14286 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014287 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014288 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014289 return( status );
14290}
Jeff Johnson295189b2012-06-20 16:38:30 -070014291eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14292 tSirMacAddr sessionMacAddr,
14293 csrRoamSessionCloseCallback callback,
14294 void *pContext)
14295{
14296 eHalStatus status = eHAL_STATUS_SUCCESS;
14297 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014298 pCommand = csrGetCommandBuffer(pMac);
14299 if(NULL == pCommand)
14300 {
14301 status = eHAL_STATUS_RESOURCES;
14302 }
14303 else
14304 {
14305 pCommand->command = eSmeCommandDelStaSession;
14306 pCommand->sessionId = (tANI_U8)sessionId;
14307 pCommand->u.delStaSessionCmd.callback = callback;
14308 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014309 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14310 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014311 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14312 if( !HAL_STATUS_SUCCESS( status ) )
14313 {
14314 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014315 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014316 }
14317 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014318 return (status);
14319}
Jeff Johnson295189b2012-06-20 16:38:30 -070014320eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14321{
14322 return csrSendMBDelSelfStaReqMsg( pMac,
14323 pCommand->u.delStaSessionCmd.selfMacAddr );
14324}
Jeff Johnson295189b2012-06-20 16:38:30 -070014325static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14326{
14327 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14328 tListElem *pEntry, *pNext;
14329 tSmeCmd *pCommand;
14330 tDblLinkList localList;
14331
14332 vos_mem_zero(&localList, sizeof(tDblLinkList));
14333 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14334 {
14335 smsLog(pMac, LOGE, FL(" failed to open list"));
14336 return;
14337 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014338 csrLLLock(pList);
14339 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14340 while(pEntry != NULL)
14341 {
14342 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14343 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14344 if(pCommand->sessionId == sessionId)
14345 {
14346 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14347 {
14348 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14349 }
14350 }
14351 pEntry = pNext;
14352 }
14353 csrLLUnlock(pList);
14354
14355 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14356 {
14357 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14358 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14359 }
14360 csrLLClose(&localList);
14361}
14362
Jeff Johnson295189b2012-06-20 16:38:30 -070014363void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14364{
14365 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14366 {
14367 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014368 csrRoamStop(pMac, sessionId);
14369 csrFreeConnectBssDesc(pMac, sessionId);
14370 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14371 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014372 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014373#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014374 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014375#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014376 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14377 if (pMac->fScanOffload)
14378 {
14379 purgeSmeSessionCmdList(pMac, sessionId,
14380 &pMac->sme.smeScanCmdPendingList);
14381 }
14382
Jeff Johnson295189b2012-06-20 16:38:30 -070014383 purgeCsrSessionCmdList(pMac, sessionId);
14384 csrInitSession(pMac, sessionId);
14385 }
14386}
14387
Jeff Johnson295189b2012-06-20 16:38:30 -070014388eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14389 tANI_BOOLEAN fSync,
14390 csrRoamSessionCloseCallback callback,
14391 void *pContext )
14392{
14393 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014394 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14395 {
14396 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14397 if(fSync)
14398 {
14399 csrCleanupSession(pMac, sessionId);
14400 }
14401 else
14402 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014403 purgeSmeSessionCmdList(pMac, sessionId,
14404 &pMac->sme.smeCmdPendingList);
14405 if (pMac->fScanOffload)
14406 {
14407 purgeSmeSessionCmdList(pMac, sessionId,
14408 &pMac->sme.smeScanCmdPendingList);
14409 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014410 purgeCsrSessionCmdList(pMac, sessionId);
14411 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14412 pSession->selfMacAddr, callback, pContext);
14413 }
14414 }
14415 else
14416 {
14417 status = eHAL_STATUS_INVALID_PARAMETER;
14418 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014419 return ( status );
14420}
14421
Jeff Johnson295189b2012-06-20 16:38:30 -070014422static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14423{
14424 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014425
14426 if(!pSession)
14427 {
14428 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14429 return;
14430 }
14431
Jeff Johnson295189b2012-06-20 16:38:30 -070014432 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14433 pSession->sessionId = CSR_SESSION_ID_INVALID;
14434 pSession->callback = NULL;
14435 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014436 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14437 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14438 csrFreeRoamProfile( pMac, sessionId );
14439 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14440 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14441 csrFreeConnectBssDesc(pMac, sessionId);
14442 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014443 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14444 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014445 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014446 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014447 pSession->pWpaRsnReqIE = NULL;
14448 }
14449 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014450 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014451 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014452 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014453 pSession->pWpaRsnRspIE = NULL;
14454 }
14455 pSession->nWpaRsnRspIeLength = 0;
14456#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014457 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014458 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014459 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014460 pSession->pWapiReqIE = NULL;
14461 }
14462 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014463 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014464 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014465 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014466 pSession->pWapiRspIE = NULL;
14467 }
14468 pSession->nWapiRspIeLength = 0;
14469#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014470 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014471 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014472 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014473 }
14474 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014475
Kiet Lam64c1b492013-07-12 13:56:44 +053014476 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014477 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014478 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014479 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014480 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014481 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014482}
14483
Jeff Johnson295189b2012-06-20 16:38:30 -070014484eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14485{
14486 eHalStatus status = eHAL_STATUS_FAILURE;
14487 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014488 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14489 {
14490 if( CSR_IS_SESSION_VALID( pMac, i ) )
14491 {
14492 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14493 {
14494 //Found it
14495 status = eHAL_STATUS_SUCCESS;
14496 *pSessionId = i;
14497 break;
14498 }
14499 }
14500 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014501 return( status );
14502}
14503
Jeff Johnson295189b2012-06-20 16:38:30 -070014504//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14505//session because for IBSS, the bssid changes.
14506static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14507{
14508 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14509 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014510 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14511 {
14512 if( CSR_IS_SESSION_VALID( pMac, i ) )
14513 {
14514 pSession = CSR_GET_SESSION( pMac, i );
14515 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14516 {
14517 //Found it
14518 nRet = i;
14519 break;
14520 }
14521 }
14522 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014523 return (nRet);
14524}
Jeff Johnson295189b2012-06-20 16:38:30 -070014525static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14526{
14527 /* Update the current BSS info in ho control block based on connected
14528 profile info from pmac global structure */
14529
Arif Hussain24bafea2013-11-15 15:10:03 -080014530 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14531 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014532 /* Check for user misconfig of RSSI trigger threshold */
14533 pMac->roam.configParam.vccRssiThreshold =
14534 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14535 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14536 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014537 /* Check for user misconfig of UL MAC Loss trigger threshold */
14538 pMac->roam.configParam.vccUlMacLossThreshold =
14539 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14540 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014541#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14542 {
14543 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014544 /* Indicate the neighbor roal algorithm about the connect indication */
14545 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14546 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14547 }
14548#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014549}
14550
Jeff Johnson295189b2012-06-20 16:38:30 -070014551static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14552{
14553 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014554
14555 if(!pSession)
14556 {
14557 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14558 return;
14559 }
14560
Jeff Johnson295189b2012-06-20 16:38:30 -070014561 //Only to handle the case for Handover on infra link
14562 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14563 {
14564 return;
14565 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014566 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14567 csrRoamDeregStatisticsReq(pMac);
14568 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14569#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14570 /* Indicate the neighbor roal algorithm about the disconnect indication */
14571 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14572#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014573
14574 //Remove this code once SLM_Sessionization is supported
14575 //BMPS_WORKAROUND_NOT_NEEDED
14576 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014577 csrIsInfraApStarted( pMac ) &&
14578 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014579 {
14580 pMac->roam.configParam.doBMPSWorkaround = 0;
14581 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014582}
14583
Jeff Johnson295189b2012-06-20 16:38:30 -070014584void csrRoamTlStatsTimerHandler(void *pv)
14585{
14586 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14587 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014588 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14589
Jeff Johnsone7245742012-09-05 17:12:55 -070014590 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14591
Jeff Johnson295189b2012-06-20 16:38:30 -070014592#if 0
14593 // TODO Persession .???
14594 //req TL for stats
14595 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14596 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014597 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014598 }
14599 else
14600 {
14601 //save in SME
14602 csrRoamSaveStatsFromTl(pMac, tlStats);
14603 }
14604#endif
14605 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14606 {
14607 if(pMac->roam.tlStatsReqInfo.periodicity)
14608 {
14609 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014610 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14611 pMac->roam.tlStatsReqInfo.periodicity);
14612 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014613 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014614 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014615 return;
14616 }
14617 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14618 }
14619 }
14620}
Jeff Johnson295189b2012-06-20 16:38:30 -070014621void csrRoamPeStatsTimerHandler(void *pv)
14622{
14623 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14624 eHalStatus status;
14625 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14626 VOS_STATUS vosStatus;
14627 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014628 pPeStatsReqListEntry->timerRunning = FALSE;
14629 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14630 {
14631 // If we entered here, meaning the timer could not be successfully
14632 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14633
14634 /* Destroy the timer */
14635 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14636 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014638 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014639 }
14640
14641 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014642 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014643 pPeStatsReqListEntry = NULL;
14644 }
14645 else
14646 {
14647 if(!pPeStatsReqListEntry->rspPending)
14648 {
14649 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14650 pPeStatsReqListEntry->staId);
14651 if(!HAL_STATUS_SUCCESS(status))
14652 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014653 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014654 }
14655 else
14656 {
14657 pPeStatsReqListEntry->rspPending = TRUE;
14658 }
14659 }
14660
14661 //send down a req
14662 if(pPeStatsReqListEntry->periodicity &&
14663 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14664 {
14665 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14666 if(ePMC_FULL_POWER == powerState)
14667 {
14668 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14669 {
14670 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14671 }
14672 }
14673 else
14674 {
14675 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14676 {
14677 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14678 }
14679 }
14680 //start timer
14681 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14682 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14683 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014684 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014685 return;
14686 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014687 pPeStatsReqListEntry->timerRunning = TRUE;
14688
14689 }
14690
14691 }
14692}
Jeff Johnson295189b2012-06-20 16:38:30 -070014693void csrRoamStatsClientTimerHandler(void *pv)
14694{
14695 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014696 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14697 {
14698#if 0
14699 // TODO Stats fix for multisession
14700 //start the timer
14701 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14702
14703 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014705 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014706 }
14707#endif
14708 }
14709#if 0
14710 //send up the stats report
14711 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14712 pStaEntry->staId, pStaEntry->pContext);
14713#endif
14714}
14715
14716
14717
Jeff Johnson295189b2012-06-20 16:38:30 -070014718eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14719{
14720 tAniGetPEStatsReq *pMsg;
14721 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014722 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14723 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014724 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014725 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053014726 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014727 }
14728 // need to initiate a stats request to PE
14729 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14730 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14731 pMsg->staId = staId;
14732 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014733 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014734 if(!HAL_STATUS_SUCCESS(status))
14735 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014736 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070014737 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014738 return status;
14739}
Jeff Johnson295189b2012-06-20 16:38:30 -070014740void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14741{
14742 tAniGetPEStatsRsp *pSmeStatsRsp;
14743 eHalStatus status = eHAL_STATUS_FAILURE;
14744 tListElem *pEntry = NULL;
14745 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14746 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14747 tANI_U32 tempMask = 0;
14748 tANI_U8 counter = 0;
14749 tANI_U8 *pStats = NULL;
14750 tANI_U32 length = 0;
14751 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014752 v_S7_t rssi = 0, snr = 0;
14753 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014754 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014755 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14756 if(pSmeStatsRsp->rc)
14757 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014758 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014759 goto post_update;
14760 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014761 tempMask = pSmeStatsRsp->statsMask;
14762 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014763 /* subtract all statistics from this length, and after processing the entire
14764 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14765 * in this 'stats' message.
14766 */
14767 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014768 //new stats info from PE, fill up the stats strucutres in PMAC
14769 while(tempMask)
14770 {
14771 if(tempMask & 1)
14772 {
14773 switch(counter)
14774 {
14775 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014776 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014777 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14778 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014779 pStats += sizeof(tCsrSummaryStatsInfo);
14780 length -= sizeof(tCsrSummaryStatsInfo);
14781 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014782 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014783 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014784 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14785 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014786 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14787 length -= sizeof(tCsrGlobalClassAStatsInfo);
14788 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014789 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014790 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014791 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14792 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014793 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14794 length -= sizeof(tCsrGlobalClassBStatsInfo);
14795 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014796 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014797 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014798 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14799 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014800 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14801 length -= sizeof(tCsrGlobalClassCStatsInfo);
14802 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014803 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014804 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014805 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14806 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014807 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14808 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014809 }
14810 else
14811 {
14812 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014813 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014814 VOS_ASSERT( 0 );
14815 }
14816 if(!HAL_STATUS_SUCCESS(status))
14817 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014818 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014819 }
14820 pStats += sizeof(tCsrPerStaStatsInfo);
14821 length -= sizeof(tCsrPerStaStatsInfo);
14822 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014823 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014824 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014825 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014826 }
14827 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014828 tempMask >>=1;
14829 counter++;
14830 }
14831 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14832 if (length != 0)
14833 {
14834 pRssi = (tANI_U32*)pStats;
14835 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014836 pStats += sizeof(tANI_U32);
14837 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014838 }
14839 else
14840 {
14841 /* If riva is not sending rssi, continue to use the hack */
14842 rssi = RSSI_HACK_BMPS;
14843 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014844
Jeff Johnson295189b2012-06-20 16:38:30 -070014845 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014846
14847 if (length != 0)
14848 {
14849 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014850 pStats += sizeof(tANI_U32);
14851 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014852 }
14853 else
14854 {
14855 linkCapacity = 0;
14856 }
14857
14858 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014859
14860 if (length != 0)
14861 {
14862 pSnr = (tANI_U32*)pStats;
14863 snr = (v_S7_t)*pSnr;
14864 }
14865 else
14866 {
14867 snr = SNR_HACK_BMPS;
14868 }
14869
14870 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014871post_update:
14872 //make sure to update the pe stats req list
14873 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14874 if(pEntry)
14875 {
14876 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14877 pPeStaEntry->rspPending = FALSE;
14878
14879 }
14880 //check the one timer cases
14881 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14882 if(pEntry)
14883 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014884 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014885 if(pTempStaEntry->timerExpired)
14886 {
14887 //send up the stats report
14888 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14889 pTempStaEntry->staId, pTempStaEntry->pContext);
14890 //also remove from the client list
14891 csrRoamRemoveStatListEntry(pMac, pEntry);
14892 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014893 }
14894 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014895}
Jeff Johnson295189b2012-06-20 16:38:30 -070014896tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14897{
14898 tListElem *pEntry = NULL;
14899 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014900 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014901 if(!pEntry)
14902 {
14903 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014904 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014905 return NULL;
14906 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014907 while( pEntry )
14908 {
14909 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014910 if(pTempStaEntry->statsMask == statsMask)
14911 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014912 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014913 break;
14914 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014915 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14916 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014917 return pEntry;
14918}
14919
Jeff Johnson295189b2012-06-20 16:38:30 -070014920tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14921 tANI_BOOLEAN update)
14922{
14923 tListElem *pEntry;
14924 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014925 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014926 if(!pEntry)
14927 {
14928 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014929 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014930 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014931 return NULL;
14932 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014933 while( pEntry )
14934 {
14935 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014936 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14937 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14938 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014939 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014940 if(update)
14941 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014942 pTempStaEntry->periodicity = pStaEntry->periodicity;
14943 pTempStaEntry->callback = pStaEntry->callback;
14944 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014945 }
14946 break;
14947 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014948 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14949 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014950 return pEntry;
14951}
Jeff Johnson295189b2012-06-20 16:38:30 -070014952tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14953{
14954 tListElem *pEntry;
14955 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014956 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014957 if(!pEntry)
14958 {
14959 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014960 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014961 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014962 return NULL;
14963 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014964 while( pEntry )
14965 {
14966 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014967 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14968 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014969 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014970 break;
14971 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014972 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14973 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014974 return pEntry;
14975}
Jeff Johnson295189b2012-06-20 16:38:30 -070014976eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14977 csrRoamLinkQualityIndCallback callback,
14978 void *pContext)
14979{
14980 pMac->roam.linkQualityIndInfo.callback = callback;
14981 pMac->roam.linkQualityIndInfo.context = pContext;
14982 if( NULL == callback )
14983 {
14984 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14985 }
14986 else
14987 {
14988 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014989 /* do we need to invoke the callback to notify client of initial value ?? */
14990 }
14991 return eHAL_STATUS_SUCCESS;
14992}
Jeff Johnson295189b2012-06-20 16:38:30 -070014993void csrRoamVccTrigger(tpAniSirGlobal pMac)
14994{
14995 eCsrRoamLinkQualityInd newVccLinkQuality;
14996 tANI_U32 ul_mac_loss = 0;
14997 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014998 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14999 /*-------------------------------------------------------------------------
15000 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015001 Check for a change in link quality and notify client if necessary
15002 -------------------------------------------------------------------------*/
15003 ul_mac_loss_trigger_threshold =
15004 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015005 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015006 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015007 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015008 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15009 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015010 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015011 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15012 }
15013 else
15014 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015015 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015016 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15017 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015018 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15019 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015020 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15021 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015022 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015023 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15024 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015025 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015026 newVccLinkQuality );
15027
15028 /* we now invoke the callback once to notify client of initial value */
15029 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15030 pMac->roam.linkQualityIndInfo.context );
15031 //event: EVENT_WLAN_VCC
15032 }
15033 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015034 pMac->roam.vccLinkQuality = newVccLinkQuality;
15035
Jeff Johnson295189b2012-06-20 16:38:30 -070015036}
Jeff Johnson295189b2012-06-20 16:38:30 -070015037VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15038 v_U8_t rssiNotification,
15039 void * context)
15040{
15041 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15042 eCsrRoamLinkQualityInd newVccLinkQuality;
15043 // TODO : Session info unavailable
15044 tANI_U32 sessionId = 0;
15045 VOS_STATUS status = VOS_STATUS_SUCCESS;
15046 /*-------------------------------------------------------------------------
15047 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015048 Check for a change in link quality and notify client if necessary
15049 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015050 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015051 pMac->roam.configParam.vccRssiThreshold);
15052 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15053 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015054 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015055 return VOS_STATUS_SUCCESS;
15056 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015057 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15058 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015059 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015060 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15061 }
15062 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15063 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015064 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015065 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15066 }
15067 else
15068 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015069 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015070 //Set to this so the code below won't do anything
15071 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015072 VOS_ASSERT(0);
15073 }
15074
Jeff Johnson295189b2012-06-20 16:38:30 -070015075 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15076 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015077 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015078 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15079 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015080 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015081 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015082 /* we now invoke the callback once to notify client of initial value */
15083 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15084 pMac->roam.linkQualityIndInfo.context );
15085 //event: EVENT_WLAN_VCC
15086 }
15087 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015088 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015089 return status;
15090}
Jeff Johnson295189b2012-06-20 16:38:30 -070015091tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15092 tDblLinkList *pStaList,
15093 tCsrStatsClientReqInfo *pStaEntry)
15094{
15095 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015096 //if same entity requested for same set of stats with different periodicity &
15097 // callback update it
15098 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15099 {
15100
Kiet Lam64c1b492013-07-12 13:56:44 +053015101 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15102 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015103 {
15104 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015105 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015106 return NULL;
15107 }
15108
Jeff Johnson295189b2012-06-20 16:38:30 -070015109 pNewStaEntry->callback = pStaEntry->callback;
15110 pNewStaEntry->pContext = pStaEntry->pContext;
15111 pNewStaEntry->periodicity = pStaEntry->periodicity;
15112 pNewStaEntry->requesterId = pStaEntry->requesterId;
15113 pNewStaEntry->statsMask = pStaEntry->statsMask;
15114 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15115 pNewStaEntry->pMac = pStaEntry->pMac;
15116 pNewStaEntry->staId = pStaEntry->staId;
15117 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15118
15119 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15120 }
15121 return pNewStaEntry;
15122}
15123
Jeff Johnson295189b2012-06-20 16:38:30 -070015124tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15125 tDblLinkList *pStaList,
15126 tCsrPeStatsReqInfo *pStaEntry)
15127{
15128 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015129 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15130 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015131 {
15132 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015133 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015134 return NULL;
15135 }
15136
Jeff Johnson295189b2012-06-20 16:38:30 -070015137 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15138 pNewStaEntry->numClient = pStaEntry->numClient;
15139 pNewStaEntry->periodicity = pStaEntry->periodicity;
15140 pNewStaEntry->statsMask = pStaEntry->statsMask;
15141 pNewStaEntry->pMac = pStaEntry->pMac;
15142 pNewStaEntry->staId = pStaEntry->staId;
15143 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15144 pNewStaEntry->rspPending = pStaEntry->rspPending;
15145
15146 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015147 return pNewStaEntry;
15148}
Jeff Johnson295189b2012-06-20 16:38:30 -070015149eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15150 tCsrRssiCallback callback,
15151 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15152{
15153 eHalStatus status = eHAL_STATUS_SUCCESS;
15154 vos_msg_t msg;
15155 tANI_U32 sessionId;
15156
15157 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015158 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015159 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15160 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015161 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015162 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015163 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015164 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015165 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15166
15167 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15168 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15169 pMsg->sessionId = sessionId;
15170 pMsg->staId = staId;
15171 pMsg->rssiCallback = callback;
15172 pMsg->pDevContext = pContext;
15173 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015174 msg.type = eWNI_SME_GET_RSSI_REQ;
15175 msg.bodyptr = pMsg;
15176 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015177 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15178 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015179 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015180 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015181 status = eHAL_STATUS_FAILURE;
15182 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015183 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015184 return status;
15185}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015186
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015187eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15188 tCsrSnrCallback callback,
15189 tANI_U8 staId, tCsrBssid bssId,
15190 void *pContext)
15191{
15192 eHalStatus status = eHAL_STATUS_SUCCESS;
15193 vos_msg_t msg;
15194 tANI_U32 sessionId;
15195
15196 tAniGetSnrReq *pMsg;
15197
15198 smsLog(pMac, LOG2, FL("called"));
15199
15200 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15201 if (NULL == pMsg )
15202 {
15203 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15204 return status;
15205 }
15206
15207 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15208
15209 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15210 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15211 pMsg->sessionId = sessionId;
15212 pMsg->staId = staId;
15213 pMsg->snrCallback = callback;
15214 pMsg->pDevContext = pContext;
15215 msg.type = eWNI_SME_GET_SNR_REQ;
15216 msg.bodyptr = pMsg;
15217 msg.reserved = 0;
15218
15219 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15220 {
15221 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15222 vos_mem_free((v_VOID_t *)pMsg);
15223 status = eHAL_STATUS_FAILURE;
15224 }
15225
15226 smsLog(pMac, LOG2, FL("returned"));
15227 return status;
15228}
15229
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015230#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015231eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15232 tCsrRssiCallback callback,
15233 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15234{
15235 eHalStatus status = eHAL_STATUS_SUCCESS;
15236 tAniGetRssiReq *pMsg;
15237
Kiet Lam64c1b492013-07-12 13:56:44 +053015238 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15239 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015240 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015241 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015242 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015243 }
15244 // need to initiate a stats request to PE
15245 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15246 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15247 pMsg->staId = staId;
15248 pMsg->rssiCallback = callback;
15249 pMsg->pDevContext = pContext;
15250 pMsg->pVosContext = pVosContext;
15251 status = palSendMBMessage(pMac->hHdd, pMsg );
15252 if(!HAL_STATUS_SUCCESS(status))
15253 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015254 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015255 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015256 status = eHAL_STATUS_FAILURE;
15257 }
15258 return status;
15259}
15260#endif
15261
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015262
15263
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015264#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015265eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15266 tCsrTsmStatsCallback callback,
15267 tANI_U8 staId,
15268 tCsrBssid bssId,
15269 void *pContext,
15270 void* pVosContext,
15271 tANI_U8 tid)
15272{
15273 eHalStatus status = eHAL_STATUS_SUCCESS;
15274 tAniGetTsmStatsReq *pMsg = NULL;
15275
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015276 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15277 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015278 {
15279 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015280 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015281 }
15282 // need to initiate a stats request to PE
15283 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15284 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15285 pMsg->staId = staId;
15286 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015287 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015288 pMsg->tsmStatsCallback = callback;
15289 pMsg->pDevContext = pContext;
15290 pMsg->pVosContext = pVosContext;
15291 status = palSendMBMessage(pMac->hHdd, pMsg );
15292 if(!HAL_STATUS_SUCCESS(status))
15293 {
15294 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15295 //pMsg is freed by palSendMBMessage
15296 status = eHAL_STATUS_FAILURE;
15297 }
15298 return status;
15299}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015300#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015301
15302
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015303/* ---------------------------------------------------------------------------
15304 \fn csrGetTLSTAState
15305 \helper function to get teh TL STA State whenever the function is called.
15306
15307 \param staId - The staID to be passed to the TL
15308 to get the relevant TL STA State
15309 \return the state as tANI_U16
15310 ---------------------------------------------------------------------------*/
15311tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15312{
15313 WLANTL_STAStateType tlSTAState;
15314 tlSTAState = WLANTL_STA_INIT;
15315
15316 //request TL for STA State
15317 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15318 {
15319 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15320 }
15321
15322 return tlSTAState;
15323}
15324
Jeff Johnson295189b2012-06-20 16:38:30 -070015325eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15326 tANI_U32 statsMask,
15327 tCsrStatsCallback callback,
15328 tANI_U32 periodicity, tANI_BOOLEAN cache,
15329 tANI_U8 staId, void *pContext)
15330{
15331 tCsrStatsClientReqInfo staEntry;
15332 tCsrStatsClientReqInfo *pStaEntry = NULL;
15333 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15334 tListElem *pEntry = NULL;
15335 tANI_BOOLEAN found = FALSE;
15336 eHalStatus status = eHAL_STATUS_SUCCESS;
15337 tANI_BOOLEAN insertInClientList = FALSE;
15338 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015339 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015340
15341 if( csrIsAllSessionDisconnected(pMac) )
15342 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015343 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015344 return eHAL_STATUS_FAILURE;
15345 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015346
15347 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15348 {
15349 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15350 return eHAL_STATUS_FAILURE;
15351 }
15352
Jeff Johnson295189b2012-06-20 16:38:30 -070015353 if((!statsMask) && (!callback))
15354 {
15355 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015356 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015357 return eHAL_STATUS_FAILURE;
15358 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015359 //for the search list method for deregister
15360 staEntry.requesterId = requesterId;
15361 staEntry.statsMask = statsMask;
15362 //requester wants to deregister or just an error
15363 if((statsMask) && (!callback))
15364 {
15365 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15366 if(!pEntry)
15367 {
15368 //msg
15369 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015370 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015371 return eHAL_STATUS_FAILURE;
15372 }
15373 else
15374 {
15375 //clean up & return
15376 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015377 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015378 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015379 pStaEntry->pPeStaEntry->numClient--;
15380 //check if we need to delete the entry from peStatsReqList too
15381 if(!pStaEntry->pPeStaEntry->numClient)
15382 {
15383 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15384 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015385 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015386
Jeff Johnson295189b2012-06-20 16:38:30 -070015387 //check if we need to stop the tl stats timer too
15388 pMac->roam.tlStatsReqInfo.numClient--;
15389 if(!pMac->roam.tlStatsReqInfo.numClient)
15390 {
15391 if(pMac->roam.tlStatsReqInfo.timerRunning)
15392 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015393 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15394 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015395 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015396 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015397 return eHAL_STATUS_FAILURE;
15398 }
15399 }
15400 pMac->roam.tlStatsReqInfo.periodicity = 0;
15401 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15402 }
15403 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015404 // Destroy the vos timer...
15405 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15406 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15407 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015408 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015409 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015410 csrRoamRemoveStatListEntry(pMac, pEntry);
15411 pStaEntry = NULL;
15412 return eHAL_STATUS_SUCCESS;
15413 }
15414 }
15415
15416 if(cache && !periodicity)
15417 {
15418 //return the cached stats
15419 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15420 }
15421 else
15422 {
15423 //add the request in the client req list
15424 staEntry.callback = callback;
15425 staEntry.pContext = pContext;
15426 staEntry.periodicity = periodicity;
15427 staEntry.pPeStaEntry = NULL;
15428 staEntry.staId = staId;
15429 staEntry.pMac = pMac;
15430 staEntry.timerExpired = FALSE;
15431
15432
Jeff Johnson295189b2012-06-20 16:38:30 -070015433 //if periodic report requested with non cached result from PE/TL
15434 if(periodicity)
15435 {
15436
15437 //if looking for stats from PE
15438 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15439 {
15440
15441 //check if same request made already & waiting for rsp
15442 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15443 periodicity, &found, staId);
15444 if(!pPeStaEntry)
15445 {
15446 //bail out, maxed out on number of req for PE
15447 return eHAL_STATUS_FAILURE;
15448 }
15449 else
15450 {
15451 staEntry.pPeStaEntry = pPeStaEntry;
15452 }
15453
15454 }
15455 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15456 if(statsMask & (1 << eCsrGlobalClassDStats))
15457 {
15458 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15459 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015460 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015461 }
15462 else
15463 {
15464
15465 //update periodicity
15466 if(pMac->roam.tlStatsReqInfo.periodicity)
15467 {
15468 pMac->roam.tlStatsReqInfo.periodicity =
15469 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15470 }
15471 else
15472 {
15473 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15474 }
15475 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15476 {
15477 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15478 }
15479
15480 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15481 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015482 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015483 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015484 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015485 //req TL for class D stats
15486 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15487 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015488 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015489 }
15490 else
15491 {
15492 //save in SME
15493 csrRoamSaveStatsFromTl(pMac, pTlStats);
15494 }
15495 vos_mem_free(pTlStats);
15496 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015497 }
15498 else
15499 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015500 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015501 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015502
Jeff Johnson295189b2012-06-20 16:38:30 -070015503 if(pMac->roam.tlStatsReqInfo.periodicity)
15504 {
15505 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015506 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15507 pMac->roam.tlStatsReqInfo.periodicity);
15508 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015509 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015510 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015511 return eHAL_STATUS_FAILURE;
15512 }
15513 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15514 }
15515 }
15516 }
15517 pMac->roam.tlStatsReqInfo.numClient++;
15518 }
15519
15520 insertInClientList = TRUE;
15521 }
15522 //if one time report requested with non cached result from PE/TL
15523 else if(!cache && !periodicity)
15524 {
15525 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15526 {
15527 //send down a req
15528 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15529 if(!HAL_STATUS_SUCCESS(status))
15530 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015531 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015532 }
15533 //so that when the stats rsp comes back from PE we respond to upper layer
15534 //right away
15535 staEntry.timerExpired = TRUE;
15536 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015537 }
15538 if(statsMask & (1 << eCsrGlobalClassDStats))
15539 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015540 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015541 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015542 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015543 //req TL for class D stats
15544 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15545 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015546 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015547 }
15548 else
15549 {
15550 //save in SME
15551 csrRoamSaveStatsFromTl(pMac, pTlStats);
15552 }
15553 vos_mem_free(pTlStats);
15554 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015555 }
15556 else
15557 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015558 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015559 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015560
15561 }
15562 //if looking for stats from TL only
15563 if(!insertInClientList)
15564 {
15565 //return the stats
15566 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15567 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015568 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015569 if(insertInClientList)
15570 {
15571 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15572 if(!pStaEntry)
15573 {
15574 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015575 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015576 return eHAL_STATUS_FAILURE;
15577 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015578 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015579 //Init & start timer if needed
15580 if(periodicity)
15581 {
15582 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15583 csrRoamStatsClientTimerHandler, pStaEntry );
15584 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15585 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015586 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015587 return eHAL_STATUS_FAILURE;
15588 }
15589 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15590 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015592 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015593 return eHAL_STATUS_FAILURE;
15594 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015595 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015596 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015597 }
15598 return eHAL_STATUS_SUCCESS;
15599}
15600
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015601#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15602
15603static tSirRetStatus
15604csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15605 tANI_U8* pBD,
15606 tANI_U8 type,
15607 tANI_U8 subType,
15608 tSirMacAddr peerAddr,
15609 tSirMacAddr selfMacAddr)
15610{
15611 tSirRetStatus statusCode = eSIR_SUCCESS;
15612 tpSirMacMgmtHdr pMacHdr;
15613
15614 /* Prepare MAC management header */
15615 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15616
15617 /* Prepare FC */
15618 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15619 pMacHdr->fc.type = type;
15620 pMacHdr->fc.subType = subType;
15621
15622 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015623 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15624 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015625
15626 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15627
15628 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015629 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15630 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015631 return statusCode;
15632} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15633
15634static tSirRetStatus
15635csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15636 tANI_U8 nChannelNum,
15637 tANI_U32 dot11mode,
15638 tSirMacAddr selfMacAddr,
15639 tANI_U8 *pFrame,
15640 tANI_U16 *pusLen)
15641{
15642 tDot11fProbeRequest pr;
15643 tANI_U32 nStatus, nBytes, nPayload;
15644 tSirRetStatus nSirStatus;
15645 /*Bcast tx*/
15646 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15647 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15648
15649
Kiet Lam64c1b492013-07-12 13:56:44 +053015650 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015651
15652 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15653
15654 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15655 {
15656 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15657 }
15658
15659
15660 if (IS_DOT11_MODE_HT(dot11mode))
15661 {
15662 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15663 }
15664
15665
15666 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15667 if ( DOT11F_FAILED( nStatus ) )
15668 {
15669 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15670 "Failed to calculate the packed size f"
15671 "or a Probe Request (0x%08x).\n", nStatus );
15672
15673
15674 nPayload = sizeof( tDot11fProbeRequest );
15675 }
15676 else if ( DOT11F_WARNED( nStatus ) )
15677 {
15678 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15679 "There were warnings while calculating"
15680 "the packed size for a Probe Request ("
15681 "0x%08x).\n", nStatus );
15682 }
15683
15684 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15685
15686 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015687 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015688
15689
15690 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015691 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015692
15693 if ( eSIR_SUCCESS != nSirStatus )
15694 {
15695 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15696 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15697 nSirStatus );
15698 return nSirStatus;
15699 }
15700
15701
15702 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15703 sizeof( tSirMacMgmtHdr ),
15704 nPayload, &nPayload );
15705 if ( DOT11F_FAILED( nStatus ) )
15706 {
15707 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15708 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15709 return eSIR_FAILURE;
15710 }
15711 else if ( DOT11F_WARNED( nStatus ) )
15712 {
15713 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015714 "There were warnings while packing a Probe Request (0x%08x).\n",
15715 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015716 }
15717
15718 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15719 return eSIR_SUCCESS;
15720}
15721
15722eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15723{
15724 vos_msg_t msg;
15725 tSirRoamOffloadScanReq *pRequestBuf;
15726 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15727 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015728 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015729 tANI_U8 *ChannelList = NULL;
15730 tANI_U32 sessionId;
15731 eHalStatus status = eHAL_STATUS_SUCCESS;
15732 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015733 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015734 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015735 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015736 tSirBssDescription *pBssDesc = NULL;
15737 tDot11fBeaconIEs *pIes = NULL;
15738 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080015739 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015740
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015741 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15742
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015743 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015744 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015745 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015746 return eHAL_STATUS_FAILURE;
15747 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015748
15749 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15750 {
15751 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15752 return eHAL_STATUS_FAILURE;
15753 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015754 status = csrRoamGetSessionIdFromBSSID(pMac,
15755 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15756 &sessionId);
15757 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15758 * It is important to ensure that the command is passed down to the FW only
15759 * if the Infra Station is in a connected state.A connected station could also be
15760 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15761 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15762 * irrespective of whichever state we are in.*/
15763 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15764 (command != ROAM_SCAN_OFFLOAD_STOP))
15765 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053015766 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
15767 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
15768 macTraceGetNeighbourRoamState(
15769 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015770 return eHAL_STATUS_FAILURE;
15771 }
15772
15773 if ( !HAL_STATUS_SUCCESS( status ) )
15774 {
15775 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15776 return eHAL_STATUS_FAILURE;
15777 }
15778 pSession = CSR_GET_SESSION( pMac, sessionId );
krunal soni587bf012014-02-04 12:35:11 -080015779 if (NULL == pSession)
15780 {
15781 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15782 "%s:pSession is null", __func__);
15783 return eHAL_STATUS_FAILURE;
15784 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015785 pBssDesc = pSession->pConnectBssDesc;
15786 if (pBssDesc == NULL)
15787 {
15788 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: pBssDesc not found for current session", __func__);
15789 return eHAL_STATUS_FAILURE;
15790 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015791 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15792 if (NULL == pRequestBuf)
15793 {
15794 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15795 return eHAL_STATUS_FAILED_ALLOC;
15796 }
15797
Kiet Lam64c1b492013-07-12 13:56:44 +053015798 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015799 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15800 * host driver reloads, but Riva still up and running*/
Mukul Sharma90506b42014-04-24 13:24:12 +053015801 pRequestBuf->Command = command;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015802 if(command == ROAM_SCAN_OFFLOAD_STOP)
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015803 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015804 pRequestBuf->RoamScanOffloadEnabled = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015805 /*For a STOP Command, there is no need to
15806 * go through filling up all the below parameters
15807 * since they are not required for the STOP command*/
15808 goto send_roam_scan_offload_cmd;
15809 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015810 else
15811 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015812 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15813 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015814 sizeof(tCsrBssid));
15815 pRequestBuf->ConnectedNetwork.ssId.length =
15816 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15817 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15818 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15819 pRequestBuf->ConnectedNetwork.ssId.length);
15820 pRequestBuf->ConnectedNetwork.authentication =
15821 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15822 pRequestBuf->ConnectedNetwork.encryption =
15823 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15824 pRequestBuf->ConnectedNetwork.mcencryption =
15825 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015826 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
15827 {
15828 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015829 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015830 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15831 }
15832 else
15833 {
15834 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
15835 operationChannel = pSession->connectedProfile.operationChannel;
15836
15837 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
15838 {
15839 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15840 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
15841 vos_mem_free(pRequestBuf);
15842 return eHAL_STATUS_FAILURE;
15843 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053015844 if(NULL == pIes)
15845 {
15846 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15847 "%s : pIes is Null", __func__);
15848 return eHAL_STATUS_FAILURE;
15849 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015850 if (pIes->SuppRates.present)
15851 {
15852 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
15853 /*Check for both basic rates and extended rates.*/
15854 for (i = 0; i < pIes->SuppRates.num_rates; i++)
15855 {
15856 /*Check if the Rate is Mandatory or Not*/
15857 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
15858 && (pIes->SuppRates.rates[i] & 0x80))
15859 {
15860 /*Retrieve the actual data rate*/
15861 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
15862 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15863 if (minRate == 0)
15864 minRate = dataRate;
15865 else
15866 minRate = (minRate < dataRate) ? minRate:dataRate;
15867 }
15868 }
15869
15870 if (pIes->ExtSuppRates.present)
15871 {
15872 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
15873 {
15874 /*Check if the Rate is Mandatory or Not*/
15875 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
15876 && (pIes->ExtSuppRates.rates[i] & 0x80))
15877 {
15878 /*Retrieve the actual data rate*/
15879 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
15880 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15881 if (minRate == 0)
15882 minRate = dataRate;
15883 else
15884 minRate = (minRate < dataRate) ? minRate:dataRate;
15885 }
15886 }
15887 }
15888 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
15889 }
15890 else
15891 {
15892 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15893 "%s: Supp Rates not present in pIes", __func__);
15894 vos_mem_free(pRequestBuf);
15895 return eHAL_STATUS_FAILURE;
15896 }
15897 if (NULL != pIes)
15898 {
15899 vos_mem_free(pIes);
15900 pIes = NULL;
15901 }
15902 switch (minRate)
15903 {
15904 case 1:
15905 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
15906 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
15907 break;
15908 case 2:
15909 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
15910 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
15911 break;
15912 case 5:
15913 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
15914 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
15915 break;
15916 case 6:
15917 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15918 {
15919 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
15920 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
15921 }
15922 else
15923 {
15924 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
15925 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
15926 }
15927 break;
15928 case 11:
15929 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
15930 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
15931 break;
15932 case 12:
15933 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15934 {
15935 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
15936 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
15937 }
15938 else
15939 {
15940 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
15941 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
15942 }
15943 break;
15944 case 24:
15945 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15946 {
15947 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
15948 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
15949 }
15950 else
15951 {
15952 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
15953 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
15954 }
15955 break;
15956 default:
15957 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
15958 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15959 break;
15960 }
15961 }
15962 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15963 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
15964 operationChannel, minRate,
15965 pRequestBuf->RxSensitivityThreshold,
15966 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015967 pRequestBuf->RoamRssiDiff =
15968 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015969 pRequestBuf->StartScanReason = reason;
15970 pRequestBuf->NeighborScanTimerPeriod =
15971 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
15972 pRequestBuf->NeighborRoamScanRefreshPeriod =
15973 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
15974 pRequestBuf->NeighborScanChannelMinTime =
15975 pNeighborRoamInfo->cfgParams.minChannelScanTime;
15976 pRequestBuf->NeighborScanChannelMaxTime =
15977 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
15978 pRequestBuf->EmptyRefreshScanPeriod =
15979 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080015980 /* MAWC feature */
15981 pRequestBuf->MAWCEnabled =
15982 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015983#ifdef FEATURE_WLAN_ESE
15984 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015985#endif
15986 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015987#ifdef FEATURE_WLAN_ESE
15988 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015989 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
15990 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015991 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
15992#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015993 currChannelListInfo->numOfChannels == 0)
15994 {
15995
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015996 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
15997 * Give Preference to INI Channels.*/
15998 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
15999 {
16000 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
16001 /*The INI channels need to be filtered with respect to the current
16002 * band that is supported.*/
16003 eBand = pMac->roam.configParam.bandCapability;
16004 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016005 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016006 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16007 "Invalid band, No operation carried out (Band %d)", eBand);
16008 vos_mem_free(pRequestBuf);
16009 return eHAL_STATUS_FAILURE;
16010 }
16011 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
16012 {
16013 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
16014 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
16015 (eCSR_BAND_ALL == eBand))
16016 {
16017 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
16018 csrRoamIsChannelValid(pMac, *ChannelList) &&
16019 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16020 {
16021 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16022 }
16023 }
16024 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016025 }
16026 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16027 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016028 }
16029 else
16030 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016031 ChannelList = pMac->scan.occupiedChannels.channelList;
16032 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
16033 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016034 /*Allow DFS channels only if the DFS channel roam flag is enabled */
16035 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16036 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016037 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16038 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016039 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016040 }
16041 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016042 }
16043 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16044 /* If the profile changes as to what it was earlier, inform the FW through
16045 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
16046 * for the earlier profile and try to learn them afresh.*/
16047 if (reason == REASON_FLUSH_CHANNEL_LIST)
16048 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16049 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016050 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16051 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16052 else
16053 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016054 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016055 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016056 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016057#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016058 else
16059 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016060 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016061 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016062 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016063 if (currChannelListInfo->numOfChannels != 0)
16064 {
16065 ChannelList = currChannelListInfo->ChannelList;
16066 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016067 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016068 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16069 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016070 {
16071 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16072 }
16073 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016074 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016075 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16076 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16077 }
16078 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016079#endif
Kaushik, Sushant5ed8ab62014-03-05 11:21:11 +053016080 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0])) && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016081 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016082 if (j < sizeof(ChannelCacheStr))
16083 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016084 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16085 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016086 }
16087 else
16088 {
16089 break;
16090 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016091 }
16092 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16093 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16094 pRequestBuf->ChannelCacheType,
16095 pRequestBuf->ConnectedNetwork.ChannelCount,
16096 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016097 num_channels = 0;
16098 ChannelList = NULL;
16099
16100 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016101 host_channels = sizeof(pMac->roam.validChannelList);
16102 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016103 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016104 ChannelList = pMac->roam.validChannelList;
16105 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016106 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016107 else
16108 {
16109 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16110 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016111 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016112 return eHAL_STATUS_FAILURE;
16113 }
16114 for(i=0; i<pMac->roam.numValidChannels; i++)
16115 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016116 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16117 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Srinivas Girigowda56076852013-08-20 14:00:50 -070016118 {
16119 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16120 }
16121 ChannelList++;
16122 }
16123 pRequestBuf->ValidChannelCount = num_channels;
16124
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016125 pRequestBuf->MDID.mdiePresent =
16126 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16127 pRequestBuf->MDID.mobilityDomain =
16128 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016129 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16130
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016131 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016132 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16133 * where RFS is the RF Switching time. It is twice RFS to consider the
16134 * time to go off channel and return to the home channel. */
16135 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16136 {
16137 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16138 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16139 " Hence enforcing home away time to disable (0)",
16140 __func__, pRequestBuf->HomeAwayTime,
16141 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16142 pRequestBuf->HomeAwayTime = 0;
16143 }
16144 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016145
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016146 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16147 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16148 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16149 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16150 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16151
16152 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16153 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016154send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016155 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016156 msg.reserved = 0;
16157 msg.bodyptr = pRequestBuf;
16158 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16159 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016160 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16161 vos_mem_free(pRequestBuf);
16162 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016163 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016164 else
16165 {
16166 if (ROAM_SCAN_OFFLOAD_START == command)
16167 bRoamScanOffloadStarted = VOS_TRUE;
16168 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16169 bRoamScanOffloadStarted = VOS_FALSE;
16170 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016171
16172 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16173 return status;
16174}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016175
16176eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16177{
16178 switch(reason)
16179 {
16180 case 0:
16181 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16182 break;
16183 case REASON_OS_REQUESTED_ROAMING_NOW:
16184 csrNeighborRoamProceedWithHandoffReq(pMac);
16185 break;
16186 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016187 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 -070016188 }
16189 return eHAL_STATUS_SUCCESS;
16190}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016191#endif
16192
Jeff Johnson295189b2012-06-20 16:38:30 -070016193tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16194 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16195{
16196 tANI_BOOLEAN found = FALSE;
16197 eHalStatus status = eHAL_STATUS_SUCCESS;
16198 tCsrPeStatsReqInfo staEntry;
16199 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16200 tListElem *pStaEntry = NULL;
16201 VOS_STATUS vosStatus;
16202 tPmcPowerState powerState;
16203 *pFound = FALSE;
16204
16205 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16206 if(pStaEntry)
16207 {
16208 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16209 if(pTempStaEntry->periodicity)
16210 {
16211 pTempStaEntry->periodicity =
16212 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16213 }
16214 else
16215 {
16216 pTempStaEntry->periodicity = periodicity;
16217 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016218 pTempStaEntry->numClient++;
16219 found = TRUE;
16220 }
16221 else
16222 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016223 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016224 staEntry.numClient = 1;
16225 staEntry.periodicity = periodicity;
16226 staEntry.pMac = pMac;
16227 staEntry.rspPending = FALSE;
16228 staEntry.staId = staId;
16229 staEntry.statsMask = statsMask;
16230 staEntry.timerRunning = FALSE;
16231 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16232 if(!pTempStaEntry)
16233 {
16234 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016235 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016236 return NULL;
16237 }
16238 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016239 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16240 if(ePMC_FULL_POWER == powerState)
16241 {
16242 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16243 {
16244 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16245 }
16246 }
16247 else
16248 {
16249 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16250 {
16251 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16252 }
16253 }
16254 if(!pTempStaEntry->timerRunning)
16255 {
16256 //send down a req in case of one time req, for periodic ones wait for timer to expire
16257 if(!pTempStaEntry->rspPending &&
16258 !pTempStaEntry->periodicity)
16259 {
16260 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16261 if(!HAL_STATUS_SUCCESS(status))
16262 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016263 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016264 }
16265 else
16266 {
16267 pTempStaEntry->rspPending = TRUE;
16268 }
16269 }
16270 if(pTempStaEntry->periodicity)
16271 {
16272 if(!found)
16273 {
16274
16275 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16276 csrRoamPeStatsTimerHandler, pTempStaEntry );
16277 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16278 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016279 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016280 return NULL;
16281 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016282 }
16283 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016284 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016285 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16286 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16287 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016288 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016289 return NULL;
16290 }
16291 pTempStaEntry->timerRunning = TRUE;
16292 }
16293 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016294 *pFound = found;
16295 return pTempStaEntry;
16296}
16297
Jeff Johnson295189b2012-06-20 16:38:30 -070016298/*
16299 pStaEntry is no longer invalid upon the return of this function.
16300*/
16301static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16302{
16303 if(pEntry)
16304 {
16305 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16306 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016307 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016308 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016309 }
16310 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016311
16312void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16313{
16314 tListElem *pEntry;
16315 tCsrPeStatsReqInfo *pTempStaEntry;
16316 VOS_STATUS vosStatus;
16317 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016318 if(!pEntry)
16319 {
16320 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016321 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016322 return;
16323 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016324 while( pEntry )
16325 {
16326 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016327 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16328 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016329 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016330 if(pTempStaEntry->timerRunning)
16331 {
16332 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16333 /* If we are not able to stop the timer here, just remove
16334 * the entry from the linked list. Destroy the timer object
16335 * and free the memory in the timer CB
16336 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016337 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016338 {
16339 /* the timer is successfully stopped */
16340 pTempStaEntry->timerRunning = FALSE;
16341
16342 /* Destroy the timer */
16343 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16344 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16345 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016346 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016347 }
16348 }
16349 else
16350 {
16351 // the timer could not be stopped. Hence destroy and free the
16352 // memory for the PE stat entry in the timer CB.
16353 pTempStaEntry->timerStopFailed = TRUE;
16354 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016355 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016356
16357 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16358 {
16359 // Only free the memory if we could stop the timer successfully
16360 if(!pTempStaEntry->timerStopFailed)
16361 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016362 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016363 pTempStaEntry = NULL;
16364 }
16365 break;
16366 }
16367
16368 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16369 }
16370 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016371 return;
16372}
16373
16374
Jeff Johnsone7245742012-09-05 17:12:55 -070016375void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016376{
16377
Jeff Johnsone7245742012-09-05 17:12:55 -070016378 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16379 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16380 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16381 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16382 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16383 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16384 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016385 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016386 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16387 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16388 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16389 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16390 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16391 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016392 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016393 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16394 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016395
16396}
16397
Jeff Johnson295189b2012-06-20 16:38:30 -070016398void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16399 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16400{
16401 tANI_U8 stats[500];
16402 tANI_U8 *pStats = NULL;
16403 tANI_U32 tempMask = 0;
16404 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016405 if(!callback)
16406 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016407 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016408 return;
16409 }
16410 if(!statsMask)
16411 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016412 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016413 return;
16414 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016415 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016416 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016417 while(tempMask)
16418 {
16419 if(tempMask & 1)
16420 {
16421 //new stats info from PE, fill up the stats strucutres in PMAC
16422 switch(counter)
16423 {
16424 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016425 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016426 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16427 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016428 pStats += sizeof(tCsrSummaryStatsInfo);
16429 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016430 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016431 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016432 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16433 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016434 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016435 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016436 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016437 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016438 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16439 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016440 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016441 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016442 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016443 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016444 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16445 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016446 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016447 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016448 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016449 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016450 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16451 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016452 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016453 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016454 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016455 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016456 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16457 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016458 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016459 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016460 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016461 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016462 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016463 }
16464 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016465 tempMask >>=1;
16466 counter++;
16467 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016468 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016469}
16470
Jeff Johnson295189b2012-06-20 16:38:30 -070016471eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16472{
16473 tListElem *pEntry = NULL;
16474 tListElem *pPrevEntry = NULL;
16475 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16476 eHalStatus status = eHAL_STATUS_SUCCESS;
16477 VOS_STATUS vosStatus;
16478 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016479 if(!pEntry)
16480 {
16481 //list empty
16482 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016483 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016484 return status;
16485 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016486 while( pEntry )
16487 {
16488 if(pPrevEntry)
16489 {
16490 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16491 //send up the stats report
16492 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16493 pTempStaEntry->staId, pTempStaEntry->pContext);
16494 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16495 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016496 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016497 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16498 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016499 pTempStaEntry->pPeStaEntry->numClient--;
16500 //check if we need to delete the entry from peStatsReqList too
16501 if(!pTempStaEntry->pPeStaEntry->numClient)
16502 {
16503 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16504 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016505 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016506 //check if we need to stop the tl stats timer too
16507 pMac->roam.tlStatsReqInfo.numClient--;
16508 if(!pMac->roam.tlStatsReqInfo.numClient)
16509 {
16510 if(pMac->roam.tlStatsReqInfo.timerRunning)
16511 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016512 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16513 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016514 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016515 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016516 //we will continue
16517 }
16518 }
16519 pMac->roam.tlStatsReqInfo.periodicity = 0;
16520 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16521 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016522 if (pTempStaEntry->periodicity)
16523 {
16524 //While creating StaEntry in csrGetStatistics,
16525 //Initializing and starting timer only when periodicity is set.
16526 //So Stop and Destroy timer only when periodicity is set.
16527
Jeff Johnsone7245742012-09-05 17:12:55 -070016528 vos_timer_stop( &pTempStaEntry->timer );
16529 // Destroy the vos timer...
16530 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16531 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16532 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016533 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016534 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016535 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016536
Jeff Johnson295189b2012-06-20 16:38:30 -070016537
16538 pPrevEntry = pEntry;
16539 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16540 }
16541 //the last one
16542 if(pPrevEntry)
16543 {
16544 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16545 //send up the stats report
16546 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16547 pTempStaEntry->staId, pTempStaEntry->pContext);
16548 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16549 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016550 return status;
16551
16552}
16553
Jeff Johnson295189b2012-06-20 16:38:30 -070016554eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16555 tRequestFullPowerReason *pReason,
16556 tANI_BOOLEAN *pfNeedPower )
16557{
16558 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16559 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16560 tPmcState pmcState;
16561 eHalStatus status = eHAL_STATUS_SUCCESS;
16562 // TODO : Session info unavailable
16563 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016564 if( pfNeedPower )
16565 {
16566 *pfNeedPower = eANI_BOOLEAN_FALSE;
16567 }
16568 //We only handle CSR commands
16569 if( !(eSmeCsrCommandMask & pCommand->command) )
16570 {
16571 return eHAL_STATUS_SUCCESS;
16572 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016573 //Check PMC state first
16574 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016575 switch( pmcState )
16576 {
16577 case REQUEST_IMPS:
16578 case IMPS:
16579 if( eSmeCommandScan == pCommand->command )
16580 {
16581 switch( pCommand->u.scanCmd.reason )
16582 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016583#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16584 case eCsrScanGetLfrResult:
16585#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016586 case eCsrScanGetResult:
16587 case eCsrScanBGScanAbort:
16588 case eCsrScanBGScanEnable:
16589 case eCsrScanGetScanChnInfo:
16590 //Internal process, no need for full power
16591 fNeedFullPower = eANI_BOOLEAN_FALSE;
16592 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016593 default:
16594 //Other scans are real scan, ask for power
16595 fNeedFullPower = eANI_BOOLEAN_TRUE;
16596 break;
16597 } //switch
16598 }
16599 else
16600 {
16601 //ask for power for roam and status change
16602 fNeedFullPower = eANI_BOOLEAN_TRUE;
16603 }
16604 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016605 case REQUEST_BMPS:
16606 case BMPS:
16607 case REQUEST_START_UAPSD:
16608 case UAPSD:
16609 //We treat WOWL same as BMPS
16610 case REQUEST_ENTER_WOWL:
16611 case WOWL:
16612 if( eSmeCommandRoam == pCommand->command )
16613 {
16614 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16615 tCsrScanResult *pScanResult;
16616 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016617 switch ( pCommand->u.roamCmd.roamReason )
16618 {
16619 case eCsrForcedDisassoc:
16620 case eCsrForcedDisassocMICFailure:
16621 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16622 fNeedFullPower = eANI_BOOLEAN_TRUE;
16623 break;
16624 case eCsrSmeIssuedDisassocForHandoff:
16625 case eCsrForcedDeauth:
16626 case eCsrHddIssuedReassocToSameAP:
16627 case eCsrSmeIssuedReassocToSameAP:
16628 fNeedFullPower = eANI_BOOLEAN_TRUE;
16629 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016630 case eCsrCapsChange:
16631 fNeedFullPower = eANI_BOOLEAN_TRUE;
16632 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016633 default:
16634 //Check whether the profile is already connected. If so, no need for full power
16635 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16636 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16637 {
16638 //Only need to check the first one
16639 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16640 if( pEntry )
16641 {
16642 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16643#if 0
16644 // TODO : Session Specific info pConnectBssDesc
16645 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16646 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16647 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16648 {
16649 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16650 // with Authenticating first. To force this, stop the current association (Disassociate) and
16651 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16652 // a new Association.
16653 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16654 {
16655 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16656 {
16657 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16658 //No need for full power
16659 //Set the flag so the code later can avoid to do the above
16660 //check again.
16661 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16662 break;
16663 }
16664 }
16665 }
16666#endif
16667 }
16668 }
16669 //If we are here, full power is needed
16670 fNeedFullPower = eANI_BOOLEAN_TRUE;
16671 break;
16672 }
16673 }
16674 else if( eSmeCommandWmStatusChange == pCommand->command )
16675 {
16676 //need full power for all
16677 fNeedFullPower = eANI_BOOLEAN_TRUE;
16678 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16679 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016680#ifdef FEATURE_WLAN_TDLS
16681 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16682 {
16683 //TDLS link is getting established. need full power
16684 fNeedFullPower = eANI_BOOLEAN_TRUE;
16685 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16686 }
16687#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016688 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016689 case REQUEST_STOP_UAPSD:
16690 case REQUEST_EXIT_WOWL:
16691 if( eSmeCommandRoam == pCommand->command )
16692 {
16693 fNeedFullPower = eANI_BOOLEAN_TRUE;
16694 switch ( pCommand->u.roamCmd.roamReason )
16695 {
16696 case eCsrForcedDisassoc:
16697 case eCsrForcedDisassocMICFailure:
16698 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16699 break;
16700 default:
16701 break;
16702 }
16703 }
16704 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016705 case STOPPED:
16706 case REQUEST_STANDBY:
16707 case STANDBY:
16708 case LOW_POWER:
16709 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016710 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016711 status = eHAL_STATUS_FAILURE;
16712 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016713 case FULL_POWER:
16714 case REQUEST_FULL_POWER:
16715 default:
16716 //No need to ask for full power. This has to be FULL_POWER state
16717 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016718 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016719 if( pReason )
16720 {
16721 *pReason = reason;
16722 }
16723 if( pfNeedPower )
16724 {
16725 *pfNeedPower = fNeedFullPower;
16726 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016727 return ( status );
16728}
16729
Jeff Johnson295189b2012-06-20 16:38:30 -070016730static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16731{
16732 eHalStatus status = eHAL_STATUS_SUCCESS;
16733 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16734 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016735 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016736 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16737 {
16738 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16739 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016740 return ( status );
16741}
16742
Jeff Johnson295189b2012-06-20 16:38:30 -070016743tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16744{
16745 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016746 if( pCmd )
16747 {
16748 pMac->roam.sPendingCommands++;
16749 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016750 return ( pCmd );
16751}
16752
Jeff Johnson295189b2012-06-20 16:38:30 -070016753void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16754{
16755 if (pMac->roam.sPendingCommands > 0)
16756 {
16757 //All command allocated through csrGetCommandBuffer need to
16758 //decrement the pending count when releasing.
16759 pMac->roam.sPendingCommands--;
16760 smeReleaseCommand( pMac, pCommand );
16761 }
16762 else
16763 {
16764 smsLog(pMac, LOGE, FL( "no pending commands"));
16765 VOS_ASSERT(0);
16766 }
16767}
16768
Jeff Johnson295189b2012-06-20 16:38:30 -070016769//Return SUCCESS is the command is queued, failed
16770eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16771{
16772 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016773 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16774 {
16775 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16776 pCommand->u.scanCmd.reason);
16777 return eHAL_STATUS_CSR_WRONG_STATE;
16778 }
16779
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016780 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16781 {
16782 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16783 &pCommand->Link, LL_ACCESS_LOCK);
16784 // process the command queue...
16785 smeProcessPendingQueue(pMac);
16786 status = eHAL_STATUS_SUCCESS;
16787 goto end;
16788 }
16789
Jeff Johnson295189b2012-06-20 16:38:30 -070016790 //We can call request full power first before putting the command into pending Q
16791 //because we are holding SME lock at this point.
16792 status = csrRequestFullPower( pMac, pCommand );
16793 if( HAL_STATUS_SUCCESS( status ) )
16794 {
16795 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016796 //make sure roamCmdPendingList is not empty first
16797 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16798 if( fNoCmdPending )
16799 {
16800 smePushCommand( pMac, pCommand, fHighPriority );
16801 }
16802 else
16803 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016804 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016805 //no list lock is needed since SME lock is held
16806 if( !fHighPriority )
16807 {
16808 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16809 }
16810 else {
16811 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16812 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016813 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016814 }
16815 else if( eHAL_STATUS_PMC_PENDING == status )
16816 {
16817 //no list lock is needed since SME lock is held
16818 if( !fHighPriority )
16819 {
16820 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16821 }
16822 else {
16823 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16824 }
16825 //Let caller know the command is queue
16826 status = eHAL_STATUS_SUCCESS;
16827 }
16828 else
16829 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016830 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016831 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016832 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016833 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016834end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016835 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016836}
Jeff Johnson295189b2012-06-20 16:38:30 -070016837eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16838{
16839 eHalStatus status = eHAL_STATUS_SUCCESS;
16840 tSirUpdateAPWPSIEsReq *pMsg;
16841 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16842
16843 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16844 if (NULL == pSession)
16845 {
16846 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16847 return eHAL_STATUS_FAILURE;
16848 }
16849
Jeff Johnson295189b2012-06-20 16:38:30 -070016850 do
16851 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016852 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
16853 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16854 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016855 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
16856
16857 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070016858 VOS_ASSERT(pBuf);
16859
Jeff Johnson295189b2012-06-20 16:38:30 -070016860 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016861 // transactionId
16862 *pBuf = 0;
16863 *( pBuf + 1 ) = 0;
16864 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070016865 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016866 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16867 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016868 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016869 //sessionId
16870 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016871 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016872 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070016873 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070016874 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016875 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016876 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016877 return ( status );
16878}
Jeff Johnson295189b2012-06-20 16:38:30 -070016879eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
16880{
16881 eHalStatus status = eHAL_STATUS_SUCCESS;
16882 tSirUpdateAPWPARSNIEsReq *pMsg;
16883 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016884 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16885 if (NULL == pSession)
16886 {
16887 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16888 return eHAL_STATUS_FAILURE;
16889 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016890 do
16891 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016892 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
16893 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16894 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016895 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016896 pBuf = (tANI_U8 *)&pMsg->transactionId;
16897 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016898 // transactionId
16899 *pBuf = 0;
16900 *( pBuf + 1 ) = 0;
16901 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070016902 VOS_ASSERT(pBuf);
16903
Jeff Johnson295189b2012-06-20 16:38:30 -070016904 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016905 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16906 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016907 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016908 // sessionId
16909 *pBuf++ = (tANI_U8)sessionId;
16910
16911 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016912 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070016913 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070016914 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016915 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016916 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016917 return ( status );
16918}
Jeff Johnson295189b2012-06-20 16:38:30 -070016919
16920#ifdef WLAN_FEATURE_VOWIFI_11R
16921//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
16922eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
16923{
16924 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16925 tpSirFTPreAuthReq pftPreAuthReq;
16926 tANI_U16 auth_req_len = 0;
16927 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016928 auth_req_len = sizeof(tSirFTPreAuthReq);
16929 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053016930 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070016931 {
16932 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
16933 return eHAL_STATUS_RESOURCES;
16934 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016935 // Save the SME Session ID here. We need it while processing the preauth response
16936 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016937 vos_mem_zero(pftPreAuthReq, auth_req_len);
16938
16939 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
16940 sizeof(pBssDescription->length) + pBssDescription->length);
16941
16942 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
16943
16944 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
16945
Kiet Lam64c1b492013-07-12 13:56:44 +053016946 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
16947 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
16948 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
16949 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016950
Jeff Johnson295189b2012-06-20 16:38:30 -070016951#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080016952 if (csrRoamIs11rAssoc(pMac) &&
16953 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070016954 {
16955 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053016956 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
16957 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070016958 }
16959 else
16960#endif
16961 {
16962 pftPreAuthReq->ft_ies_length = 0;
16963 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070016964 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
16965 sizeof(pBssDescription->length) + pBssDescription->length);
16966 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070016967 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
16968}
Jeff Johnson295189b2012-06-20 16:38:30 -070016969/*--------------------------------------------------------------------------
16970 * This will receive and process the FT Pre Auth Rsp from the current
16971 * associated ap.
16972 *
16973 * This will invoke the hdd call back. This is so that hdd can now
16974 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
16975 ------------------------------------------------------------------------*/
16976void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
16977{
16978 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16979 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016980#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016981 tCsrRoamInfo roamInfo;
16982#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016983
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016984#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016985 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016986 if (status != eHAL_STATUS_SUCCESS) {
16987 /*
16988 * Bail out if pre-auth was not even processed.
16989 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016990 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
16991 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016992 return;
16993 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016994#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016995 /* The below function calls/timers should be invoked only if the pre-auth is successful */
16996 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
16997 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070016998 // Implies a success
16999 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017000 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
17001 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070017002 /* No need to notify qos module if this is a non 11r roam*/
17003 if (csrRoamIs11rAssoc(pMac))
17004 {
17005 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
17006 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017007 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
17008 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017009 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
17010 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070017011 if (eHAL_STATUS_SUCCESS != status)
17012 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017013 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017014 return;
17015 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017016 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017017 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
17018 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070017019 if (csrRoamIs11rAssoc(pMac))
17020 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
17021 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
17022
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017023#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17024 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017025 {
17026 /* read TSF */
17027 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
17028
17029 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017030 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017031 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
17032 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017033#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017034#ifdef FEATURE_WLAN_LFR
17035 // If Legacy Fast Roaming is enabled, signal the supplicant
17036 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053017037 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017038 {
17039 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017040 vos_mem_copy((void *)&roamInfo.bssid,
17041 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017042 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
17043 }
17044
17045#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017046
17047 // Done with it, init it.
17048 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
17049}
17050#endif
17051#ifdef FEATURE_WLAN_BTAMP_UT_RF
17052void csrRoamJoinRetryTimerHandler(void *pv)
17053{
17054 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
17055 tpAniSirGlobal pMac = pInfo->pMac;
17056 tANI_U32 sessionId = pInfo->sessionId;
17057 tCsrRoamSession *pSession;
17058
17059 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17060 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017061 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017062 pSession = CSR_GET_SESSION( pMac, sessionId );
17063 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
17064 {
17065 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
17066 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017067 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017068 }
17069 }
17070 }
17071}
Jeff Johnson295189b2012-06-20 16:38:30 -070017072eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
17073{
17074 eHalStatus status = eHAL_STATUS_FAILURE;
17075 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17076
17077 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
17078 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017079 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070017080 pSession->maxRetryCount--;
17081 pSession->joinRetryTimerInfo.pMac = pMac;
17082 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017083 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
17084 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017085 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017086 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017087 }
17088 }
17089 else
17090 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017091 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070017092 pSession->maxRetryCount);
17093 }
17094
17095 return (status);
17096}
Jeff Johnson295189b2012-06-20 16:38:30 -070017097eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
17098{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017099 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070017100 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17101 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017102 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070017103 }
17104
17105 return eHAL_STATUS_SUCCESS;
17106}
17107#endif
17108
17109
17110/*
17111 pBuf points to the beginning of the message
17112 LIM packs disassoc rsp as below,
17113 messageType - 2 bytes
17114 messageLength - 2 bytes
17115 sessionId - 1 byte
17116 transactionId - 2 bytes (tANI_U16)
17117 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17118 peerMacAddr - 6 bytes
17119 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17120*/
17121static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17122{
17123 if(pBuf && pRsp)
17124 {
17125 pBuf += 4; //skip type and length
17126 pRsp->sessionId = *pBuf++;
17127 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17128 pBuf += 2;
17129 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17130 pBuf += 4;
17131 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17132 }
17133}
17134
Jeff Johnsond13512a2012-07-17 11:42:19 -070017135eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17136{
17137 static uNvTables nvTables;
17138 eHalStatus status = eHAL_STATUS_SUCCESS;
17139 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17140
17141 /* read the country code from NV and use it */
17142 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17143 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017144 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17145 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017146 return status;
17147 }
17148 else
17149 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017150 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017151 status = eHAL_STATUS_FAILURE;
17152 return status;
17153 }
17154}
17155
17156eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17157{
Kiet Lam64c1b492013-07-12 13:56:44 +053017158 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017159 return eHAL_STATUS_SUCCESS;
17160}
schang86c22c42013-03-13 18:41:24 -070017161
17162eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17163{
17164 tSirSetTxPowerReq *pMsg = NULL;
17165 eHalStatus status = eHAL_STATUS_SUCCESS;
17166 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17167
17168 if (!pSession)
17169 {
17170 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17171 return eHAL_STATUS_FAILURE;
17172 }
17173
Kiet Lam64c1b492013-07-12 13:56:44 +053017174 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17175 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17176 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17177 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17178 pMsg->length = sizeof(tSirSetTxPowerReq);
17179 pMsg->mwPower = mW;
17180 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17181 sizeof(tSirMacAddr));
17182 status = palSendMBMessage(pMac->hHdd, pMsg);
17183 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017184 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017185 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17186 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017187 }
17188 return status;
17189}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017190
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017191eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17192{
17193 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17194 eHalStatus status = eHAL_STATUS_SUCCESS;
17195 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17196
17197 if (!pSession)
17198 {
17199 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17200 return eHAL_STATUS_FAILURE;
17201 }
17202 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17203 {
17204 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
17205 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17206 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17207 pMsg->length = sizeof(tANI_U8);
17208 pMsg->seesionId = sessionId;
17209 status = palSendMBMessage(pMac->hHdd, pMsg);
17210 if (!HAL_STATUS_SUCCESS(status))
17211 {
17212 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17213 //pMsg is freed by palSendMBMessage
17214 }
17215 }
17216 else
17217 {
17218 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17219 status = eHAL_STATUS_FAILURE;
17220 }
17221 return status;
17222}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017223/* Returns whether a session is in VOS_STA_MODE...or not */
17224tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17225{
17226 tCsrRoamSession *pSession = NULL;
17227 pSession = CSR_GET_SESSION ( pMac, sessionId );
17228 if(!pSession)
17229 {
17230 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17231 return eANI_BOOLEAN_FALSE;
17232 }
17233 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17234 {
17235 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17236 return eANI_BOOLEAN_FALSE;
17237 }
17238 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17239 {
17240 return eANI_BOOLEAN_FALSE;
17241 }
17242 /* There is a possibility that the above check may fail,because
17243 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17244 * when it is connected.So,we may sneak through the above check even
17245 * if we are not a STA mode INFRA station. So, if we sneak through
17246 * the above condition, we can use the following check if we are
17247 * really in STA Mode.*/
17248
17249 if ( NULL != pSession->pCurRoamProfile )
17250 {
17251 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17252 {
17253 return eANI_BOOLEAN_TRUE;
17254 } else {
17255 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17256 return eANI_BOOLEAN_FALSE;
17257 }
17258 }
17259
17260 return eANI_BOOLEAN_FALSE;
17261}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017262
17263#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17264eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17265 tCsrHandoffRequest *pHandoffInfo)
17266{
17267 eHalStatus status = eHAL_STATUS_SUCCESS;
17268 vos_msg_t msg;
17269
17270 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017271 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17272 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017273 {
17274 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017275 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017276 }
17277 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17278 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17279 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17280 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017281 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017282 pHandoffInfo->bssid,
17283 6);
17284 msg.type = eWNI_SME_HANDOFF_REQ;
17285 msg.bodyptr = pMsg;
17286 msg.reserved = 0;
17287 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17288 {
17289 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017290 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017291 status = eHAL_STATUS_FAILURE;
17292 }
17293 return status;
17294}
17295#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017296
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017297
17298#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017299/* ---------------------------------------------------------------------------
17300 \fn csrSetCCKMIe
17301 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17302 data structure and this IE will be packed inside reassociation request
17303 \param pMac - pMac global structure
17304 \param sessionId - Current session id
17305 \param pCckmIe - pointer to CCKM IE data
17306 \param ccKmIeLen - length of the CCKM IE
17307 \- return Success or failure
17308 -------------------------------------------------------------------------*/
17309VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17310 const tANI_U8 *pCckmIe,
17311 const tANI_U8 ccKmIeLen)
17312{
17313 eHalStatus status = eHAL_STATUS_SUCCESS;
17314 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17315
17316 if (!pSession)
17317 {
17318 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17319 return eHAL_STATUS_FAILURE;
17320 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017321 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017322 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17323 return status;
17324}
17325
17326/* ---------------------------------------------------------------------------
17327 \fn csrRoamReadTSF
17328 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17329 probe response reception from the hand off AP to arrive at the latest TSF value.
17330 \param pMac - pMac global structure
17331 \param pTimestamp - output TSF timestamp
17332 \- return Success or failure
17333 -------------------------------------------------------------------------*/
17334VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17335{
17336 eHalStatus status = eHAL_STATUS_SUCCESS;
17337 tCsrNeighborRoamBSSInfo handoffNode;
17338 tANI_U32 timer_diff = 0;
17339 tANI_U32 timeStamp[2];
17340 tpSirBssDescription pBssDescription = NULL;
17341
17342 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17343 pBssDescription = handoffNode.pBssDescription;
17344
17345 // Get the time diff in milli seconds
17346 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17347 // Convert msec to micro sec timer
17348 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17349
17350 timeStamp[0] = pBssDescription->timeStamp[0];
17351 timeStamp[1] = pBssDescription->timeStamp[1];
17352
17353 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17354
Kiet Lamf2f201e2013-11-16 21:24:16 +053017355 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017356 sizeof (tANI_U32) * 2);
17357 return status;
17358}
17359
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017360#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017361