blob: 1c4679a19b12ad0c55078fade40c51353536bb4a [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);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004408 /* The OSEN IE doesn't provide the cipher suite.
4409 * Therefore set to constant value of AES */
4410 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4411 {
4412 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4413 eCSR_ENCRYPT_TYPE_AES;
4414 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4415 eCSR_ENCRYPT_TYPE_AES;
4416 }
4417 else
4418 {
4419 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4420 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4421 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4422 pScanResult->mcEncryptionType;
4423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004424 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4425 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4426 {
4427 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4428 {
4429 eRoamState = eCsrStartIbssSameIbss;
4430 break;
4431 }
4432 }
4433 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4434 {
4435 //trying to connect to the one already connected
4436 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4437 eRoamState = eCsrReassocToSelfNoCapChange;
4438 break;
4439 }
4440 // Attempt to Join this Bss...
4441 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4442 break;
4443 }
4444
4445 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4447 {
4448 //Need to indicate association_completion if association_start has been done
4449 if(pSession->bRefAssocStartCnt > 0)
4450 {
4451 pSession->bRefAssocStartCnt--;
4452 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004453 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4455 eCSR_ROAM_ASSOCIATION_COMPLETION,
4456 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4457 }
4458 }
4459
4460 return( eRoamState );
4461}
4462
Jeff Johnson295189b2012-06-20 16:38:30 -07004463static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4464{
4465 eHalStatus status = eHAL_STATUS_SUCCESS;
4466 eCsrJoinState RoamState;
4467 tANI_U32 sessionId = pCommand->sessionId;
4468
Jeff Johnson295189b2012-06-20 16:38:30 -07004469 //***if( hddIsRadioStateOn( pAdapter ) )
4470 {
4471 // Attept to join a Bss...
4472 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004473
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004475 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 {
4477 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 // and if connected in Infrastructure mode...
4479 if ( csrIsConnStateInfra(pMac, sessionId) )
4480 {
4481 //... then we need to issue a disassociation
4482 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4483 if(!HAL_STATUS_SUCCESS(status))
4484 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004485 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 //roam command is completed by caller in the failed case
4487 fComplete = eANI_BOOLEAN_TRUE;
4488 }
4489 }
4490 else if( csrIsConnStateIbss(pMac, sessionId) )
4491 {
4492 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4493 if(!HAL_STATUS_SUCCESS(status))
4494 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004495 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004496 //roam command is completed by caller in the failed case
4497 fComplete = eANI_BOOLEAN_TRUE;
4498 }
4499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4501 {
4502 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4503 if(!HAL_STATUS_SUCCESS(status))
4504 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004505 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 //roam command is completed by caller in the failed case
4507 fComplete = eANI_BOOLEAN_TRUE;
4508 }
4509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 else
4511 {
4512 fComplete = eANI_BOOLEAN_TRUE;
4513 }
4514 if(fComplete)
4515 {
4516 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004517 if(eCsrStopRoamingDueToConcurrency == RoamState)
4518 {
4519 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4520 }
4521 else
4522 {
4523 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4524 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 }
4526 }
4527 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4528 {
4529 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4530 }
4531 else if ( eCsrStartIbssSameIbss == RoamState )
4532 {
4533 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4534 }
4535 }//hddIsRadioStateOn
4536
4537 return status;
4538}
Jeff Johnson295189b2012-06-20 16:38:30 -07004539eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4540{
4541 tANI_U32 sessionId;
4542 tCsrRoamSession *pSession;
4543 tCsrScanResult *pScanResult = NULL;
4544 tSirBssDescription *pBssDesc = NULL;
4545 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004546 sessionId = pCommand->sessionId;
4547 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004548
4549 if(!pSession)
4550 {
4551 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4552 return eHAL_STATUS_FAILURE;
4553 }
4554
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4556 {
4557 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004558 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004559 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4560 return eHAL_STATUS_FAILURE;
4561 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004562 if (pCommand->u.roamCmd.pRoamBssEntry)
4563 {
4564 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4565 pBssDesc = &pScanResult->Result.BssDescriptor;
4566 }
4567 else
4568 {
4569 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004570 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4572 return eHAL_STATUS_FAILURE;
4573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4575 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4576 return status;
4577}
4578
Jeff Johnson295189b2012-06-20 16:38:30 -07004579eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4580{
4581 eHalStatus status = eHAL_STATUS_SUCCESS;
4582 tCsrRoamInfo roamInfo;
4583 tANI_U32 sessionId = pCommand->sessionId;
4584 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004585
4586 if(!pSession)
4587 {
4588 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4589 return eHAL_STATUS_FAILURE;
4590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004591
4592 switch ( pCommand->u.roamCmd.roamReason )
4593 {
4594 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004596 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 case eCsrSmeIssuedDisassocForHandoff:
4599 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4600#if 0 // TODO : Confirm this change
4601 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4602#else
4603 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4604#endif
4605
4606 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004609 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004610 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004613 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 case eCsrHddIssuedReassocToSameAP:
4616 case eCsrSmeIssuedReassocToSameAP:
4617 {
4618 tDot11fBeaconIEs *pIes = NULL;
4619
Jeff Johnson295189b2012-06-20 16:38:30 -07004620 if( pSession->pConnectBssDesc )
4621 {
4622 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4623 if(!HAL_STATUS_SUCCESS(status) )
4624 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004625 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004626 }
4627 else
4628 {
4629 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4630 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4631 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4633 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4634 pSession->bRefAssocStartCnt++;
4635 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4636 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4637
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004638 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004639 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4640 &pCommand->u.roamCmd.roamProfile );
4641 if(!HAL_STATUS_SUCCESS(status))
4642 {
4643 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004644 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004645 }
4646
Kiet Lam64c1b492013-07-12 13:56:44 +05304647 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004648 pIes = NULL;
4649 }
4650 }
4651 break;
4652 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004654 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4656 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4657 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004658 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004659 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004660 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4661 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004662
Jeff Johnson295189b2012-06-20 16:38:30 -07004663 case eCsrStopBss:
4664 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4665 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4666 break;
4667
4668 case eCsrForcedDisassocSta:
4669 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4670 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4671 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4672 pCommand->u.roamCmd.reason);
4673 break;
4674
4675 case eCsrForcedDeauthSta:
4676 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4677 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4678 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4679 pCommand->u.roamCmd.reason);
4680 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004681
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004682 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004683 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004684 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4685 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004686 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004687
4688 default:
4689 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4690
4691 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4692 {
4693 //Remember the roaming profile
4694 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304695 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4696 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304698 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004699 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4700 }
4701 }
4702
4703 //At this point, original uapsd_mask is saved in pCurRoamProfile
4704 //uapsd_mask in the pCommand may change from this point on.
4705
4706 // Attempt to roam with the new scan results (if we need to..)
4707 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004708 if(!HAL_STATUS_SUCCESS(status))
4709 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004710 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004711 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 break;
4713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004714 return (status);
4715}
4716
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004717void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4718{
4719 pCommand->u.roamCmd.pLastRoamBss = NULL;
4720 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4721 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304722 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004723}
4724
Jeff Johnson295189b2012-06-20 16:38:30 -07004725void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4726{
4727 if(pCommand->u.roamCmd.fReleaseBssList)
4728 {
4729 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4730 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4731 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4732 }
4733 if(pCommand->u.roamCmd.fReleaseProfile)
4734 {
4735 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4736 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4737 }
4738 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4739 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304740 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004741}
4742
Jeff Johnson295189b2012-06-20 16:38:30 -07004743void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4744{
Kiet Lam64c1b492013-07-12 13:56:44 +05304745 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004746}
Jeff Johnson295189b2012-06-20 16:38:30 -07004747void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4748{
4749 tListElem *pEntry;
4750 tSmeCmd *pCommand;
4751 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004752 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004753 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4754 if ( pEntry )
4755 {
4756 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004757 // If the head of the queue is Active and it is a ROAM command, remove
4758 // and put this on the Free queue.
4759 if ( eSmeCommandRoam == pCommand->command )
4760 {
4761 //we need to process the result first before removing it from active list because state changes
4762 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4763 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4764 if( fReleaseCommand )
4765 {
4766 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4767 {
4768 csrReleaseCommandRoam( pMac, pCommand );
4769 }
4770 else
4771 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004772 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004773 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004774 }
4775 }
4776 else
4777 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004778 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004779 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004780 }
4781 }
4782 else
4783 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004784 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 }
4786 }
4787 else
4788 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004789 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004791 if( fReleaseCommand )
4792 {
4793 smeProcessPendingQueue( pMac );
4794 }
4795}
4796
Jeff Johnson295189b2012-06-20 16:38:30 -07004797void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4798{
4799 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004800 if(!pSession)
4801 {
4802 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4803 return;
4804 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304805 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4806 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004807 pSession->NumPmkidCandidate = 0;
4808}
Jeff Johnson295189b2012-06-20 16:38:30 -07004809#ifdef FEATURE_WLAN_WAPI
4810void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4811{
4812 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004813 if(!pSession)
4814 {
4815 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4816 return;
4817 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304818 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4819 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004820 pSession->NumBkidCandidate = 0;
4821}
4822#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004823extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4824
Jeff Johnson295189b2012-06-20 16:38:30 -07004825static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4826 tSirBssDescription *pSirBssDesc,
4827 tDot11fBeaconIEs *pIes)
4828{
4829 eHalStatus status = eHAL_STATUS_SUCCESS;
4830 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4831 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004832
4833 if(!pSession)
4834 {
4835 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4836 return eHAL_STATUS_FAILURE;
4837 }
4838
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 if((eCSR_AUTH_TYPE_WPA == authType) ||
4840 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4841 (eCSR_AUTH_TYPE_RSN == authType) ||
4842 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4843#if defined WLAN_FEATURE_VOWIFI_11R
4844 ||
4845 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4846 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4847#endif /* FEATURE_WLAN_WAPI */
4848#ifdef FEATURE_WLAN_WAPI
4849 ||
4850 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4851 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4852#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004853#ifdef WLAN_FEATURE_11W
4854 ||
4855 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4856#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004857 )
4858 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004859 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4860 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004861 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004862 }
4863 if( pIesLocal )
4864 {
4865 tANI_U32 nIeLen;
4866 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004867 if((eCSR_AUTH_TYPE_RSN == authType) ||
4868#if defined WLAN_FEATURE_VOWIFI_11R
4869 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4870 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4871#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004872#if defined WLAN_FEATURE_11W
4873 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4874#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004875 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4876 {
4877 if(pIesLocal->RSN.present)
4878 {
4879 //Calculate the actual length
4880 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4881 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4882 + 2 //akm_suite_count
4883 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4884 + 2; //reserved
4885 if( pIesLocal->RSN.pmkid_count )
4886 {
4887 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4888 }
4889 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304890 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4891 if (NULL == pSession->pWpaRsnRspIE)
4892 status = eHAL_STATUS_FAILURE;
4893 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004894 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304895 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004896 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4897 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4898 //copy upto akm_suites
4899 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304900 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4901 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004902 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304903 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4904 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004905 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304906 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4907 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004908 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004909 if( pIesLocal->RSN.pwise_cipher_suite_count )
4910 {
4911 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304912 vos_mem_copy(pIeBuf,
4913 pIesLocal->RSN.pwise_cipher_suites,
4914 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4916 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304917 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004918 pIeBuf += 2;
4919 if( pIesLocal->RSN.akm_suite_count )
4920 {
4921 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304922 vos_mem_copy(pIeBuf,
4923 pIesLocal->RSN.akm_suites,
4924 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4926 }
4927 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05304928 vos_mem_copy(pIeBuf,
4929 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
4930 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004931 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4932 }
4933 }
4934 }
4935 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4936 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4937 {
4938 if(pIesLocal->WPA.present)
4939 {
4940 //Calculate the actual length
4941 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4942 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4943 + 2 //auth_suite_count
4944 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4945 // The WPA capabilities follows the Auth Suite (two octects)--
4946 // this field is optional, and we always "send" zero, so just
4947 // remove it. This is consistent with our assumptions in the
4948 // frames compiler; c.f. bug 15234:
4949 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304950
4951 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4952 if ( NULL == pSession->pWpaRsnRspIE )
4953 status = eHAL_STATUS_FAILURE;
4954 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 {
4956 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4957 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4958 pIeBuf = pSession->pWpaRsnRspIE + 2;
4959 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05304960 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304962 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
4963 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304965 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
4966 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4968 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4969 }
4970 }
4971 }
4972#ifdef FEATURE_WLAN_WAPI
4973 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4974 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4975 {
4976 if(pIesLocal->WAPI.present)
4977 {
4978 //Calculate the actual length
4979 nIeLen = 4 //version + akm_suite_count
4980 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4981 + 2 //pwise_cipher_suite_count
4982 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4983 + 6; //gp_cipher_suite + preauth + reserved
4984 if( pIesLocal->WAPI.bkid_count )
4985 {
4986 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4987 }
4988
4989 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304990 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
4991 if ( NULL == pSession->pWapiRspIE )
4992 status = eHAL_STATUS_FAILURE;
4993 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 {
4995 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4996 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4997 pIeBuf = pSession->pWapiRspIE + 2;
4998 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05304999 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005000 pIeBuf += 4;
5001 if( pIesLocal->WAPI.akm_suite_count )
5002 {
5003 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305004 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5005 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305007 }
5008 vos_mem_copy(pIeBuf,
5009 &pIesLocal->WAPI.unicast_cipher_suite_count,
5010 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005012 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5013 {
5014 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305015 vos_mem_copy( pIeBuf,
5016 pIesLocal->WAPI.unicast_cipher_suites,
5017 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005018 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5019 }
lukez3c809222013-05-03 10:23:02 -07005020 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305021 vos_mem_copy(pIeBuf,
5022 pIesLocal->WAPI.multicast_cipher_suite,
5023 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005024 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305025 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305026 vos_mem_copy(pIeBuf,
5027 pIesLocal->WAPI.multicast_cipher_suite + 4,
5028 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005029 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305030 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305031 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5032
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005033 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 if( pIesLocal->WAPI.bkid_count )
5035 {
5036 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305037 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5038 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005039 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5040 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305041 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005043 }
5044 }
5045#endif /* FEATURE_WLAN_WAPI */
5046 if( !pIes )
5047 {
5048 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305049 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 }
5051 }
5052 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005053 return (status);
5054}
5055
Jeff Johnson295189b2012-06-20 16:38:30 -07005056static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5057{
5058 v_U8_t bACWeights[WLANTL_MAX_AC];
5059 v_U8_t paramBk, paramBe, paramVi, paramVo;
5060 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005061 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5062 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5063 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5064 //This doesn't address the case where the lower AC needs a real higher weight
5065 if( pIEs->WMMParams.present )
5066 {
5067 //no change to the lowest ones
5068 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5069 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5070 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5071 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5072 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5073 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5074 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5075 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5076 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5077 {
5078 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5079 fWeightChange = VOS_TRUE;
5080 }
5081 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5082 {
5083 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5084 fWeightChange = VOS_TRUE;
5085 }
5086 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5087 {
5088 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5089 fWeightChange = VOS_TRUE;
5090 }
5091 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5092 {
5093 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5094 fWeightChange = VOS_TRUE;
5095 }
5096 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5097 {
5098 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5099 fWeightChange = VOS_TRUE;
5100 }
5101 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5102 {
5103 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5104 fWeightChange = VOS_TRUE;
5105 }
5106 if(fWeightChange)
5107 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005108 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005109 bACWeights[2], bACWeights[3]);
5110 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5111 }
5112 }
5113}
Jeff Johnson295189b2012-06-20 16:38:30 -07005114#ifdef WLAN_FEATURE_VOWIFI_11R
5115//Returns whether the current association is a 11r assoc or not
5116tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5117{
5118#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5119 return csrNeighborRoamIs11rAssoc(pMac);
5120#else
5121 return eANI_BOOLEAN_FALSE;
5122#endif
5123}
5124#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005125#ifdef FEATURE_WLAN_ESE
5126//Returns whether the current association is a ESE assoc or not
5127tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005128{
5129#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005130 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005131#else
5132 return eANI_BOOLEAN_FALSE;
5133#endif
5134}
5135#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005136#ifdef FEATURE_WLAN_LFR
5137//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305138tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005139{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305140 tCsrRoamSession *pSession = NULL;
5141
5142 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5143 {
5144 pSession = CSR_GET_SESSION( pMac, sessionId );
5145 if (NULL != pSession->pCurRoamProfile)
5146 {
5147 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5148 {
5149 return eANI_BOOLEAN_FALSE;
5150 }
5151 }
5152 }
5153
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005154#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5155 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5156 {
5157 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5158 }
5159 else
5160#endif
5161 {
5162 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005163 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005164 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005165}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005166
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005167#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005168/* ---------------------------------------------------------------------------
5169
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005170 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005171
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005172 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005173
5174 \param pMac - The handle returned by macOpen.
5175
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005176 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005177
5178---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005179tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005180{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005181 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005182}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005183#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005184
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005185#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5186//Returns whether "FW based BG scan" is currently enabled...or not
5187tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5188{
5189 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5190}
5191#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005192#endif
5193
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005194#if defined(FEATURE_WLAN_ESE)
5195tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005196{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005197 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005198}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005199#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005200
Jeff Johnson295189b2012-06-20 16:38:30 -07005201//Return true means the command can be release, else not
5202static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5203 eCsrRoamCompleteResult Result, void *Context )
5204{
5205 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5206 tSirBssDescription *pSirBssDesc = NULL;
5207 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5208 tCsrScanResult *pScanResult = NULL;
5209 tCsrRoamInfo roamInfo;
5210 sme_QosAssocInfo assocInfo;
5211 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5212 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5213 tDot11fBeaconIEs *pIes = NULL;
5214 tANI_U32 sessionId = pCommand->sessionId;
5215 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5216 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5217 eRoamCmdStatus roamStatus;
5218 eCsrRoamResult roamResult;
5219 eHalStatus status;
5220 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005221 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005222
Jeff Johnson32d95a32012-09-10 13:15:23 -07005223 if(!pSession)
5224 {
5225 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5226 return eANI_BOOLEAN_FALSE;
5227 }
5228
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005229 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005230 switch( Result )
5231 {
5232 case eCsrJoinSuccess:
5233 // reset the IDLE timer
5234 // !!
5235 // !! fall through to the next CASE statement here is intentional !!
5236 // !!
5237 case eCsrReassocSuccess:
5238 if(eCsrReassocSuccess == Result)
5239 {
5240 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5241 }
5242 else
5243 {
5244 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5245 }
5246 // Success Join Response from LIM. Tell NDIS we are connected and save the
5247 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005248 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305249 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005250 //always free the memory here
5251 if(pSession->pWpaRsnRspIE)
5252 {
5253 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305254 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005255 pSession->pWpaRsnRspIE = NULL;
5256 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005257#ifdef FEATURE_WLAN_WAPI
5258 if(pSession->pWapiRspIE)
5259 {
5260 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305261 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005262 pSession->pWapiRspIE = NULL;
5263 }
5264#endif /* FEATURE_WLAN_WAPI */
5265#ifdef FEATURE_WLAN_BTAMP_UT_RF
5266 //Reset counter so no join retry is needed.
5267 pSession->maxRetryCount = 0;
5268 csrRoamStopJoinRetryTimer(pMac, sessionId);
5269#endif
5270 /* This creates problem since we have not saved the connected profile.
5271 So moving this after saving the profile
5272 */
5273 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305274
5275 /* Reset remainInPowerActiveTillDHCP as it might have been set
5276 * by last failed secured connection.
5277 * It should be set only for secured connection.
5278 */
5279 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005280 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5281 {
5282 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5283 }
5284 else
5285 {
5286 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5287 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005288 //Use the last connected bssdesc for reassoc-ing to the same AP.
5289 //NOTE: What to do when reassoc to a different AP???
5290 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5291 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5292 {
5293 pSirBssDesc = pSession->pConnectBssDesc;
5294 if(pSirBssDesc)
5295 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305296 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5297 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005298 }
5299 }
5300 else
5301 {
5302
5303 if(pCommand->u.roamCmd.pRoamBssEntry)
5304 {
5305 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5306 if(pScanResult != NULL)
5307 {
5308 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5309 //this can be NULL
5310 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305311 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5312 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005313 }
5314 }
5315 }
5316 if( pSirBssDesc )
5317 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005318 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005319 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5320 //Save WPA/RSN IE
5321 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005322#ifdef FEATURE_WLAN_ESE
5323 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005324#endif
5325
5326 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5327 // substate change.
5328 // Moving even save profile above so that below mentioned conditon is also met.
5329 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5330 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005331 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5332 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5333 // will be dropped for the security context may not be set properly.
5334 //
5335 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5336 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5337 //
5338 // this reordering was done on titan_prod_usb branch and is being replicated here.
5339 //
5340
5341 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5342 !pProfile->bWPSAssociation)
5343 {
5344 // Issue the set Context request to LIM to establish the Unicast STA context
5345 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5346 pProfile->negotiatedUCEncryptionType,
5347 pSirBssDesc, &(pSirBssDesc->bssId),
5348 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5349 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005350 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5352 }
5353 // Issue the set Context request to LIM to establish the Broadcast STA context
5354 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5355 pSirBssDesc, &BroadcastMac,
5356 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5357 }
5358 else
5359 {
5360 //Need to wait for supplicant authtication
5361 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005362 //Set the subestate to WaitForKey in case authentiation is needed
5363 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5364
Jeff Johnson295189b2012-06-20 16:38:30 -07005365 if(pProfile->bWPSAssociation)
5366 {
5367 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5368 }
5369 else
5370 {
5371 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5372 }
5373
5374 //Save sessionId in case of timeout
5375 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5376 //This time should be long enough for the rest of the process plus setting key
5377 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5378 {
5379 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005380 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5382 }
5383 }
5384
5385 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5386 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005387 if(Context)
5388 {
5389 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5390 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005391 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5392 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5393#ifdef WLAN_FEATURE_VOWIFI_11R
5394 len += pJoinRsp->parsedRicRspLen;
5395#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005396#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005397 len += pJoinRsp->tspecIeLen;
5398#endif
5399 if(len)
5400 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305401 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5402 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305404 vos_mem_copy(pSession->connectedInfo.pbFrames,
5405 pJoinRsp->frames, len);
5406 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5407 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5408 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005409#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305410 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005411#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005412#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305413 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005414#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305415 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5416 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5417 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5418 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 }
5420 }
5421 if(pCommand->u.roamCmd.fReassoc)
5422 {
5423 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5424 }
5425 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5426 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5427 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5428 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305429 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 }
5431 else
5432 {
5433 if(pCommand->u.roamCmd.fReassoc)
5434 {
5435 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5436 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5437 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5438 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5439 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5440 }
5441 }
5442#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5443 // Indicate SME-QOS with reassoc success event, only after
5444 // copying the frames
5445 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5446#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005447 roamInfo.pBssDesc = pSirBssDesc;
5448 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5449 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5450#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5451 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5452#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5453 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005454 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5455 //It may be better to let QoS do this????
5456 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5457 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005458 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005459 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5460 pmcStartUapsd( pMac, NULL, NULL );
5461 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305462 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5464 if( pSession->bRefAssocStartCnt > 0 )
5465 {
5466 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005467 //Remove this code once SLM_Sessionization is supported
5468 //BMPS_WORKAROUND_NOT_NEEDED
5469 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005470 {
5471 pMac->roam.configParam.doBMPSWorkaround = 1;
5472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5474 }
5475
5476 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 // reset the PMKID candidate list
5478 csrResetPMKIDCandidateList( pMac, sessionId );
5479 //Update TL's AC weight base on the current EDCA parameters
5480 //These parameters may change in the course of the connection, that sictuation
5481 //is not taken care here. This change is mainly to address a WIFI WMM test where
5482 //BE has a equal or higher TX priority than VI.
5483 //We only do this for infra link
5484 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5485 {
5486 csrCheckAndUpdateACWeight(pMac, pIes);
5487 }
5488#ifdef FEATURE_WLAN_WAPI
5489 // reset the BKID candidate list
5490 csrResetBKIDCandidateList( pMac, sessionId );
5491#endif /* FEATURE_WLAN_WAPI */
5492 }
5493 else
5494 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005495 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005497 csrScanCancelIdleScan(pMac);
5498 //Not to signal link up because keys are yet to be set.
5499 //The linkup function will overwrite the sub-state that we need to keep at this point.
5500 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5501 {
5502 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5505 //enough to let security and DHCP handshake succeed before entry into BMPS
5506 if (pmcShouldBmpsTimerRun(pMac))
5507 {
Abhishek Singh65d939e2014-04-25 13:33:07 +05305508 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5509 * until keys are set before going into BMPS.
5510 */
5511 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5512 {
5513 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5514 smsLog(pMac, LOG1, FL("Set remainInPowerActiveTillDHCP "
5515 "to make sure we wait until keys are set before"
5516 " going to BMPS"));
5517 }
5518
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5520 != eHAL_STATUS_SUCCESS)
5521 {
5522 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5523 }
5524 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005526 break;
5527
Jeff Johnson295189b2012-06-20 16:38:30 -07005528 case eCsrStartBssSuccess:
5529 // on the StartBss Response, LIM is returning the Bss Description that we
5530 // are beaconing. Add this Bss Description to our scan results and
5531 // chain the Profile to this Bss Description. On a Start BSS, there was no
5532 // detected Bss description (no partner) so we issued the Start Bss to
5533 // start the Ibss without any Bss description. Lim was kind enough to return
5534 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005535 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005536 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305538 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 if( CSR_IS_IBSS( pProfile ) )
5540 {
5541 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005543 else if (CSR_IS_INFRA_AP(pProfile))
5544 {
5545 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005547 else
5548 {
5549 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5550 }
5551 if( !CSR_IS_WDS_STA( pProfile ) )
5552 {
5553 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005554 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005555 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5556 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305557 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005558 roamInfo.pBssDesc = pSirBssDesc;
5559 //We need to associate_complete it first, becasue Associate_start already indicated.
5560 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5561 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5562 break;
5563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005564 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005565 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005566 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005567 }
5568 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5569 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5570 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5571 if(pSirBssDesc)
5572 {
5573 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305574 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5575 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 }
5577 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305578 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005579#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5580 {
5581 vos_log_ibss_pkt_type *pIbssLog;
5582 tANI_U32 bi;
5583
5584 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5585 if(pIbssLog)
5586 {
5587 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5588 {
5589 //We start the IBSS (didn't find any matched IBSS out there)
5590 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5591 }
5592 else
5593 {
5594 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5595 }
5596 if(pSirBssDesc)
5597 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305598 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005599 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5600 }
5601 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5602 {
5603 //***U8 is not enough for beacon interval
5604 pIbssLog->beaconInterval = (v_U8_t)bi;
5605 }
5606 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5607 }
5608 }
5609#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5610 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5611 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005612 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5613 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5615 csrRoamIssueSetContextReq( pMac, sessionId,
5616 pProfile->negotiatedMCEncryptionType,
5617 pSirBssDesc, &BroadcastMac,
5618 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5619 }
5620 }
5621 else
5622 {
5623 //Keep the state to eCSR_ROAMING_STATE_JOINING
5624 //Need to send join_req.
5625 if(pCommand->u.roamCmd.pRoamBssEntry)
5626 {
5627 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5628 {
5629 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5630 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5631 // Set the roaming substate to 'join attempt'...
5632 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005633 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005634 }
5635 }
5636 else
5637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005638 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 VOS_ASSERT( 0 );
5640 }
5641 }
5642 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5643 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5644 //trigger the connection start indication in Vista
5645 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5646 {
5647 roamStatus = eCSR_ROAM_IBSS_IND;
5648 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5649 if( CSR_IS_WDS( pProfile ) )
5650 {
5651 roamStatus = eCSR_ROAM_WDS_IND;
5652 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5653 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 if( CSR_IS_INFRA_AP( pProfile ) )
5655 {
5656 roamStatus = eCSR_ROAM_INFRA_IND;
5657 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5658 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005659
5660 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5661 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5662 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305663 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5665 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005666 //We start the IBSS (didn't find any matched IBSS out there)
5667 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005668 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305669 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5670 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005671 //Remove this code once SLM_Sessionization is supported
5672 //BMPS_WORKAROUND_NOT_NEEDED
5673 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005674 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005675 {
5676 pMac->roam.configParam.doBMPSWorkaround = 1;
5677 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005678
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5680 }
5681
5682 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005683
5684 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 {
5686 //need to send stop BSS because we fail to send join_req
5687 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5688 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5689 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5690 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005691 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 case eCsrStartBssFailure:
5693#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5694 {
5695 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5697 if(pIbssLog)
5698 {
5699 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5700 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5701 }
5702 }
5703#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005704 roamStatus = eCSR_ROAM_IBSS_IND;
5705 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5706 if( CSR_IS_WDS( pProfile ) )
5707 {
5708 roamStatus = eCSR_ROAM_WDS_IND;
5709 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005711 if( CSR_IS_INFRA_AP( pProfile ) )
5712 {
5713 roamStatus = eCSR_ROAM_INFRA_IND;
5714 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5715 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005716 if(Context)
5717 {
5718 pSirBssDesc = (tSirBssDescription *)Context;
5719 }
5720 else
5721 {
5722 pSirBssDesc = NULL;
5723 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305724 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005725 roamInfo.pBssDesc = pSirBssDesc;
5726 //We need to associate_complete it first, becasue Associate_start already indicated.
5727 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5728 csrSetDefaultDot11Mode( pMac );
5729 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005730 case eCsrSilentlyStopRoaming:
5731 // We are here because we try to start the same IBSS
5732 //No message to PE
5733 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005734 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005735 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5736 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305737 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005738 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5739 if( roamInfo.pBssDesc )
5740 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305741 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5742 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005743 }
5744 //Since there is no change in the current state, simply pass back no result otherwise
5745 //HDD may be mistakenly mark to disconnected state.
5746 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5747 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 case eCsrSilentlyStopRoamingSaveState:
5750 //We are here because we try to connect to the same AP
5751 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005752 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305753 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005754
5755 //to aviod resetting the substate to NONE
5756 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5757 //No need to change substate to wai_for_key because there is no state change
5758 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5759 if( roamInfo.pBssDesc )
5760 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305761 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5762 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5765 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5766 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5767 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5768 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5769 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5770 roamInfo.staId = pSession->connectedInfo.staId;
5771 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005772 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005773 pSession->bRefAssocStartCnt--;
5774 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5775 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5776 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5777 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005778 case eCsrReassocFailure:
5779#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5780 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5781#endif
5782 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005783 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 csrFreeConnectBssDesc(pMac, sessionId);
5785 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5786 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305787 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5789 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5790 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5791 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5792 eCSR_ROAM_WDS_IND,
5793 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5794 //Need to issue stop_bss
5795 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005796 case eCsrJoinFailure:
5797 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005798 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 default:
5800 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005801 smsLog(pMac, LOGW, FL("receives no association indication"));
5802 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005803 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5805 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5806 {
5807 //do not free for the other profiles as we need to send down stop BSS later
5808 csrFreeConnectBssDesc(pMac, sessionId);
5809 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5810 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5811 csrSetDefaultDot11Mode( pMac );
5812 }
5813
5814 switch( pCommand->u.roamCmd.roamReason )
5815 {
5816 // If this transition is because of an 802.11 OID, then we transition
5817 // back to INIT state so we sit waiting for more OIDs to be issued and
5818 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005819 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 case eCsrSmeIssuedAssocToSimilarAP:
5821 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005822 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305824 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005825 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5826 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5827 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305828 vos_mem_copy(&roamInfo.bssid,
5829 &pSession->joinFailStatusCode.bssId,
5830 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005831
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 /* Defeaturize this later if needed */
5833#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5834 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5835 if (csrRoamIsHandoffInProgress(pMac))
5836 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 /* Should indicate neighbor roam algorithm about the connect failure here */
5838 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005840#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 if(pSession->bRefAssocStartCnt > 0)
5842 {
5843 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005844 if(eCsrJoinFailureDueToConcurrency == Result)
5845 {
5846 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5847 eCSR_ROAM_ASSOCIATION_COMPLETION,
5848 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5849 }
5850 else
5851 {
5852 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 eCSR_ROAM_ASSOCIATION_COMPLETION,
5854 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005855 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005856 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005857 else
5858 {
5859 /* bRefAssocStartCnt is not incremented when
5860 * eRoamState == eCsrStopRoamingDueToConcurrency
5861 * in csrRoamJoinNextBss API. so handle this in
5862 * else case by sending assoc failure
5863 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005864 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005865 pCommand->u.scanCmd.roamId,
5866 eCSR_ROAM_ASSOCIATION_FAILURE,
5867 eCSR_ROAM_RESULT_FAILURE);
5868 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005869 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005870#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05305871 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5873#endif
5874 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5875 csrScanStartIdleScan(pMac);
5876#ifdef FEATURE_WLAN_BTAMP_UT_RF
5877 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5878 //BT activity and not able to recevie WLAN traffic. Retry the join
5879 if( CSR_IS_WDS_STA(pProfile) )
5880 {
5881 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5882 }
5883#endif
5884 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 case eCsrHddIssuedReassocToSameAP:
5886 case eCsrSmeIssuedReassocToSameAP:
5887 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5888
5889 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5890#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5891 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5892#endif
5893 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5894 csrScanStartIdleScan(pMac);
5895 break;
5896 case eCsrForcedDisassoc:
5897 case eCsrForcedDeauth:
5898 case eCsrSmeIssuedIbssJoinFailure:
5899 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5900
5901 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5902 {
5903 // Notify HDD that IBSS join failed
5904 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5905 }
5906 else
5907 {
5908 csrRoamCallCallback(pMac, sessionId, NULL,
5909 pCommand->u.roamCmd.roamId,
5910 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5911 }
5912#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5913 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5914#endif
5915 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08005916 /*
5917 *DelSta not done FW still in conneced state so dont
5918 *issue IMPS req
5919 */
5920 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
5921 {
5922 smsLog(pMac, LOGW, FL("FW still in connected state "));
5923 break;
5924 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005925 csrScanStartIdleScan(pMac);
5926 break;
5927 case eCsrForcedIbssLeave:
5928 csrRoamCallCallback(pMac, sessionId, NULL,
5929 pCommand->u.roamCmd.roamId,
5930 eCSR_ROAM_IBSS_LEAVE,
5931 eCSR_ROAM_RESULT_IBSS_STOP);
5932 break;
5933 case eCsrForcedDisassocMICFailure:
5934 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5935
5936 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5937#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5938 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5939#endif
5940 csrScanStartIdleScan(pMac);
5941 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 case eCsrStopBss:
5943 csrRoamCallCallback(pMac, sessionId, NULL,
5944 pCommand->u.roamCmd.roamId,
5945 eCSR_ROAM_INFRA_IND,
5946 eCSR_ROAM_RESULT_INFRA_STOPPED);
5947 break;
5948 case eCsrForcedDisassocSta:
5949 case eCsrForcedDeauthSta:
5950 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5951 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5952 {
5953 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005954
5955 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5956 {
5957 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05305958 vos_mem_copy(roamInfo.peerMac,
5959 pCommand->u.roamCmd.peerMac,
5960 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5962 roamInfo.statusCode = eSIR_SME_SUCCESS;
5963 status = csrRoamCallCallback(pMac, sessionId,
5964 &roamInfo, pCommand->u.roamCmd.roamId,
5965 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5966 }
5967 }
5968 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005969 case eCsrLostLink1:
5970 // if lost link roam1 failed, then issue lost link Scan2 ...
5971 csrScanRequestLostLink2(pMac, sessionId);
5972 break;
5973 case eCsrLostLink2:
5974 // if lost link roam2 failed, then issue lost link scan3 ...
5975 csrScanRequestLostLink3(pMac, sessionId);
5976 break;
5977 case eCsrLostLink3:
5978 default:
5979 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5980
5981 //We are done with one round of lostlink roaming here
5982 csrScanHandleFailedLostlink3(pMac, sessionId);
5983 break;
5984 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005985 break;
5986 }
5987 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 return ( fReleaseCommand );
5989}
5990
Jeff Johnson295189b2012-06-20 16:38:30 -07005991eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5992{
5993 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005994 return (status);
5995}
5996
Jeff Johnson295189b2012-06-20 16:38:30 -07005997eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5998{
5999 eHalStatus status = eHAL_STATUS_SUCCESS;
6000 tANI_U32 size = 0;
6001
6002 do
6003 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306004 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006005 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6006 {
6007 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306008 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6009 if ( NULL == pDstProfile->BSSIDs.bssid )
6010 status = eHAL_STATUS_FAILURE;
6011 else
6012 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006013 if(!HAL_STATUS_SUCCESS(status))
6014 {
6015 break;
6016 }
6017 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306018 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6019 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006020 }
6021 if(pSrcProfile->SSIDs.numOfSSIDs)
6022 {
6023 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306024 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6025 if ( NULL == pDstProfile->SSIDs.SSIDList )
6026 status = eHAL_STATUS_FAILURE;
6027 else
6028 status = eHAL_STATUS_SUCCESS;
6029 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006030 {
6031 break;
6032 }
6033 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306034 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6035 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 }
6037 if(pSrcProfile->nWPAReqIELength)
6038 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306039 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6040 if ( NULL == pDstProfile->pWPAReqIE )
6041 status = eHAL_STATUS_FAILURE;
6042 else
6043 status = eHAL_STATUS_SUCCESS;
6044
6045 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 {
6047 break;
6048 }
6049 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306050 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6051 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 }
6053 if(pSrcProfile->nRSNReqIELength)
6054 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306055 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6056 if ( NULL == pDstProfile->pRSNReqIE )
6057 status = eHAL_STATUS_FAILURE;
6058 else
6059 status = eHAL_STATUS_SUCCESS;
6060
6061 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 {
6063 break;
6064 }
6065 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306066 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6067 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006068 }
6069#ifdef FEATURE_WLAN_WAPI
6070 if(pSrcProfile->nWAPIReqIELength)
6071 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306072 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6073 if ( NULL == pDstProfile->pWAPIReqIE )
6074 status = eHAL_STATUS_FAILURE;
6075 else
6076 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 if(!HAL_STATUS_SUCCESS(status))
6078 {
6079 break;
6080 }
6081 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306082 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6083 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006084 }
6085#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 if(pSrcProfile->nAddIEScanLength)
6087 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306088 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6089 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006090 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306091 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306092 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306093 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6094 }
6095 else
6096 {
6097 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6098 FL(" AddIEScanLength is not valid %u"),
6099 pSrcProfile->nAddIEScanLength);
6100 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 if(pSrcProfile->nAddIEAssocLength)
6103 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306104 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6105 if ( NULL == pDstProfile->pAddIEAssoc )
6106 status = eHAL_STATUS_FAILURE;
6107 else
6108 status = eHAL_STATUS_SUCCESS;
6109
Jeff Johnson295189b2012-06-20 16:38:30 -07006110 if(!HAL_STATUS_SUCCESS(status))
6111 {
6112 break;
6113 }
6114 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306115 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6116 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006118 if(pSrcProfile->ChannelInfo.ChannelList)
6119 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306120 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6121 pSrcProfile->ChannelInfo.numOfChannels);
6122 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6123 status = eHAL_STATUS_FAILURE;
6124 else
6125 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 if(!HAL_STATUS_SUCCESS(status))
6127 {
6128 break;
6129 }
6130 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306131 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6132 pSrcProfile->ChannelInfo.ChannelList,
6133 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006135 pDstProfile->AuthType = pSrcProfile->AuthType;
6136 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6137 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6138 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6139 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6140 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006141#ifdef WLAN_FEATURE_11W
6142 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6143 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6144 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6145#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006146 pDstProfile->BSSType = pSrcProfile->BSSType;
6147 pDstProfile->phyMode = pSrcProfile->phyMode;
6148 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6149
6150#ifdef FEATURE_WLAN_WAPI
6151 if(csrIsProfileWapi(pSrcProfile))
6152 {
6153 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6154 {
6155 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6156 }
6157 }
6158#endif /* FEATURE_WLAN_WAPI */
6159 pDstProfile->CBMode = pSrcProfile->CBMode;
6160 /*Save the WPS info*/
6161 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006162 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006163 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006164 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006165 pDstProfile->privacy = pSrcProfile->privacy;
6166 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6167 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6168 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6169 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6170 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6171 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6172 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6173 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6174 pDstProfile->wps_state = pSrcProfile->wps_state;
6175 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306176 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6177 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006178#ifdef WLAN_FEATURE_VOWIFI_11R
6179 if (pSrcProfile->MDID.mdiePresent)
6180 {
6181 pDstProfile->MDID.mdiePresent = 1;
6182 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6183 }
6184#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006185 }while(0);
6186
6187 if(!HAL_STATUS_SUCCESS(status))
6188 {
6189 csrReleaseProfile(pMac, pDstProfile);
6190 pDstProfile = NULL;
6191 }
6192
6193 return (status);
6194}
Jeff Johnson295189b2012-06-20 16:38:30 -07006195eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6196{
6197 eHalStatus status = eHAL_STATUS_SUCCESS;
6198 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6199 do
6200 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306201 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006202 if(pSrcProfile->bssid)
6203 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306204 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6205 if ( NULL == pDstProfile->BSSIDs.bssid )
6206 status = eHAL_STATUS_FAILURE;
6207 else
6208 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006209 if(!HAL_STATUS_SUCCESS(status))
6210 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306211 smsLog( pMac, LOGE,
6212 FL("failed to allocate memory for BSSID"
6213 "%02x:%02x:%02x:%02x:%02x:%02x"),
6214 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6215 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 break;
6217 }
6218 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306219 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6220 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 }
6222 if(pSrcProfile->SSID.ssId)
6223 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306224 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6225 if ( NULL == pDstProfile->SSIDs.SSIDList )
6226 status = eHAL_STATUS_FAILURE;
6227 else
6228 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006229 if(!HAL_STATUS_SUCCESS(status))
6230 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306231 smsLog( pMac, LOGE,
6232 FL("failed to allocate memory for SSIDList"
6233 "%02x:%02x:%02x:%02x:%02x:%02x"),
6234 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6235 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 break;
6237 }
6238 pDstProfile->SSIDs.numOfSSIDs = 1;
6239 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6240 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306241 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6242 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006244 if(pSrcProfile->nAddIEAssocLength)
6245 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306246 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6247 if ( NULL == pDstProfile->pAddIEAssoc)
6248 status = eHAL_STATUS_FAILURE;
6249 else
6250 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006251 if(!HAL_STATUS_SUCCESS(status))
6252 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006253 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006254 break;
6255 }
6256 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306257 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6258 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006259 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306260 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6261 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6262 status = eHAL_STATUS_FAILURE;
6263 else
6264 status = eHAL_STATUS_SUCCESS;
6265
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 if(!HAL_STATUS_SUCCESS(status))
6267 {
6268 break;
6269 }
6270 pDstProfile->ChannelInfo.numOfChannels = 1;
6271 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006272 pDstProfile->AuthType.numEntries = 1;
6273 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6274 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6275 pDstProfile->EncryptionType.numEntries = 1;
6276 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6277 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6278 pDstProfile->mcEncryptionType.numEntries = 1;
6279 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6280 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6281 pDstProfile->BSSType = pSrcProfile->BSSType;
6282 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306283 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6284 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006285#ifdef WLAN_FEATURE_VOWIFI_11R
6286 if (pSrcProfile->MDID.mdiePresent)
6287 {
6288 pDstProfile->MDID.mdiePresent = 1;
6289 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6290 }
6291#endif
6292
6293 }while(0);
6294
6295 if(!HAL_STATUS_SUCCESS(status))
6296 {
6297 csrReleaseProfile(pMac, pDstProfile);
6298 pDstProfile = NULL;
6299 }
6300
6301 return (status);
6302}
6303
Jeff Johnson295189b2012-06-20 16:38:30 -07006304eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6305 tScanResultHandle hBSSList,
6306 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6307 tANI_BOOLEAN fClearScan)
6308{
6309 eHalStatus status = eHAL_STATUS_SUCCESS;
6310 tSmeCmd *pCommand;
6311
6312 pCommand = csrGetCommandBuffer(pMac);
6313 if(NULL == pCommand)
6314 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006315 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006316 status = eHAL_STATUS_RESOURCES;
6317 }
6318 else
6319 {
6320 if( fClearScan )
6321 {
6322 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306323 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006324 }
6325 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6326 if(NULL == pProfile)
6327 {
6328 //We can roam now
6329 //Since pProfile is NULL, we need to build our own profile, set everything to default
6330 //We can only support open and no encryption
6331 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6332 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6333 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6334 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6335 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6336 }
6337 else
6338 {
6339 //make a copy of the profile
6340 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6341 if(HAL_STATUS_SUCCESS(status))
6342 {
6343 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6344 }
6345 }
6346 pCommand->command = eSmeCommandRoam;
6347 pCommand->sessionId = (tANI_U8)sessionId;
6348 pCommand->u.roamCmd.hBSSList = hBSSList;
6349 pCommand->u.roamCmd.roamId = roamId;
6350 pCommand->u.roamCmd.roamReason = reason;
6351 //We need to free the BssList when the command is done
6352 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6353 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006354 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6355 FL("CSR PERSONA=%d"),
6356 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006357 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6358 if( !HAL_STATUS_SUCCESS( status ) )
6359 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006360 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006361 csrReleaseCommandRoam( pMac, pCommand );
6362 }
6363 }
6364
6365 return (status);
6366}
Jeff Johnson295189b2012-06-20 16:38:30 -07006367eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6368 tCsrRoamModifyProfileFields *pMmodProfileFields,
6369 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6370{
6371 eHalStatus status = eHAL_STATUS_SUCCESS;
6372 tSmeCmd *pCommand;
6373
6374 pCommand = csrGetCommandBuffer(pMac);
6375 if(NULL == pCommand)
6376 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006377 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 status = eHAL_STATUS_RESOURCES;
6379 }
6380 else
6381 {
6382 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306383 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 if(pProfile)
6385 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006386 //This is likely trying to reassoc to different profile
6387 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6388 //make a copy of the profile
6389 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6390 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006391 }
6392 else
6393 {
6394 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6395 //how to update WPA/WPA2 info in roamProfile??
6396 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 if(HAL_STATUS_SUCCESS(status))
6399 {
6400 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6401 }
6402 pCommand->command = eSmeCommandRoam;
6403 pCommand->sessionId = (tANI_U8)sessionId;
6404 pCommand->u.roamCmd.roamId = roamId;
6405 pCommand->u.roamCmd.roamReason = reason;
6406 //We need to free the BssList when the command is done
6407 //For reassoc there is no BSS list, so the boolean set to false
6408 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6409 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6410 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6412 if( !HAL_STATUS_SUCCESS( status ) )
6413 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006414 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006415 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6416 csrReleaseCommandRoam( pMac, pCommand );
6417 }
6418 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006419 return (status);
6420}
6421
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006422eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6423 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306424// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006425{
6426 eHalStatus status = eHAL_STATUS_SUCCESS;
6427 tSmeCmd *pCommand;
6428
6429 pCommand = csrGetCommandBuffer(pMac);
6430 if(NULL == pCommand)
6431 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006432 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006433 status = eHAL_STATUS_RESOURCES;
6434 }
6435 else
6436 {
6437 if(pBssDescription)
6438 {
6439 //copy over the parameters we need later
6440 pCommand->command = eSmeCommandRoam;
6441 pCommand->sessionId = (tANI_U8)sessionId;
6442 pCommand->u.roamCmd.roamReason = reason;
6443 //this is the important parameter
6444 //in this case we are using this field for the "next" BSS
6445 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6446 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6447 if( !HAL_STATUS_SUCCESS( status ) )
6448 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006449 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006450 csrReleaseCommandPreauth( pMac, pCommand );
6451 }
6452 }
6453 else
6454 {
6455 //Return failure
6456 status = eHAL_STATUS_RESOURCES;
6457 }
6458 }
6459 return (status);
6460}
6461
6462eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6463{
6464 tListElem *pEntry;
6465 tSmeCmd *pCommand;
6466 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6467 if ( pEntry )
6468 {
6469 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6470 if ( (eSmeCommandRoam == pCommand->command) &&
6471 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6472 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006473 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006474 pCommand->command, pCommand->u.roamCmd.roamReason);
6475 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6476 csrReleaseCommandPreauth( pMac, pCommand );
6477 }
6478 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006479 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006480 pCommand->command, pCommand->u.roamCmd.roamReason);
6481 }
6482 }
6483 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006484 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006485 }
6486 smeProcessPendingQueue( pMac );
6487 return eHAL_STATUS_SUCCESS;
6488}
6489
Jeff Johnson295189b2012-06-20 16:38:30 -07006490eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6491 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6492{
6493 eHalStatus status = eHAL_STATUS_FAILURE;
6494 tScanResultHandle hBSSList;
6495 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006496 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6497 if(HAL_STATUS_SUCCESS(status))
6498 {
6499 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6500 if(pRoamId)
6501 {
6502 *pRoamId = roamId;
6503 }
6504 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6505 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6506 if(!HAL_STATUS_SUCCESS(status))
6507 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006508 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006509 csrScanResultPurge(pMac, hBSSList);
6510 }
6511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006512 return (status);
6513}
6514
Jeff Johnson295189b2012-06-20 16:38:30 -07006515eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6516 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6517{
6518 eHalStatus status = eHAL_STATUS_SUCCESS;
6519 tScanResultHandle hBSSList;
6520 tCsrScanResultFilter *pScanFilter;
6521 tANI_U32 roamId = 0;
6522 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6523 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006524 if (NULL == pProfile)
6525 {
6526 smsLog(pMac, LOGP, FL("No profile specified"));
6527 return eHAL_STATUS_FAILURE;
6528 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306529 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6530 "encryType = %d"),
6531 lim_BssTypetoString(pProfile->BSSType),
6532 pProfile->BSSType,
6533 pProfile->AuthType.authType[0],
6534 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006535 if( CSR_IS_WDS( pProfile ) &&
6536 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6537 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006538 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006539 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006540 return status;
6541 }
6542 csrRoamCancelRoaming(pMac, sessionId);
6543 csrScanRemoveFreshScanCommand(pMac, sessionId);
6544 csrScanCancelIdleScan(pMac);
6545 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306546 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006547 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6548 {
6549 csrScanDisable(pMac);
6550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006551 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6552 //Check whether ssid changes
6553 if(csrIsConnStateConnected(pMac, sessionId))
6554 {
6555 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6556 {
6557 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6558 }
6559 }
6560#ifdef FEATURE_WLAN_BTAMP_UT_RF
6561 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6562#endif
6563 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6564 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006565 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006566 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6567 if(pRoamId)
6568 {
6569 roamId = *pRoamId;
6570 }
6571 if(!HAL_STATUS_SUCCESS(status))
6572 {
6573 fCallCallback = eANI_BOOLEAN_TRUE;
6574 }
6575 }
6576 else
6577 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306578 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6579 if ( NULL == pScanFilter )
6580 status = eHAL_STATUS_FAILURE;
6581 else
6582 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006583 if(HAL_STATUS_SUCCESS(status))
6584 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306585 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006586 //Try to connect to any BSS
6587 if(NULL == pProfile)
6588 {
6589 //No encryption
6590 pScanFilter->EncryptionType.numEntries = 1;
6591 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6592 }//we don't have a profile
6593 else
6594 {
6595 //Here is the profile we need to connect to
6596 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6597 }//We have a profile
6598 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6599 if(pRoamId)
6600 {
6601 *pRoamId = roamId;
6602 }
6603
6604 if(HAL_STATUS_SUCCESS(status))
6605 {
6606 /*Save the WPS info*/
6607 if(NULL != pProfile)
6608 {
6609 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006610 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 }
6612 else
6613 {
6614 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006615 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 do
6618 {
6619 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006621 )
6622 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006623 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6625 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6626 if(!HAL_STATUS_SUCCESS(status))
6627 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006628 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006629 fCallCallback = eANI_BOOLEAN_TRUE;
6630 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006631 else
6632 {
6633 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6634 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 break;
6636 }
6637 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006638 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 if(HAL_STATUS_SUCCESS(status))
6640 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6642 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6643 if(!HAL_STATUS_SUCCESS(status))
6644 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006645 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 csrScanResultPurge(pMac, hBSSList);
6647 fCallCallback = eANI_BOOLEAN_TRUE;
6648 }
6649 }//Have scan result
6650 else if(NULL != pProfile)
6651 {
6652 //Check whether it is for start ibss
6653 if(CSR_IS_START_IBSS(pProfile))
6654 {
6655 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6656 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6657 if(!HAL_STATUS_SUCCESS(status))
6658 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006659 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006660 fCallCallback = eANI_BOOLEAN_TRUE;
6661 }
6662 }
6663 else
6664 {
6665 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006666 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006667 if(!HAL_STATUS_SUCCESS(status))
6668 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006669 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 fCallCallback = eANI_BOOLEAN_TRUE;
6671 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006672 else
6673 {
6674 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 }
6677 }
6678 else
6679 {
6680 fCallCallback = eANI_BOOLEAN_TRUE;
6681 }
6682 } while (0);
6683 if(NULL != pProfile)
6684 {
6685 //we need to free memory for filter if profile exists
6686 csrFreeScanFilter(pMac, pScanFilter);
6687 }
6688 }//Got the scan filter from profile
6689
Kiet Lam64c1b492013-07-12 13:56:44 +05306690 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006691 }//allocated memory for pScanFilter
6692 }//No Bsslist coming in
6693 //tell the caller if we fail to trigger a join request
6694 if( fCallCallback )
6695 {
6696 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6697 }
6698
6699 return (status);
6700}
Jeff Johnson295189b2012-06-20 16:38:30 -07006701eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6702 tCsrRoamModifyProfileFields modProfileFields,
6703 tANI_U32 *pRoamId)
6704{
6705 eHalStatus status = eHAL_STATUS_SUCCESS;
6706 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6707 tANI_U32 roamId = 0;
6708 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006709 if (NULL == pProfile)
6710 {
6711 smsLog(pMac, LOGP, FL("No profile specified"));
6712 return eHAL_STATUS_FAILURE;
6713 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306714 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6715 "encryType = %d"),
6716 lim_BssTypetoString(pProfile->BSSType),
6717 pProfile->BSSType,
6718 pProfile->AuthType.authType[0],
6719 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006720 csrRoamCancelRoaming(pMac, sessionId);
6721 csrScanRemoveFreshScanCommand(pMac, sessionId);
6722 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306723 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006724 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006725 if(csrIsConnStateConnected(pMac, sessionId))
6726 {
6727 if(pProfile)
6728 {
6729 if(pProfile->SSIDs.numOfSSIDs &&
6730 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6731 {
6732 fCallCallback = eANI_BOOLEAN_FALSE;
6733 }
6734 else
6735 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006736 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006737 }
6738 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306739 else if (!vos_mem_compare(&modProfileFields,
6740 &pSession->connectedProfile.modifyProfileFields,
6741 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006742 {
6743 fCallCallback = eANI_BOOLEAN_FALSE;
6744 }
6745 else
6746 {
6747 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006748 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 }
6750 }
6751 else
6752 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006753 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006754 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006755 if(!fCallCallback)
6756 {
6757 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6758 if(pRoamId)
6759 {
6760 *pRoamId = roamId;
6761 }
6762
Jeff Johnson295189b2012-06-20 16:38:30 -07006763 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6764 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006765 }
6766 else
6767 {
6768 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6769 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006771 return status;
6772}
Jeff Johnson295189b2012-06-20 16:38:30 -07006773eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6774{
6775 eHalStatus status = eHAL_STATUS_FAILURE;
6776 tScanResultHandle hBSSList = NULL;
6777 tCsrScanResultFilter *pScanFilter = NULL;
6778 tANI_U32 roamId;
6779 tCsrRoamProfile *pProfile = NULL;
6780 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006781
6782 if(!pSession)
6783 {
6784 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6785 return eHAL_STATUS_FAILURE;
6786 }
6787
Jeff Johnson295189b2012-06-20 16:38:30 -07006788 do
6789 {
6790 if(pSession->pCurRoamProfile)
6791 {
6792 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306793 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006794 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306795 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6796 if ( NULL == pProfile )
6797 status = eHAL_STATUS_FAILURE;
6798 else
6799 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006800 if(!HAL_STATUS_SUCCESS(status))
6801 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306802 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006803 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306804 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006805 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306806 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6807 if ( NULL == pScanFilter )
6808 status = eHAL_STATUS_FAILURE;
6809 else
6810 status = eHAL_STATUS_SUCCESS;
6811
Jeff Johnson295189b2012-06-20 16:38:30 -07006812 if(!HAL_STATUS_SUCCESS(status))
6813 {
6814 break;
6815 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306816 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006817 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6818 if(!HAL_STATUS_SUCCESS(status))
6819 {
6820 break;
6821 }
6822 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6823 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6824 if(HAL_STATUS_SUCCESS(status))
6825 {
6826 //we want to put the last connected BSS to the very beginning, if possible
6827 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6828 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6829 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6830 if(!HAL_STATUS_SUCCESS(status))
6831 {
6832 csrScanResultPurge(pMac, hBSSList);
6833 break;
6834 }
6835 }
6836 else
6837 {
6838 //Do a scan on this profile
6839 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006840 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006841 if(!HAL_STATUS_SUCCESS(status))
6842 {
6843 break;
6844 }
6845 }
6846 }//We have a profile
6847 else
6848 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006849 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 break;
6851 }
6852 }while(0);
6853 if(pScanFilter)
6854 {
6855 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306856 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006857 }
6858 if(NULL != pProfile)
6859 {
6860 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306861 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006862 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006863 return (status);
6864}
Jeff Johnson295189b2012-06-20 16:38:30 -07006865eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6866{
6867 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006868 if(csrIsConnStateConnected(pMac, sessionId))
6869 {
6870 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6871 if(HAL_STATUS_SUCCESS(status))
6872 {
6873 status = csrRoamJoinLastProfile(pMac, sessionId);
6874 }
6875 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006876 return (status);
6877}
6878
Jeff Johnson295189b2012-06-20 16:38:30 -07006879eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6880{
6881 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006882 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006883 csrRoamCancelRoaming(pMac, sessionId);
6884 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6885 if(csrIsConnStateDisconnected(pMac, sessionId))
6886 {
6887 status = csrRoamJoinLastProfile(pMac, sessionId);
6888 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006889 return (status);
6890}
6891
Jeff Johnson295189b2012-06-20 16:38:30 -07006892eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6893{
6894 eHalStatus status = eHAL_STATUS_SUCCESS;
6895 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6896 eCsrRoamSubState NewSubstate;
6897 tANI_U32 sessionId = pCommand->sessionId;
6898
6899 // change state to 'Roaming'...
6900 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6901
6902 if ( csrIsConnStateIbss( pMac, sessionId ) )
6903 {
6904 // If we are in an IBSS, then stop the IBSS...
6905 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6906 fComplete = (!HAL_STATUS_SUCCESS(status));
6907 }
6908 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6909 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006910 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 -07006911 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6912 //Restore AC weight in case we change it
6913 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6914 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6915 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6916 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6917 {
6918 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6919 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05306920 else
6921 {
6922 // If we are in neighbor preauth done state then on receiving
6923 // disassoc or deauth we dont roam instead we just disassoc
6924 // from current ap and then go to disconnected state
6925 // This happens for ESE and 11r FT connections ONLY.
6926#ifdef WLAN_FEATURE_VOWIFI_11R
6927 if (csrRoamIs11rAssoc(pMac) &&
6928 (csrNeighborRoamStatePreauthDone(pMac)))
6929 {
6930 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6931 }
6932#endif
6933#ifdef FEATURE_WLAN_ESE
6934 if (csrRoamIsESEAssoc(pMac) &&
6935 (csrNeighborRoamStatePreauthDone(pMac)))
6936 {
6937 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6938 }
6939#endif
6940#ifdef FEATURE_WLAN_LFR
6941 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
6942 (csrNeighborRoamStatePreauthDone(pMac)))
6943 {
6944 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6945 }
6946#endif
6947 }
6948
Jeff Johnson295189b2012-06-20 16:38:30 -07006949 if( fDisassoc )
6950 {
6951 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6952 }
6953 else
6954 {
6955 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6956 }
6957 fComplete = (!HAL_STATUS_SUCCESS(status));
6958 }
6959 else if ( csrIsConnStateWds( pMac, sessionId ) )
6960 {
6961 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6962 {
6963 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6964 fComplete = (!HAL_STATUS_SUCCESS(status));
6965 }
6966 //This has to be WDS station
6967 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6968 {
6969
6970 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6971 if( fDisassoc )
6972 {
6973 status = csrRoamIssueDisassociate( pMac, sessionId,
6974 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6975 fComplete = (!HAL_STATUS_SUCCESS(status));
6976 }
6977 }
6978 } else {
6979 // we got a dis-assoc request while not connected to any peer
6980 // just complete the command
6981 fComplete = eANI_BOOLEAN_TRUE;
6982 status = eHAL_STATUS_FAILURE;
6983 }
6984 if(fComplete)
6985 {
6986 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6987 }
6988
6989 if(HAL_STATUS_SUCCESS(status))
6990 {
6991 if ( csrIsConnStateInfra( pMac, sessionId ) )
6992 {
6993 //Set the state to disconnect here
6994 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6995 }
6996 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006997 else
6998 {
6999 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007001 return (status);
7002}
7003
Jeff Johnson295189b2012-06-20 16:38:30 -07007004/* This is been removed from latest code base */
7005/*
7006static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7007{
7008 eHalStatus status;
7009 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007010 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7011 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007012 return ( status );
7013}
7014*/
7015
Jeff Johnson295189b2012-06-20 16:38:30 -07007016eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7017{
7018 eHalStatus status = eHAL_STATUS_SUCCESS;
7019 tSmeCmd *pCommand;
7020 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007021 do
7022 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08007023 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007024 pCommand = csrGetCommandBuffer( pMac );
7025 if ( !pCommand )
7026 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007027 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007028 status = eHAL_STATUS_RESOURCES;
7029 break;
7030 }
7031 //Change the substate in case it is wait-for-key
7032 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7033 {
7034 csrRoamStopWaitForKeyTimer( pMac );
7035 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7036 }
7037 pCommand->command = eSmeCommandRoam;
7038 pCommand->sessionId = (tANI_U8)sessionId;
7039 switch ( reason )
7040 {
7041 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7042 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7043 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007044 case eCSR_DISCONNECT_REASON_DEAUTH:
7045 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7046 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007047 case eCSR_DISCONNECT_REASON_HANDOFF:
7048 fHighPriority = eANI_BOOLEAN_TRUE;
7049 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7050 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007051 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7052 case eCSR_DISCONNECT_REASON_DISASSOC:
7053 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7054 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007055 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7056 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7057 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007058 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7059 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7060 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007061 default:
7062 break;
7063 }
7064 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7065 if( !HAL_STATUS_SUCCESS( status ) )
7066 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007067 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007068 csrReleaseCommandRoam( pMac, pCommand );
7069 }
7070 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007071 return( status );
7072}
7073
Jeff Johnson295189b2012-06-20 16:38:30 -07007074eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7075{
7076 eHalStatus status = eHAL_STATUS_SUCCESS;
7077 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007078 pCommand = csrGetCommandBuffer( pMac );
7079 if ( NULL != pCommand )
7080 {
7081 //Change the substate in case it is wait-for-key
7082 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7083 {
7084 csrRoamStopWaitForKeyTimer( pMac );
7085 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7086 }
7087 pCommand->command = eSmeCommandRoam;
7088 pCommand->sessionId = (tANI_U8)sessionId;
7089 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7090 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7091 if( !HAL_STATUS_SUCCESS( status ) )
7092 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007093 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007094 csrReleaseCommandRoam( pMac, pCommand );
7095 }
7096 }
7097 else
7098 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007099 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007100 status = eHAL_STATUS_RESOURCES;
7101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007102 return ( status );
7103}
7104
Jeff Johnson295189b2012-06-20 16:38:30 -07007105eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7106{
7107 eHalStatus status = eHAL_STATUS_SUCCESS;
7108 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007109
7110 if(!pSession)
7111 {
7112 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7113 return eHAL_STATUS_FAILURE;
7114 }
7115
Jeff Johnson295189b2012-06-20 16:38:30 -07007116#ifdef FEATURE_WLAN_BTAMP_UT_RF
7117 //Stop te retry
7118 pSession->maxRetryCount = 0;
7119 csrRoamStopJoinRetryTimer(pMac, sessionId);
7120#endif
7121 //Not to call cancel roaming here
7122 //Only issue disconnect when necessary
7123 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7124 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7125 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7126
7127 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007128 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007129 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7130 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307131 else
7132 {
7133 smsLog( pMac, LOGE, FL("Roam command is not present"));
7134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007135 return (status);
7136}
7137
Jeff Johnson295189b2012-06-20 16:38:30 -07007138eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7139{
7140 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007141
7142 if(!pSession)
7143 {
7144 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7145 return eHAL_STATUS_FAILURE;
7146 }
7147
Jeff Johnson295189b2012-06-20 16:38:30 -07007148 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007149 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7150
7151 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7152}
7153
Jeff Johnson295189b2012-06-20 16:38:30 -07007154eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7155 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7156{
7157 eHalStatus status = eHAL_STATUS_SUCCESS;
7158 tDot11fBeaconIEs *pIesTemp = pIes;
7159 tANI_U8 index;
7160 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7161 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007162
7163 if(!pSession)
7164 {
7165 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7166 return eHAL_STATUS_FAILURE;
7167 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007168 if(pConnectProfile->pAddIEAssoc)
7169 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307170 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007171 pConnectProfile->pAddIEAssoc = NULL;
7172 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307173 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007174 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7175 pConnectProfile->AuthInfo = pProfile->AuthType;
7176 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7177 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7178 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7179 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7180 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7181 pConnectProfile->BSSType = pProfile->BSSType;
7182 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7183 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007184 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307185 if (!pConnectProfile->beaconInterval)
7186 {
7187 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7188 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307189 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007190 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7191 if(pProfile->nAddIEAssocLength)
7192 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307193 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7194 if ( NULL == pConnectProfile->pAddIEAssoc )
7195 status = eHAL_STATUS_FAILURE;
7196 else
7197 status = eHAL_STATUS_SUCCESS;
7198 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007199 {
7200 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7201 return eHAL_STATUS_FAILURE;
7202 }
7203 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307204 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7205 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007206 }
7207
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 //Save bssid
7209 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7210#ifdef WLAN_FEATURE_VOWIFI_11R
7211 if (pSirBssDesc->mdiePresent)
7212 {
7213 pConnectProfile->MDID.mdiePresent = 1;
7214 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7215 }
7216#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007217 if( NULL == pIesTemp )
7218 {
7219 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7220 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007221#ifdef FEATURE_WLAN_ESE
7222 if ((csrIsProfileESE(pProfile) ||
7223 ((pIesTemp->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +05307224 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007225 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007226 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007227 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007228 }
7229#endif
7230 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007231 if(HAL_STATUS_SUCCESS(status))
7232 {
7233 if(pIesTemp->SSID.present)
7234 {
7235 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307236 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7237 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007238 }
7239
7240 //Save the bss desc
7241 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307242
7243 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007244 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307245 //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 -07007246 pConnectProfile->qap = TRUE;
7247 }
7248 else
7249 {
7250 pConnectProfile->qap = FALSE;
7251 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007252 if ( NULL == pIes )
7253 {
7254 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307255 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007256 }
7257 }
7258 //Save Qos connection
7259 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7260
7261 if(!HAL_STATUS_SUCCESS(status))
7262 {
7263 csrFreeConnectBssDesc(pMac, sessionId);
7264 }
7265 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7266 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307267 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7268 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7269 pConnectProfile->SSID.ssId,
7270 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007271 {
7272 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7273 break;
7274 }
7275 pConnectProfile->handoffPermitted = FALSE;
7276 }
7277
7278 return (status);
7279}
7280
Jeff Johnson295189b2012-06-20 16:38:30 -07007281static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7282{
7283 tListElem *pEntry = NULL;
7284 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007285 //The head of the active list is the request we sent
7286 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7287 if(pEntry)
7288 {
7289 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007291 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7292 {
7293 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7294 {
7295#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7296 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7297#endif
7298 }
7299 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7300 }
7301 else
7302 {
7303 tANI_U32 roamId = 0;
7304 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007305 if(!pSession)
7306 {
7307 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7308 return;
7309 }
7310
Jeff Johnson295189b2012-06-20 16:38:30 -07007311
7312 //The head of the active list is the request we sent
7313 //Try to get back the same profile and roam again
7314 if(pCommand)
7315 {
7316 roamId = pCommand->u.roamCmd.roamId;
7317 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007318 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7319 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007320 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007321#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7322 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7323 if (csrRoamIsHandoffInProgress(pMac))
7324 {
7325 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7326 /* Should indicate neighbor roam algorithm about the connect failure here */
7327 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7328 }
7329#endif
7330 if (pCommand)
7331 {
7332 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7333 {
7334 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7335 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7336 csrRoamReissueRoamCommand(pMac);
7337 }
7338 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7339 {
7340 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7341 }
7342 else
7343 {
7344 csrRoam(pMac, pCommand);
7345 }
7346 }
7347 else
7348 {
7349 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7350 }
7351 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7352}
7353
Jeff Johnson295189b2012-06-20 16:38:30 -07007354eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7355 tDot11fBeaconIEs *pIes,
7356 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7357{
7358 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007359 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7360 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007361
7362 // Set the roaming substate to 'join attempt'...
7363 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007364 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007365 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007366 return (status);
7367}
7368
Jeff Johnson295189b2012-06-20 16:38:30 -07007369static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7370 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7371{
7372 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007373 // Set the roaming substate to 'join attempt'...
7374 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7375
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307376 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7377 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007378
7379 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007380 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007381}
7382
Jeff Johnson295189b2012-06-20 16:38:30 -07007383void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7384{
7385 tListElem *pEntry;
7386 tSmeCmd *pCommand;
7387 tCsrRoamInfo roamInfo;
7388 tANI_U32 sessionId;
7389 tCsrRoamSession *pSession;
7390
7391 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7392 if(pEntry)
7393 {
7394 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7395 if ( eSmeCommandRoam == pCommand->command )
7396 {
7397 sessionId = pCommand->sessionId;
7398 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007399
7400 if(!pSession)
7401 {
7402 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7403 return;
7404 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307405 /* While switching between two AP, csr will reissue roam command again
7406 to the nextbss if it was interrupted by the dissconnect req for the
7407 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7408 so reset the bRefAssocStartCnt.
7409 */
7410 if(pSession->bRefAssocStartCnt > 0)
7411 {
7412 pSession->bRefAssocStartCnt--;
7413 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007414 if( pCommand->u.roamCmd.fStopWds )
7415 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307416 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007417 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7418 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7419 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007420 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007421 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7422 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7423 eCSR_ROAM_WDS_IND,
7424 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007425 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7426 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7427 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7428 eCSR_ROAM_INFRA_IND,
7429 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7430 }
7431
Jeff Johnson295189b2012-06-20 16:38:30 -07007432
Jeff Johnson295189b2012-06-20 16:38:30 -07007433 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7434 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007435 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007436 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7437 }
7438 }
7439 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7440 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007441 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007442 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7443 }
7444 }
7445 else
7446 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007447 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007448 }
7449 }
7450 else
7451 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007452 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007453 }
7454}
7455
Jeff Johnson295189b2012-06-20 16:38:30 -07007456tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7457{
7458 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7459 tListElem *pEntry;
7460 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007461 //alwasy lock active list before locking pending list
7462 csrLLLock( &pMac->sme.smeCmdActiveList );
7463 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7464 if(pEntry)
7465 {
7466 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7467 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7468 {
7469 fRet = eANI_BOOLEAN_TRUE;
7470 }
7471 }
7472 if(eANI_BOOLEAN_FALSE == fRet)
7473 {
7474 csrLLLock(&pMac->sme.smeCmdPendingList);
7475 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7476 while(pEntry)
7477 {
7478 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7479 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7480 {
7481 fRet = eANI_BOOLEAN_TRUE;
7482 break;
7483 }
7484 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7485 }
7486 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7487 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307488 if (eANI_BOOLEAN_FALSE == fRet)
7489 {
7490 csrLLLock(&pMac->roam.roamCmdPendingList);
7491 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7492 while (pEntry)
7493 {
7494 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7495 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7496 {
7497 fRet = eANI_BOOLEAN_TRUE;
7498 break;
7499 }
7500 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7501 }
7502 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007504 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007505 return (fRet);
7506}
7507
Jeff Johnson295189b2012-06-20 16:38:30 -07007508tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7509{
7510 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7511 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007512 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7513 {
7514 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7515 {
7516 break;
7517 }
7518 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007519 return ( fRet );
7520}
7521
Jeff Johnson295189b2012-06-20 16:38:30 -07007522tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7523{
7524 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007525 //alwasy lock active list before locking pending list
7526 csrLLLock( &pMac->sme.smeCmdActiveList );
7527 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7528 if(eANI_BOOLEAN_FALSE == fRet)
7529 {
7530 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7531 }
7532 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007533 return (fRet);
7534}
7535
Jeff Johnson295189b2012-06-20 16:38:30 -07007536tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7537{
7538 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7539 tListElem *pEntry;
7540 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007541 //alwasy lock active list before locking pending list
7542 csrLLLock( &pMac->sme.smeCmdActiveList );
7543 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7544 if( pEntry )
7545 {
7546 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7547 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7548 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7549 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7550 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7551 {
7552 fRet = eANI_BOOLEAN_TRUE;
7553 }
7554 }
7555 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007556 return (fRet);
7557}
Jeff Johnson295189b2012-06-20 16:38:30 -07007558eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7559{
7560 eHalStatus status = eHAL_STATUS_SUCCESS;
7561 tSmeCmd *pCommand = NULL;
7562 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7563 tANI_BOOLEAN fRemoveCmd = FALSE;
7564 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007565 // Delete the old assoc command. All is setup for reassoc to be serialized
7566 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7567 if ( pEntry )
7568 {
7569 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7570 if ( !pCommand )
7571 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007572 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007573 return eHAL_STATUS_RESOURCES;
7574 }
7575 if ( eSmeCommandRoam == pCommand->command )
7576 {
7577 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7578 {
7579 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7580 }
7581 else
7582 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007583 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007584 }
7585 if (fRemoveCmd == FALSE)
7586 {
7587 // Implies we did not get the serialized assoc command we
7588 // were expecting
7589 pCommand = NULL;
7590 }
7591 }
7592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007593 if(NULL == pCommand)
7594 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007595 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007596 return eHAL_STATUS_RESOURCES;
7597 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007598 do
7599 {
7600 //Change the substate in case it is wait-for-key
7601 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7602 {
7603 csrRoamStopWaitForKeyTimer( pMac );
7604 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7605 }
7606 pCommand->command = eSmeCommandRoam;
7607 pCommand->sessionId = (tANI_U8)sessionId;
7608 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007609 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7610 if( !HAL_STATUS_SUCCESS( status ) )
7611 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007612 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007613 csrReleaseCommandRoam( pMac, pCommand );
7614 }
7615 } while( 0 );
7616
Jeff Johnson295189b2012-06-20 16:38:30 -07007617 return( status );
7618}
7619static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7620{
7621 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7622 tCsrScanResult *pScanResult = NULL;
7623 tSirBssDescription *pBssDesc = NULL;
7624 tSmeCmd *pCommand = NULL;
7625 tANI_U32 sessionId;
7626 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007627 if(NULL == pEntry)
7628 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307629 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 return;
7631 }
7632 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7633 sessionId = pCommand->sessionId;
7634 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007635
7636 if(!pSession)
7637 {
7638 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7639 return;
7640 }
7641
Jeff Johnson295189b2012-06-20 16:38:30 -07007642 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7643 {
7644 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007645 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007646 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7647 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007648 /* If the roaming has stopped, not to continue the roaming command*/
7649 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7650 {
7651 //No need to complete roaming here as it already completes
7652 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7653 pCommand->u.roamCmd.roamReason);
7654 csrSetAbortRoamingCommand( pMac, pCommand );
7655 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007657 else
7658 {
7659 if ( CCM_IS_RESULT_SUCCESS(result) )
7660 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007661 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007662 // Successfully set the configuration parameters for the new Bss. Attempt to
7663 // join the roaming Bss.
7664 if(pCommand->u.roamCmd.pRoamBssEntry)
7665 {
7666 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7667 pBssDesc = &pScanResult->Result.BssDescriptor;
7668 }
7669 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7670 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007672 )
7673 {
7674 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7675 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7676 pBssDesc, pCommand->u.roamCmd.roamId )))
7677 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307678 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007679 //We need to complete the command
7680 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7681 }
7682 }
7683 else
7684 {
7685 if (!pCommand->u.roamCmd.pRoamBssEntry)
7686 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307687 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007688 //We need to complete the command
7689 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7690 return;
7691 }
7692 // If we are roaming TO an Infrastructure BSS...
7693 VOS_ASSERT(pScanResult != NULL);
7694 if ( csrIsInfraBssDesc( pBssDesc ) )
7695 {
7696 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007697 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7698 {
7699 // ..and currently in an Infrastructure connection....
7700 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7701 {
7702 // ...and the SSIDs are equal, then we Reassoc.
7703 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7704 pIesLocal ) )
7705 // ..and currently in an infrastructure connection
7706 {
7707 // then issue a Reassoc.
7708 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7709 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7710 &pCommand->u.roamCmd.roamProfile );
7711 }
7712 else
7713 {
7714
7715 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7716 // previously associated AP.
7717 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7718 pIesLocal,
7719 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7720 {
7721 //try something else
7722 csrRoam( pMac, pCommand );
7723 }
7724 }
7725 }
7726 else
7727 {
7728 eHalStatus status = eHAL_STATUS_SUCCESS;
7729
7730 /* We need to come with other way to figure out that this is because of HO in BMP
7731 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007732 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07007733 * use join request */
7734#ifdef WLAN_FEATURE_VOWIFI_11R
7735 if (csrRoamIsHandoffInProgress(pMac) &&
7736 csrRoamIs11rAssoc(pMac))
7737 {
7738 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7739 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7740 }
7741 else
7742#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007743#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007744 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007745 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07007746 {
7747 // Now serialize the reassoc command.
7748 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7749 }
7750 else
7751#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007752#ifdef FEATURE_WLAN_LFR
7753 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307754 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007755 {
7756 // Now serialize the reassoc command.
7757 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7758 }
7759 else
7760#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007761 // else we are not connected and attempting to Join. Issue the
7762 // Join request.
7763 {
7764 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7765 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7766 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7767 }
7768 if(!HAL_STATUS_SUCCESS(status))
7769 {
7770 //try something else
7771 csrRoam( pMac, pCommand );
7772 }
7773 }
7774 if( !pScanResult->Result.pvIes )
7775 {
7776 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307777 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007778 }
7779 }
7780 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7781 else
7782 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007783 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007784 }
7785 }//else
7786 }//if ( WNI_CFG_SUCCESS == result )
7787 else
7788 {
7789 // In the event the configuration failed, for infra let the roam processor
7790 //attempt to join something else...
7791 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7792 {
7793 csrRoam(pMac, pCommand);
7794 }
7795 else
7796 {
7797 //We need to complete the command
7798 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7799 {
7800 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7801 }
7802 else
7803 {
7804 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7805 }
7806 }
7807 }
7808 }//we have active entry
7809}
7810
Jeff Johnson295189b2012-06-20 16:38:30 -07007811static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7812{
7813 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007814 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007815 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7816 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007817 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007818 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7819 // join the new one...
7820 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007821 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7822 }
7823 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007824 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007825 /***profHandleLostLinkAfterReset(pAdapter);
7826 // In the event the authenticate fails, let the roam processor attempt to join something else...
7827 roamRoam( pAdapter );***/
7828 }
7829}
7830
Jeff Johnson295189b2012-06-20 16:38:30 -07007831static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7832{
7833 eCsrRoamCompleteResult result;
7834 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7835 tCsrRoamInfo roamInfo;
7836 tANI_U32 roamId = 0;
7837
7838 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7839 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007840 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007841 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007842 /* Defeaturize this part later if needed */
7843#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7844 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7845 * we need the response contents while processing the result in csrRoamProcessResults() */
7846 if (csrRoamIsHandoffInProgress(pMac))
7847 {
7848 /* Need to dig more on indicating events to SME QoS module */
7849 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7850 csrRoamComplete( pMac, result, pSmeJoinRsp);
7851 }
7852 else
7853#endif
7854 {
7855 csrRoamComplete( pMac, result, NULL );
7856 }
7857 }
7858 /* Should we handle this similar to handling the join failure? Is it ok
7859 * to call csrRoamComplete() with state as CsrJoinFailure */
7860 else
7861 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007862 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007863 result = eCsrReassocFailure;
7864#ifdef WLAN_FEATURE_VOWIFI_11R
7865 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7866 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7867 {
7868 // Inform HDD to turn off FT flag in HDD
7869 if (pNeighborRoamInfo)
7870 {
7871 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7872 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7873 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007874 /*
7875 * Since the above callback sends a disconnect
7876 * to HDD, we should clean-up our state
7877 * machine as well to be in sync with the upper
7878 * layers. There is no need to send a disassoc
7879 * since: 1) we will never reassoc to the current
7880 * AP in LFR, and 2) there is no need to issue a
7881 * disassoc to the AP with which we were trying
7882 * to reassoc.
7883 */
7884 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7885 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007886 }
7887 }
7888#endif
7889 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7890 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7891 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7892 //The disassoc rsp message will remove the command from active list
7893 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7894 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7895 {
7896 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7897 }
7898 }
7899}
7900
Jeff Johnson295189b2012-06-20 16:38:30 -07007901static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7902{
Jeff Johnson295189b2012-06-20 16:38:30 -07007903#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7904 {
7905 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007906 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7907 if(pIbssLog)
7908 {
7909 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7910 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7911 {
7912 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7913 }
7914 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7915 }
7916 }
7917#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007918 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7919 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7920 {
7921 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7922 }
7923 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7924 {
7925 csrRoamReissueRoamCommand(pMac);
7926 }
7927}
7928
Jeff Johnson295189b2012-06-20 16:38:30 -07007929void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7930{
7931 tSirResultCodes statusCode;
7932#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7933 tScanResultHandle hBSSList;
7934 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7935 eHalStatus status;
7936 tCsrRoamInfo roamInfo;
7937 tCsrScanResultFilter *pScanFilter = NULL;
7938 tANI_U32 roamId = 0;
7939 tCsrRoamProfile *pCurRoamProfile = NULL;
7940 tListElem *pEntry = NULL;
7941 tSmeCmd *pCommand = NULL;
7942#endif
7943 tANI_U32 sessionId;
7944 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007945
Jeff Johnson295189b2012-06-20 16:38:30 -07007946 tSirSmeDisassocRsp SmeDisassocRsp;
7947
7948 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7949 sessionId = SmeDisassocRsp.sessionId;
7950 statusCode = SmeDisassocRsp.statusCode;
7951
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007952 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007953
7954 if ( csrIsConnStateInfra( pMac, sessionId ) )
7955 {
7956 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7957 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007958 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007959
7960 if(!pSession)
7961 {
7962 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7963 return;
7964 }
7965
Jeff Johnson295189b2012-06-20 16:38:30 -07007966 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7967 {
7968 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7969 }
7970 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7971 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7972 {
7973 if ( eSIR_SME_SUCCESS == statusCode )
7974 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007975 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007976 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7977 }
7978 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007980 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7981 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307982 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
7983 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007984#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007985 /*
7986 * First ensure if the roam profile is in the scan cache.
7987 * If not, post a reassoc failure and disconnect.
7988 */
Kiet Lam64c1b492013-07-12 13:56:44 +05307989 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7990 if ( NULL == pScanFilter )
7991 status = eHAL_STATUS_FAILURE;
7992 else
7993 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007994 if(HAL_STATUS_SUCCESS(status))
7995 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307996 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007997 status = csrRoamPrepareFilterFromProfile(pMac,
7998 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7999 if(!HAL_STATUS_SUCCESS(status))
8000 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008001 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008002 __func__, status);
8003 goto POST_ROAM_FAILURE;
8004 }
8005 else
8006 {
8007 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8008 if (!HAL_STATUS_SUCCESS(status))
8009 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008010 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008011 __func__, status);
8012 goto POST_ROAM_FAILURE;
8013 }
8014 }
8015 }
8016 else
8017 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008018 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008019 __func__, status);
8020 goto POST_ROAM_FAILURE;
8021 }
8022
8023 /*
8024 * After ensuring that the roam profile is in the scan result list,
8025 * dequeue the command from the active list.
8026 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008027 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8028 if ( pEntry )
8029 {
8030 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008031 /* If the head of the queue is Active and it is a ROAM command, remove
8032 * and put this on the Free queue.
8033 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008034 if ( eSmeCommandRoam == pCommand->command )
8035 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008036
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008037 /*
8038 * we need to process the result first before removing it from active list
8039 * because state changes still happening insides roamQProcessRoamResults so
8040 * no other roam command should be issued.
8041 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008042 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8043 if(pCommand->u.roamCmd.fReleaseProfile)
8044 {
8045 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8046 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008048 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008049 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008050 else
8051 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008052 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008053 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008054 }
8055 }
8056 else
8057 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008058 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008059 }
8060 }
8061 else
8062 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008063 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008065
8066 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008067 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8068
Kiet Lam64c1b492013-07-12 13:56:44 +05308069 vos_mem_copy(roamInfo.bssid,
8070 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8071 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008072
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008073 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8074 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008075
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008076 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308077 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8078 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008079 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308080 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008081 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8082 //make sure to put it at the head of the cmd queue
8083 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8084 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8085 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8086
Jeff Johnson295189b2012-06-20 16:38:30 -07008087 if(!HAL_STATUS_SUCCESS(status))
8088 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008089 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008090 __func__, status);
8091 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008092 }
8093
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008094 /* Notify sub-modules like QoS etc. that handoff happening */
8095 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008096 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308097 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008098 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308099 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008100 return;
8101 }
8102
8103POST_ROAM_FAILURE:
8104 if (pScanFilter)
8105 {
8106 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308107 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008108 }
8109 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308110 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008111
8112 /* Inform the upper layers that the reassoc failed */
8113 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8114 csrRoamCallCallback(pMac, sessionId,
8115 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8116
8117 /*
8118 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8119 * Upon success, we would re-enter this routine after receiving the disassoc
8120 * response and will fall into the reassoc fail sub-state. And, eventually
8121 * call csrRoamComplete which would remove the roam command from SME active
8122 * queue.
8123 */
8124 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8125 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8126 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008127 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008128 __func__, status);
8129 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008131#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008132
Jeff Johnson295189b2012-06-20 16:38:30 -07008133 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8134 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8135 {
8136 // Disassoc due to Reassoc failure falls into this codepath....
8137 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8138 }
8139 else
8140 {
8141 if ( eSIR_SME_SUCCESS == statusCode )
8142 {
8143 // Successfully disassociated from the 'old' Bss...
8144 //
8145 // We get Disassociate response in three conditions.
8146 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8147 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8148 // Infrastructure network.
8149 // - Third is where we are doing an Infra to Infra roam between networks with different
8150 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8151
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008152 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008153 }
8154 else
8155 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008156 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008157 }
8158 //We are not done yet. Get the data and continue roaming
8159 csrRoamReissueRoamCommand(pMac);
8160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008161}
8162
Jeff Johnson295189b2012-06-20 16:38:30 -07008163static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8164{
8165 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008166 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008167 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008168 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008169 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008170 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8171 {
8172 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8173 }
8174 else
8175 {
8176 if ( eSIR_SME_SUCCESS == statusCode )
8177 {
8178 // Successfully deauth from the 'old' Bss...
8179 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008180 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008181 }
8182 else
8183 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008184 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008185 }
8186 //We are not done yet. Get the data and continue roaming
8187 csrRoamReissueRoamCommand(pMac);
8188 }
8189}
8190
Jeff Johnson295189b2012-06-20 16:38:30 -07008191static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8192{
8193 eCsrRoamCompleteResult result;
8194
8195 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8196 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008197 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008198 result = eCsrStartBssSuccess;
8199 }
8200 else
8201 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008202 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008203 //Let csrRoamComplete decide what to do
8204 result = eCsrStartBssFailure;
8205 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008206 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008207}
8208
Jeff Johnson295189b2012-06-20 16:38:30 -07008209/*
8210 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8211 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8212 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8213 For the messages where sender allocates memory for specific structures, then it can be
8214 cast accordingly.
8215*/
8216void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8217{
8218 tSirSmeRsp *pSmeRsp;
8219 tSmeIbssPeerInd *pIbssPeerInd;
8220 tCsrRoamInfo roamInfo;
8221 // TODO Session Id need to be acquired in this function
8222 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008223 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308224 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8225 pSmeRsp->messageType, pSmeRsp->messageType,
8226 macTraceGetcsrRoamSubState(
8227 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008228 pSmeRsp->messageType = (pSmeRsp->messageType);
8229 pSmeRsp->length = (pSmeRsp->length);
8230 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008231 switch (pSmeRsp->messageType)
8232 {
8233
8234 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8235 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8236 {
8237 //We sent a JOIN_REQ
8238 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8239 }
8240 break;
8241
8242 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8243 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8244 {
8245 //We sent a AUTH_REQ
8246 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8247 }
8248 break;
8249
8250 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8251 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8252 {
8253 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8254 }
8255 break;
8256
8257 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8258 {
8259 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8260 }
8261 break;
8262
8263 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8264 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8265 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8266 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8267 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8268 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8269//HO
8270 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8271 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308272 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8273 macTraceGetcsrRoamSubState(
8274 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008275 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
8276 }
8277 break;
8278
8279 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8280 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8281 {
8282 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8283 }
8284 break;
8285
8286 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8287 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8288 {
8289 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8290 }
8291 break;
8292
8293 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8294 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8295 {
8296 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8297 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008298 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008299 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8300 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8301 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008302 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308303 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8304 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008305 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8306 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308307 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8308 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008309 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8310 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8311 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8312 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008313 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308314 smsLog(pMac, LOG1,
8315 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8316 pSmeRsp->messageType, pSmeRsp->messageType,
8317 macTraceGetcsrRoamSubState(
8318 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008319
8320 //If we are connected, check the link status change
8321 if(!csrIsConnStateDisconnected(pMac, sessionId))
8322 {
8323 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8324 }
8325 break;
8326 }
8327}
8328
Jeff Johnson295189b2012-06-20 16:38:30 -07008329void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8330{
8331 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008332 switch (pSirMsg->messageType)
8333 {
8334 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008335 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008336 csrRoamStatsRspProcessor( pMac, pSirMsg );
8337 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008338 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8339 {
8340 tCsrRoamSession *pSession;
8341 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8342 tCsrRoamInfo roamInfo;
8343 tCsrRoamInfo *pRoamInfo = NULL;
8344 tANI_U32 sessionId;
8345 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008346 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308347 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008348 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008349 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8350 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8351 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008352
8353 if(!pSession)
8354 {
8355 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8356 return;
8357 }
8358
Jeff Johnson295189b2012-06-20 16:38:30 -07008359 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8360 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008361 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8362 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8363 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008364 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8365 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308366 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8367 sizeof(tSirMacAddr));
8368 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8369 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008370 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008371 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8372 {
8373 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8374 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8375 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8376 }
8377 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8378 {
8379 vos_sleep( 100 );
8380 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8381 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8382 }
8383
Jeff Johnson295189b2012-06-20 16:38:30 -07008384 }
8385 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008386 default:
8387 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8388 break;
8389 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008390}
8391
Jeff Johnson295189b2012-06-20 16:38:30 -07008392eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8393 tSirBssDescription *pBssDescription,
8394 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8395 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8396 tANI_U8 keyId, tANI_U16 keyLength,
8397 tANI_U8 *pKey, tANI_U8 paeRole )
8398{
8399 eHalStatus status = eHAL_STATUS_SUCCESS;
8400 tAniEdType edType;
8401
8402 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8403 {
8404 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8405 }
8406
8407 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8408
8409 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8410 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8411 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8412 addKey )
8413 {
8414 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008415 setKey.encType = EncryptType;
8416 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308417 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008418 setKey.paeRole = paeRole; //0 for supplicant
8419 setKey.keyId = keyId; // Kye index
8420 setKey.keyLength = keyLength;
8421 if( keyLength )
8422 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308423 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008424 }
8425 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008427 return (status);
8428}
8429
Jeff Johnson295189b2012-06-20 16:38:30 -07008430static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8431 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8432{
8433 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8434 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008435#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008436 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008437#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008438
8439 do
8440 {
8441 pCommand = csrGetCommandBuffer(pMac);
8442 if(NULL == pCommand)
8443 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008444 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008445 status = eHAL_STATUS_RESOURCES;
8446 break;
8447 }
8448 pCommand->command = eSmeCommandSetKey;
8449 pCommand->sessionId = (tANI_U8)sessionId;
8450 // validate the key length, Adjust if too long...
8451 // for static WEP the keys are not set thru' SetContextReq
8452 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8453 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8454 {
8455 //KeyLength maybe 0 for static WEP
8456 if( pSetKey->keyLength )
8457 {
8458 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8459 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008460 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008461 break;
8462 }
8463
8464 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308465 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8466 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008467 }
8468 }
8469 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8470 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8471 {
8472 //KeyLength maybe 0 for static WEP
8473 if( pSetKey->keyLength )
8474 {
8475 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8476 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008477 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008478 break;
8479 }
8480
8481 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308482 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8483 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008484 }
8485 }
8486 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8487 {
8488 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8489 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008490 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008491 break;
8492 }
8493 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308494 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8495 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008496 }
8497 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8498 {
8499 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8500 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008501 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008502 break;
8503 }
8504 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308505 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8506 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008507 }
8508#ifdef FEATURE_WLAN_WAPI
8509 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8510 {
8511 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8512 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008513 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008514 break;
8515 }
8516 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308517 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8518 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 }
8520#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008521#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008522 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8523 {
8524 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8525 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008526 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008527 break;
8528 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008529 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308530 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008531 pSession->eseCckmInfo.reassoc_req_num=1;
8532 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008533 status = eHAL_STATUS_SUCCESS;
8534 break;
8535 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008536#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008537
Jeff Johnson295189b2012-06-20 16:38:30 -07008538#ifdef WLAN_FEATURE_11W
8539 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008540 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008541 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008542 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008543 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008544 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008545 break;
8546 }
8547 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308548 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008549 }
8550#endif
8551 status = eHAL_STATUS_SUCCESS;
8552 pCommand->u.setKeyCmd.roamId = roamId;
8553 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8554 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308555 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8556 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008557 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8558 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308559 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008560 //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
8561
8562 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8563 if( !HAL_STATUS_SUCCESS( status ) )
8564 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008565 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008566 }
8567 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008568 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008569 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008570 if ( ( NULL != pCommand ) &&
8571 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008572#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008573 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008574#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008575 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008576 {
8577 csrReleaseCommandSetKey( pMac, pCommand );
8578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008579 return( status );
8580}
8581
Jeff Johnson295189b2012-06-20 16:38:30 -07008582eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8583 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8584{
8585 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8586 tSmeCmd *pCommand = NULL;
8587 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008588 do
8589 {
8590 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008592 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008593 status = eHAL_STATUS_CSR_WRONG_STATE;
8594 break;
8595 }
8596 pCommand = csrGetCommandBuffer(pMac);
8597 if(NULL == pCommand)
8598 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008599 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008600 status = eHAL_STATUS_RESOURCES;
8601 break;
8602 }
8603 pCommand->command = eSmeCommandRemoveKey;
8604 pCommand->sessionId = (tANI_U8)sessionId;
8605 pCommand->u.removeKeyCmd.roamId = roamId;
8606 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308607 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8608 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8610 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8611 {
8612 //in this case, put it to the end of the Q incase there is a set key pending.
8613 fImediate = eANI_BOOLEAN_FALSE;
8614 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008615 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008616 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008617 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008618 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8619 if( !HAL_STATUS_SUCCESS( status ) )
8620 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008621 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008622 break;
8623 }
8624 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008625 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8626 {
8627 csrReleaseCommandRemoveKey( pMac, pCommand );
8628 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008629 return (status );
8630}
8631
Jeff Johnson295189b2012-06-20 16:38:30 -07008632eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8633{
8634 eHalStatus status;
8635 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8636 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8637 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8638 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008639#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8640 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8641 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008642 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008643 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308644 vos_mem_set(&setKeyEvent,
8645 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008646 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8647 {
8648 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8649 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8650 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8651 }
8652 else
8653 {
8654 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8655 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8656 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8657 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308658 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008659 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008660 {
8661 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008662 //It has to be static WEP here
8663 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8664 {
8665 setKeyEvent.keyId = (v_U8_t)defKeyId;
8666 }
8667 }
8668 else
8669 {
8670 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8671 }
8672 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8673 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8674 }
8675#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008676 if( csrIsSetKeyAllowed(pMac, sessionId) )
8677 {
8678 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8679 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8680 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8681 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8682 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8683 pCommand->u.setKeyCmd.keyRsc);
8684 }
8685 else
8686 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008687 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008688 //Set this status so the error handling take care of the case.
8689 status = eHAL_STATUS_CSR_WRONG_STATE;
8690 }
8691 if( !HAL_STATUS_SUCCESS(status) )
8692 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008693 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008694 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008695#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008696 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008697 {
8698 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8699 {
8700 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8701 }
8702 else
8703 {
8704 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8705 }
8706 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8707 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8708 }
8709#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008711 return ( status );
8712}
8713
Jeff Johnson295189b2012-06-20 16:38:30 -07008714eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8715{
8716 eHalStatus status;
8717 tpSirSmeRemoveKeyReq pMsg = NULL;
8718 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8719 tANI_U8 *p;
8720 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008721#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8722 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8723 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05308724 vos_mem_set(&removeKeyEvent,
8725 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008726 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8727 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8728 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308729 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008730 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8731 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8732 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8733#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008734 if( csrIsSetKeyAllowed(pMac, sessionId) )
8735 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308736 pMsg = vos_mem_malloc(wMsgLen);
8737 if ( NULL == pMsg )
8738 status = eHAL_STATUS_FAILURE;
8739 else
8740 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008741 }
8742 else
8743 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008744 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008745 //Set the error status so error handling kicks in below
8746 status = eHAL_STATUS_CSR_WRONG_STATE;
8747 }
8748 if( HAL_STATUS_SUCCESS( status ) )
8749 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308750 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008751 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8752 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008753 pMsg->sessionId = (tANI_U8)sessionId;
8754 pMsg->transactionId = 0;
8755 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8756 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8757 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308758 vos_mem_copy(p,
8759 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8760 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008761 p += sizeof(tSirMacAddr);
8762 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308763 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008764 p += sizeof(tSirMacAddr);
8765 // edType
8766 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8767 p++;
8768 // weptype
8769 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8770 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8771 {
8772 *p = (tANI_U8)eSIR_WEP_STATIC;
8773 }
8774 else
8775 {
8776 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8777 }
8778 p++;
8779 //keyid
8780 *p = pCommand->u.removeKeyCmd.keyId;
8781 p++;
8782 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008783 status = palSendMBMessage(pMac->hHdd, pMsg);
8784 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008785 if( !HAL_STATUS_SUCCESS( status ) )
8786 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008787 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008788#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8789 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008790 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008791 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8792#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008793 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008795 return ( status );
8796}
8797
Jeff Johnson295189b2012-06-20 16:38:30 -07008798eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8799{
8800 eHalStatus status;
8801
8802 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8803 {
8804 status = eHAL_STATUS_CSR_WRONG_STATE;
8805 }
8806 else
8807 {
8808 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008810 return ( status );
8811}
8812
Jeff Johnson295189b2012-06-20 16:38:30 -07008813/*
8814 Prepare a filter base on a profile for parsing the scan results.
8815 Upon successful return, caller MUST call csrFreeScanFilter on
8816 pScanFilter when it is done with the filter.
8817*/
8818eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8819 tCsrScanResultFilter *pScanFilter)
8820{
8821 eHalStatus status = eHAL_STATUS_SUCCESS;
8822 tANI_U32 size = 0;
8823 tANI_U8 index = 0;
8824
8825 do
8826 {
8827 if(pProfile->BSSIDs.numOfBSSIDs)
8828 {
8829 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308830 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8831 if ( NULL == pScanFilter->BSSIDs.bssid )
8832 status = eHAL_STATUS_FAILURE;
8833 else
8834 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008835 if(!HAL_STATUS_SUCCESS(status))
8836 {
8837 break;
8838 }
8839 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308840 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008841 }
8842 if(pProfile->SSIDs.numOfSSIDs)
8843 {
8844 if( !CSR_IS_WDS_STA( pProfile ) )
8845 {
8846 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8847 }
8848 else
8849 {
8850 //For WDS station
8851 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8852 pScanFilter->SSIDs.numOfSSIDs = 1;
8853 }
8854 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308855 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8856 if ( NULL == pScanFilter->SSIDs.SSIDList )
8857 status = eHAL_STATUS_FAILURE;
8858 else
8859 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008860 if(!HAL_STATUS_SUCCESS(status))
8861 {
8862 break;
8863 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308864 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8865 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008866 }
8867 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8868 {
8869 pScanFilter->ChannelInfo.numOfChannels = 0;
8870 pScanFilter->ChannelInfo.ChannelList = NULL;
8871 }
8872 else if(pProfile->ChannelInfo.numOfChannels)
8873 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308874 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8875 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8876 pProfile->ChannelInfo.numOfChannels);
8877 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8878 status = eHAL_STATUS_FAILURE;
8879 else
8880 status = eHAL_STATUS_SUCCESS;
8881
Jeff Johnson295189b2012-06-20 16:38:30 -07008882 pScanFilter->ChannelInfo.numOfChannels = 0;
8883 if(HAL_STATUS_SUCCESS(status))
8884 {
8885 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8886 {
8887 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8888 {
8889 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8890 = pProfile->ChannelInfo.ChannelList[index];
8891 pScanFilter->ChannelInfo.numOfChannels++;
8892 }
8893 else
8894 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008895 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008896 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008897 }
8898 }
8899 else
8900 {
8901 break;
8902 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008903 }
8904 else
8905 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308906 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008907 status = eHAL_STATUS_FAILURE;
8908 break;
8909 }
8910 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8911 pScanFilter->authType = pProfile->AuthType;
8912 pScanFilter->EncryptionType = pProfile->EncryptionType;
8913 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8914 pScanFilter->BSSType = pProfile->BSSType;
8915 pScanFilter->phyMode = pProfile->phyMode;
8916#ifdef FEATURE_WLAN_WAPI
8917 //check if user asked for WAPI with 11n or auto mode, in that case modify
8918 //the phymode to 11g
8919 if(csrIsProfileWapi(pProfile))
8920 {
8921 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8922 {
8923 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8924 }
8925 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8926 {
8927 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8928 }
8929 if(!pScanFilter->phyMode)
8930 {
8931 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8932 }
8933 }
8934#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008935 /*Save the WPS info*/
8936 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07008937 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008938 if( pProfile->countryCode[0] )
8939 {
8940 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05308941 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
8942 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008943 }
8944#ifdef WLAN_FEATURE_VOWIFI_11R
8945 if (pProfile->MDID.mdiePresent)
8946 {
8947 pScanFilter->MDID.mdiePresent = 1;
8948 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8949 }
8950#endif
8951
8952 }while(0);
8953
8954 if(!HAL_STATUS_SUCCESS(status))
8955 {
8956 csrFreeScanFilter(pMac, pScanFilter);
8957 }
8958
8959 return(status);
8960}
8961
Jeff Johnson295189b2012-06-20 16:38:30 -07008962tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8963 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8964{
8965 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8966 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008967 do
8968 {
8969 // Validate the type is ok...
8970 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8971 pCommand = csrGetCommandBuffer( pMac );
8972 if ( !pCommand )
8973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008974 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008975 break;
8976 }
8977 //Change the substate in case it is waiting for key
8978 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8979 {
8980 csrRoamStopWaitForKeyTimer( pMac );
8981 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8982 }
8983 pCommand->command = eSmeCommandWmStatusChange;
8984 pCommand->sessionId = (tANI_U8)sessionId;
8985 pCommand->u.wmStatusChangeCmd.Type = Type;
8986 if ( eCsrDisassociated == Type )
8987 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308988 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
8989 pSmeRsp,
8990 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008991 }
8992 else
8993 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308994 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
8995 pSmeRsp,
8996 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008997 }
8998 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8999 {
9000 fCommandQueued = eANI_BOOLEAN_TRUE;
9001 }
9002 else
9003 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009004 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009005 csrReleaseCommandWmStatusChange( pMac, pCommand );
9006 }
9007
Jeff Johnson295189b2012-06-20 16:38:30 -07009008 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9009 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009010 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009011 return( fCommandQueued );
9012}
9013
Jeff Johnson295189b2012-06-20 16:38:30 -07009014static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9015{
9016 v_S7_t rssi = 0;
9017 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9018 if(pGetRssiReq)
9019 {
9020 if(NULL != pGetRssiReq->pVosContext)
9021 {
9022 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9023 }
9024 else
9025 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009026 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009027 return;
9028 }
9029
9030 if(NULL != pGetRssiReq->rssiCallback)
9031 {
9032 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9033 }
9034 else
9035 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009036 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009037 return;
9038 }
9039 }
9040 else
9041 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009042 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009043 }
9044 return;
9045}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309046
9047static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9048{
9049 tANI_S8 snr = 0;
9050 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9051
9052 if (pGetSnrReq)
9053 {
9054 if (VOS_STATUS_SUCCESS !=
9055 WDA_GetSnr(pGetSnrReq->staId, &snr))
9056 {
9057 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9058 return;
9059 }
9060
9061 if (pGetSnrReq->snrCallback)
9062 {
9063 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9064 pGetSnrReq->pDevContext);
9065 }
9066 else
9067 {
9068 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9069 return;
9070 }
9071 }
9072 else
9073 {
9074 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9075 }
9076 return;
9077}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009078#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009079void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9080{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009081 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9082
Jeff Johnson36d483b2013-04-08 11:08:53 -07009083 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009084 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009085 /* Get roam Rssi request is backed up and passed back to the response,
9086 Extract the request message to fetch callback */
9087 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9088 v_S7_t rssi = pRoamRssiRsp->rssi;
9089
9090 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009091 {
9092 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9093 reqBkp->rssiCallback = NULL;
9094 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009095 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009096 }
9097 else
9098 {
9099 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9100 if (NULL != reqBkp)
9101 {
9102 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009103 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009104 }
9105 }
9106 }
9107 else
9108 {
9109 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9110 }
9111 return;
9112}
9113#endif
9114
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009115
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009116#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009117void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9118{
9119 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9120
9121 if (NULL != pTsmStatsRsp)
9122 {
9123 /* Get roam Rssi request is backed up and passed back to the response,
9124 Extract the request message to fetch callback */
9125 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9126
9127 if (NULL != reqBkp)
9128 {
9129 if (NULL != reqBkp->tsmStatsCallback)
9130 {
9131 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9132 pTsmStatsRsp->staId, reqBkp->pDevContext);
9133 reqBkp->tsmStatsCallback = NULL;
9134 }
9135 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009136 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009137 }
9138 else
9139 {
9140 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9141 if (NULL != reqBkp)
9142 {
9143 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009144 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009145 }
9146 }
9147 }
9148 else
9149 {
9150 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9151 }
9152 return;
9153}
9154
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009155void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009156{
9157 tANI_U32 roamTS2 = 0;
9158 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009159 tpPESession pSessionEntry = NULL;
9160 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009161
9162 if (NULL == pSession)
9163 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009164 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009165 return;
9166 }
9167
9168 roamTS2 = vos_timer_get_system_time();
9169 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009170 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9171 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009172 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009173
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009174 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9175 if (NULL == pSessionEntry)
9176 {
9177 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9178 return;
9179 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009180 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009181 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009182 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009183}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009184#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009185
Jeff Johnsone7245742012-09-05 17:12:55 -07009186static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9187{
9188 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9189 if(pTlRssiInd)
9190 {
9191 if(NULL != pTlRssiInd->tlCallback)
9192 {
9193 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009194 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009195 }
9196 else
9197 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009198 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009199 }
9200 }
9201 else
9202 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009203 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009204 }
9205 return;
9206}
Jeff Johnson295189b2012-06-20 16:38:30 -07009207
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309208eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9209{
9210 tpSirResetAPCapsChange pMsg;
9211 tANI_U16 len;
9212 eHalStatus status = eHAL_STATUS_SUCCESS;
9213
9214 /* Create the message and send to lim */
9215 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309216 pMsg = vos_mem_malloc(len);
9217 if ( NULL == pMsg )
9218 status = eHAL_STATUS_FAILURE;
9219 else
9220 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309221 if (HAL_STATUS_SUCCESS(status))
9222 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309223 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309224 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9225 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309226 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009227 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9228 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309229 status = palSendMBMessage(pMac->hHdd, pMsg);
9230 }
9231 else
9232 {
9233 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9234 }
9235 return status;
9236}
9237
Jeff Johnson295189b2012-06-20 16:38:30 -07009238void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9239{
9240 tSirSmeAssocInd *pAssocInd;
9241 tSirSmeDisassocInd *pDisassocInd;
9242 tSirSmeDeauthInd *pDeauthInd;
9243 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9244 tSirSmeNewBssInfo *pNewBss;
9245 tSmeIbssPeerInd *pIbssPeerInd;
9246 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9247 tSirSmeApNewCaps *pApNewCaps;
9248 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9249 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9250 tCsrRoamInfo *pRoamInfo = NULL;
9251 tCsrRoamInfo roamInfo;
9252 eHalStatus status;
9253 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9254 tCsrRoamSession *pSession = NULL;
9255 tpSirSmeSwitchChannelInd pSwitchChnInd;
9256 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309257 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009258
9259
9260 if (NULL == pSirMsg)
9261 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9262 return;
9263 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009264 switch( pSirMsg->messageType )
9265 {
9266 case eWNI_SME_ASSOC_IND:
9267 {
9268 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009269 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009270 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9271 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9272 if( HAL_STATUS_SUCCESS( status ) )
9273 {
9274 pSession = CSR_GET_SESSION(pMac, sessionId);
9275
Jeff Johnson32d95a32012-09-10 13:15:23 -07009276 if(!pSession)
9277 {
9278 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9279 return;
9280 }
9281
Jeff Johnson295189b2012-06-20 16:38:30 -07009282 pRoamInfo = &roamInfo;
9283
9284 // Required for indicating the frames to upper layer
9285 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9286 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9287
9288 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9289 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9290 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9291 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9292
9293 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9294 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9295 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9296
9297 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9298 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309299 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9300 sizeof(tSirMacAddr));
9301 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9302 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009303 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9304 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009305 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009306 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9307 {
9308 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9309 {
9310 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9311 pSession->pConnectBssDesc,
9312 &(pRoamInfo->peerMac),
9313 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9314 pRoamInfo->fAuthRequired = FALSE;
9315 }
9316 else
9317 {
9318 pRoamInfo->fAuthRequired = TRUE;
9319 }
9320 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9321 if (!HAL_STATUS_SUCCESS(status))
9322 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009324 /* Send Association completion message to PE */
9325 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9326
9327 /* send a message to CSR itself just to avoid the EAPOL frames going
9328 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009329 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9330 {
9331 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9332 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009333 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9334 {
9335 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9336 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9337 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009339 }
9340 }
9341 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009342 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009343 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309344 // Check if AP dis-associated us because of MIC failure. If so,
9345 // then we need to take action immediately and not wait till the
9346 // the WmStatusChange requests is pushed and processed
9347 tSmeCmd *pCommand;
9348
9349 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9350 status = csrRoamGetSessionIdFromBSSID( pMac,
9351 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9352 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009353 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309354 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9355 " for session %d "), sessionId);
9356 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9357 MAC_ADDRESS_STR " "
9358 " reason = %d status = %d "),
9359 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9360 pDisassocInd->reasonCode,
9361 pDisassocInd->statusCode);
9362 // If we are in neighbor preauth done state then on receiving
9363 // disassoc or deauth we dont roam instead we just disassoc
9364 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009365 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309366#ifdef WLAN_FEATURE_VOWIFI_11R
9367 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9368 {
9369 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009371#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009372#ifdef FEATURE_WLAN_ESE
9373 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309374 {
9375 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009377#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009378#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309379 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9380 {
9381 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9382 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009383#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309384 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009385
Agarwal Ashish4f616132013-12-30 23:32:50 +05309386 if (!pSession)
9387 {
9388 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9389 return;
9390 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009391
Agarwal Ashish4f616132013-12-30 23:32:50 +05309392 if ( csrIsConnStateInfra( pMac, sessionId ) )
9393 {
9394 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9395 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009396#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309397 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009398#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309399 csrRoamLinkDown(pMac, sessionId);
9400 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9401 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9402 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309403 pRoamInfo = &roamInfo;
9404 pRoamInfo->statusCode = pDisassocInd->statusCode;
9405 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9406 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009407
Agarwal Ashish4f616132013-12-30 23:32:50 +05309408 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9409 sizeof(tSirMacAddr));
9410 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9411 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009412
Agarwal Ashish4f616132013-12-30 23:32:50 +05309413 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9414 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009415
Agarwal Ashish4f616132013-12-30 23:32:50 +05309416 /*
9417 * STA/P2P client got disassociated so remove any pending deauth
9418 * commands in sme pending list
9419 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309420 pCommand = csrGetCommandBuffer(pMac);
9421 if (NULL == pCommand)
9422 {
9423 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9424 status = eHAL_STATUS_RESOURCES;
9425 return;
9426 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309427 pCommand->command = eSmeCommandRoam;
9428 pCommand->sessionId = (tANI_U8)sessionId;
9429 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9430 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9431 pDisassocInd->peerMacAddr,
9432 sizeof(tSirMacAddr));
9433 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9434 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009435
Agarwal Ashish4f616132013-12-30 23:32:50 +05309436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009437 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309438 else
9439 {
9440 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9441 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9442 }
Kiet Lam82004c62013-11-11 13:24:28 +05309443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009444 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009445 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009446 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009447 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9448 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9449 if( HAL_STATUS_SUCCESS( status ) )
9450 {
9451 // If we are in neighbor preauth done state then on receiving
9452 // disassoc or deauth we dont roam instead we just disassoc
9453 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009454 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009455#ifdef WLAN_FEATURE_VOWIFI_11R
9456 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9457 {
9458 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9459 }
9460#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009461#ifdef FEATURE_WLAN_ESE
9462 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009463 {
9464 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9465 }
9466#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009467#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309468 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009469 {
9470 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9471 }
9472#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009473 pSession = CSR_GET_SESSION( pMac, sessionId );
9474
Jeff Johnson32d95a32012-09-10 13:15:23 -07009475 if(!pSession)
9476 {
9477 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9478 return;
9479 }
9480
Jeff Johnson295189b2012-06-20 16:38:30 -07009481 if ( csrIsConnStateInfra( pMac, sessionId ) )
9482 {
9483 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9484 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009485#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9486 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9487#endif
9488 csrRoamLinkDown(pMac, sessionId);
9489 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009490 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9491 {
9492
9493 pRoamInfo = &roamInfo;
9494
9495 pRoamInfo->statusCode = pDeauthInd->statusCode;
9496 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9497
9498 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9499
Kiet Lam64c1b492013-07-12 13:56:44 +05309500 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9501 sizeof(tSirMacAddr));
9502 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9503 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009504
9505 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9506 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009507 }
9508 break;
9509
9510 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 -08009511 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009512 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9513 //Update with the new channel id.
9514 //The channel id is hidden in the statusCode.
9515 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9516 if( HAL_STATUS_SUCCESS( status ) )
9517 {
9518 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009519 if(!pSession)
9520 {
9521 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9522 return;
9523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009524 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9525 if(pSession->pConnectBssDesc)
9526 {
9527 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9528 }
9529 }
9530 break;
9531
9532 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009533 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009534 {
9535 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9536 sessionId = pDeauthRsp->sessionId;
9537 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9538 {
9539 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009540 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9541 {
9542 pRoamInfo = &roamInfo;
9543 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309544 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9545 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009546 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9547 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9548 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9549 }
9550 }
9551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009552 break;
9553
9554 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009555 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009556 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009557 {
9558 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9559 sessionId = pDisassocRsp->sessionId;
9560 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9561 {
9562 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009563 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9564 {
9565 pRoamInfo = &roamInfo;
9566 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309567 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9568 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009569 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9570 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9571 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9572 }
9573 }
9574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009575 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009576 case eWNI_SME_MIC_FAILURE_IND:
9577 {
9578 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9579 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9580 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009581
9582 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9583 if( HAL_STATUS_SUCCESS( status ) )
9584 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309585 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009586 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9587 pRoamInfo = &roamInfo;
9588 if(pMicInd->info.multicast)
9589 {
9590 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9591 }
9592 else
9593 {
9594 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9595 }
9596 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9597 }
9598
Jeff Johnson295189b2012-06-20 16:38:30 -07009599#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9600 {
lukez3c809222013-05-03 10:23:02 -07009601 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009603 if(!pSession)
9604 {
9605 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9606 return;
9607 }
lukez3c809222013-05-03 10:23:02 -07009608
Kiet Lam64c1b492013-07-12 13:56:44 +05309609 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009610 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9611 secEvent.encryptionModeMulticast =
9612 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9613 secEvent.encryptionModeUnicast =
9614 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9615 secEvent.authMode =
9616 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309617 vos_mem_copy(secEvent.bssid,
9618 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009619 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9620 }
9621#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009622 }
9623 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009624 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9625 {
9626 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9627 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009628 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009629
9630 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9631 if( HAL_STATUS_SUCCESS( status ) )
9632 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309633 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009634 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9635 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9636 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9637 }
9638 }
9639 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009640
Jeff Johnson295189b2012-06-20 16:38:30 -07009641 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9642 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9643 switch( pStatusChangeMsg->statusChangeCode )
9644 {
9645 case eSIR_SME_IBSS_ACTIVE:
9646 sessionId = csrFindIbssSession( pMac );
9647 if( CSR_SESSION_ID_INVALID != sessionId )
9648 {
9649 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009650 if(!pSession)
9651 {
9652 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9653 return;
9654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009655 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9656 if(pSession->pConnectBssDesc)
9657 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309658 vos_mem_copy(&roamInfo.bssid,
9659 pSession->pConnectBssDesc->bssId,
9660 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009661 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9662 pRoamInfo = &roamInfo;
9663 }
9664 else
9665 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009666 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 }
9668 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9669 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9670 }
9671 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009672 case eSIR_SME_IBSS_INACTIVE:
9673 sessionId = csrFindIbssSession( pMac );
9674 if( CSR_SESSION_ID_INVALID != sessionId )
9675 {
9676 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009677 if(!pSession)
9678 {
9679 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9680 return;
9681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009682 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9683 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9684 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9685 }
9686 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9688 sessionId = csrFindIbssSession( pMac );
9689 if( CSR_SESSION_ID_INVALID != sessionId )
9690 {
9691 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009692 if(!pSession)
9693 {
9694 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9695 return;
9696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009697 // update the connection state information
9698 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009699#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9700 {
9701 vos_log_ibss_pkt_type *pIbssLog;
9702 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009703 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9704 if(pIbssLog)
9705 {
9706 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9707 if(pNewBss)
9708 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309709 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009710 if(pNewBss->ssId.length)
9711 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309712 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9713 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009714 }
9715 pIbssLog->operatingChannel = pNewBss->channelNumber;
9716 }
9717 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9718 {
9719 //***U8 is not enough for beacon interval
9720 pIbssLog->beaconInterval = (v_U8_t)bi;
9721 }
9722 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9723 }
9724 }
9725#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009726 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009727
9728 if ((eCSR_ENCRYPT_TYPE_NONE ==
9729 pSession->connectedProfile.EncryptionType ))
9730 {
9731 csrRoamIssueSetContextReq( pMac, sessionId,
9732 pSession->connectedProfile.EncryptionType,
9733 pSession->pConnectBssDesc,
9734 &Broadcastaddr,
9735 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9736 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009737 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9738 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309739 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9740 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009741 pRoamInfo = &roamInfo;
9742 //This BSSID is th ereal BSSID, let's save it
9743 if(pSession->pConnectBssDesc)
9744 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309745 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9746 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009747 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009748 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009749 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009750 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009751 // detection by LIM that the capabilities of the associated AP have changed.
9752 case eSIR_SME_AP_CAPS_CHANGED:
9753 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009754 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009755 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9756 if( HAL_STATUS_SUCCESS( status ) )
9757 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009758 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9759 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309760 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009761 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9762 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9763 )
9764 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309765 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9766 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009767 }
9768 else
9769 {
9770 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309771 FL("Skipping csrScanForCapabilityChange as "
9772 "CSR is in state %s and sub-state %s"),
9773 macTraceGetcsrRoamState(
9774 pMac->roam.curState[sessionId]),
9775 macTraceGetcsrRoamSubState(
9776 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309777 /* We ignore the caps change event if CSR is not in full connected state.
9778 * Send one event to PE to reset limSentCapsChangeNtf
9779 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9780 * otherwise lim cannot send any CAPS change events to SME */
9781 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009783 }
9784 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309785
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 default:
9787 roamStatus = eCSR_ROAM_FAILED;
9788 result = eCSR_ROAM_RESULT_NONE;
9789 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009790 } // end switch on statusChangeCode
9791 if(eCSR_ROAM_RESULT_NONE != result)
9792 {
9793 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9794 }
9795 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 case eWNI_SME_IBSS_NEW_PEER_IND:
9797 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009798#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9799 {
9800 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009801 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9802 if(pIbssLog)
9803 {
9804 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309805 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009806 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9807 }
9808 }
9809#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009810 sessionId = csrFindIbssSession( pMac );
9811 if( CSR_SESSION_ID_INVALID != sessionId )
9812 {
9813 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009814
9815 if(!pSession)
9816 {
9817 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9818 return;
9819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009820 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9821 if(pSession->pConnectBssDesc)
9822 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309823 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9824 sizeof(tCsrBssid));
9825 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9826 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009827 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9828 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309829 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9830 - sizeof(tSmeIbssPeerInd)));
9831 if ( NULL == roamInfo.pbFrames )
9832 status = eHAL_STATUS_FAILURE;
9833 else
9834 status = eHAL_STATUS_SUCCESS;
9835 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009836 {
9837 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309838 vos_mem_copy(roamInfo.pbFrames,
9839 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9840 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009841 }
9842 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9843 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9844 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309845 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9846 if ( NULL == roamInfo.pBssDesc )
9847 status = eHAL_STATUS_FAILURE;
9848 else
9849 status = eHAL_STATUS_SUCCESS;
9850 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009851 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309852 vos_mem_copy(roamInfo.pBssDesc,
9853 pSession->pConnectBssDesc,
9854 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009855 }
9856 if(HAL_STATUS_SUCCESS(status))
9857 {
9858 pRoamInfo = &roamInfo;
9859 }
9860 else
9861 {
9862 if(roamInfo.pbFrames)
9863 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309864 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009865 }
9866 if(roamInfo.pBssDesc)
9867 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309868 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009869 }
9870 }
9871 }
9872 else
9873 {
9874 pRoamInfo = &roamInfo;
9875 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009876 if ((eCSR_ENCRYPT_TYPE_NONE ==
9877 pSession->connectedProfile.EncryptionType ))
9878 {
9879 csrRoamIssueSetContextReq( pMac, sessionId,
9880 pSession->connectedProfile.EncryptionType,
9881 pSession->pConnectBssDesc,
9882 &(pIbssPeerInd->peerAddr),
9883 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009885 }
9886 else
9887 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009888 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009889 }
9890 //send up the sec type for the new peer
9891 if (pRoamInfo)
9892 {
9893 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9894 }
9895 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9896 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9897 if(pRoamInfo)
9898 {
9899 if(roamInfo.pbFrames)
9900 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309901 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009902 }
9903 if(roamInfo.pBssDesc)
9904 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309905 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 }
9907 }
9908 }
9909 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009910 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9911 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9912 sessionId = csrFindIbssSession( pMac );
9913 if( CSR_SESSION_ID_INVALID != sessionId )
9914 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009915#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9916 {
9917 vos_log_ibss_pkt_type *pIbssLog;
9918
9919 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9920 if(pIbssLog)
9921 {
9922 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9923 if(pIbssPeerInd)
9924 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309925 vos_mem_copy(pIbssLog->peerMacAddr,
9926 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009927 }
9928 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9929 }
9930 }
9931#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009932 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009933 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9934 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9935 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309936 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9937 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009938 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9939 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9940 }
9941 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009942 case eWNI_SME_SETCONTEXT_RSP:
9943 {
9944 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9945 tListElem *pEntry;
9946 tSmeCmd *pCommand;
9947
9948 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9949 if ( pEntry )
9950 {
9951 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9952 if ( eSmeCommandSetKey == pCommand->command )
9953 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +05309954 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009955 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009956
9957 if(!pSession)
9958 {
9959 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9960 return;
9961 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009962
9963#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9964 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9965 {
9966 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309967 vos_mem_set(&setKeyEvent,
9968 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009969 if( pRsp->peerMacAddr[0] & 0x01 )
9970 {
9971 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9972 }
9973 else
9974 {
9975 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9976 }
9977 setKeyEvent.encryptionModeMulticast =
9978 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9979 setKeyEvent.encryptionModeUnicast =
9980 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309981 vos_mem_copy(setKeyEvent.bssid,
9982 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009983 setKeyEvent.authMode =
9984 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009985 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009986 {
9987 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9988 }
9989 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9990 }
9991#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9992 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9993 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009994 csrRoamStopWaitForKeyTimer( pMac );
9995
Jeff Johnson295189b2012-06-20 16:38:30 -07009996 //We are done with authentication, whethere succeed or not
9997 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009998 //We do it here because this linkup function is not called after association
9999 //when a key needs to be set.
10000 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10001 {
10002 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10003 }
10004 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010005 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010006 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010007 vos_mem_copy(&roamInfo.peerMac,
10008 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010009 //Make sure we install the GTK before indicating to HDD as authenticated
10010 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010011 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10012 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010013 {
Yathish9f22e662012-12-10 14:21:35 -080010014#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10015 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10016 {
10017 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010018 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010019 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
10020 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
10021 pMsg->seesionId = sessionId;
10022 status = palSendMBMessage(pMac->hHdd, pMsg );
10023 }
10024#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010025 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010026 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
10027 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE )
10028 {
10029 tpSirSmeHT40OBSSScanInd pMsg;
10030 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10031 pMsg->messageType =
10032 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10033 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010034 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10035 vos_mem_copy(pMsg->peerMacAddr,
10036 pSession->connectedProfile.bssid,
10037 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010038 status = palSendMBMessage(pMac->hHdd,
10039 pMsg );
10040 }
10041 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010042 }
10043 else
10044 {
10045 result = eCSR_ROAM_RESULT_NONE;
10046 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010047 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010048 }
10049 else
10050 {
10051 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010052 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10053 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10054 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010055 }
10056 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10057 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010058 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10059 // can go ahead and initiate the TSPEC if any are pending
10060 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010061#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010062 //Send Adjacent AP repot to new AP.
10063 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10064 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010065 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010066 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010067#ifdef FEATURE_WLAN_ESE_UPLOAD
10068 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010069#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010070 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010071#endif
10072 pSession->isPrevApInfoValid = FALSE;
10073 }
10074#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010075 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10076 {
10077 csrReleaseCommandSetKey( pMac, pCommand );
10078 }
10079 }
10080 else
10081 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010082 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010083 }
10084 }
10085 else
10086 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010087 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010088 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010089 smeProcessPendingQueue( pMac );
10090 }
10091 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010092 case eWNI_SME_REMOVEKEY_RSP:
10093 {
10094 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10095 tListElem *pEntry;
10096 tSmeCmd *pCommand;
10097
10098 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10099 if ( pEntry )
10100 {
10101 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10102 if ( eSmeCommandRemoveKey == pCommand->command )
10103 {
10104 sessionId = pCommand->sessionId;
10105 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010106
10107 if(!pSession)
10108 {
10109 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10110 return;
10111 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010112#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10113 {
10114 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010115 vos_mem_set(&removeKeyEvent,
10116 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010117 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10118 removeKeyEvent.encryptionModeMulticast =
10119 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10120 removeKeyEvent.encryptionModeUnicast =
10121 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010122 vos_mem_copy( removeKeyEvent.bssid,
10123 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010124 removeKeyEvent.authMode =
10125 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010126 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010127 {
10128 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10129 }
10130 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10131 }
10132#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010133 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010134 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010135 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10136 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010137 result = eCSR_ROAM_RESULT_NONE;
10138 pRoamInfo = &roamInfo;
10139 }
10140 else
10141 {
10142 result = eCSR_ROAM_RESULT_FAILURE;
10143 }
10144 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10145 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10146 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10147 {
10148 csrReleaseCommandRemoveKey( pMac, pCommand );
10149 }
10150 }
10151 else
10152 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010153 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010154 }
10155 }
10156 else
10157 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010158 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010159 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010160 smeProcessPendingQueue( pMac );
10161 }
10162 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010163 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010164 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010165 csrRoamStatsRspProcessor( pMac, pSirMsg );
10166 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010167#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010168 case eWNI_SME_GET_ROAM_RSSI_RSP:
10169 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10170 csrRoamRssiRspProcessor( pMac, pSirMsg );
10171 break;
10172#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010173#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010174 case eWNI_SME_GET_TSM_STATS_RSP:
10175 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10176 csrTsmStatsRspProcessor( pMac, pSirMsg );
10177 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010178#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010179 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010180 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010181 csrUpdateRssi( pMac, pSirMsg );
10182 break;
10183
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010184 case eWNI_SME_GET_SNR_REQ:
10185 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10186 csrUpdateSnr(pMac, pSirMsg);
10187 break;
10188
Jeff Johnson295189b2012-06-20 16:38:30 -070010189#ifdef WLAN_FEATURE_VOWIFI_11R
10190 case eWNI_SME_FT_PRE_AUTH_RSP:
10191 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10192 break;
10193#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010194 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10195 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010196 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 -070010197 sessionId = pSmeMaxAssocInd->sessionId;
10198 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010199 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10200 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010201 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10202 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10203 break;
10204
10205 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010206 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010207 btampEstablishLogLinkHdlr( pSirMsg );
10208 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010209 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010210 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010211 csrRoamRssiIndHdlr( pMac, pSirMsg );
10212 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010213#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10214 case eWNI_SME_CANDIDATE_FOUND_IND:
10215 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10216 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10217 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010218 case eWNI_SME_HANDOFF_REQ:
10219 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10220 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10221 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010222#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010223
10224 default:
10225 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010226 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010227}
10228
Jeff Johnson295189b2012-06-20 16:38:30 -070010229void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10230 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10231{
10232 if(pSession)
10233 {
10234 if(pSession->bRefAssocStartCnt)
10235 {
10236 pSession->bRefAssocStartCnt--;
10237 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10238 //Need to call association_completion because there is an assoc_start pending.
10239 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10240 eCSR_ROAM_ASSOCIATION_COMPLETION,
10241 eCSR_ROAM_RESULT_FAILURE);
10242 }
10243 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10244 }
10245 else
10246 {
10247 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10248 }
10249}
10250
10251
10252eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10253{
10254 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010255 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10256 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10257 {
10258 status = csrScanRequestLostLink1( pMac, sessionId );
10259 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010260 return(status);
10261}
10262
Jeff Johnson295189b2012-06-20 16:38:30 -070010263//return a boolean to indicate whether roaming completed or continue.
10264tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10265 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10266{
10267 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10268 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10269 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10270 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010271 if(!pSession)
10272 {
10273 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10274 return eANI_BOOLEAN_FALSE;
10275 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010276 //Check whether time is up
10277 if(pSession->fCancelRoaming || fForce ||
10278 ((curTime - pSession->roamingStartTime) > roamTime) ||
10279 eCsrReassocRoaming == pSession->roamingReason ||
10280 eCsrDynamicRoaming == pSession->roamingReason)
10281 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010282 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010283 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10284 {
10285 //roaming is cancelled, tell HDD to indicate disconnect
10286 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10287 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10288 //to be eSIR_BEACON_MISSED
10289 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10290 {
10291 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10292 }
10293 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10294 {
10295 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10296 }
10297 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10298 {
10299 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10300 }
10301 else
10302 {
10303 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10304 }
10305 }
10306 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10307 pSession->roamingReason = eCsrNotRoaming;
10308 }
10309 else
10310 {
10311 pSession->roamResult = roamResult;
10312 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10313 {
10314 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10315 pSession->roamingReason = eCsrNotRoaming;
10316 }
10317 else
10318 {
10319 fCompleted = eANI_BOOLEAN_FALSE;
10320 }
10321 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010322 return(fCompleted);
10323}
10324
Jeff Johnson295189b2012-06-20 16:38:30 -070010325void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10326{
10327 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010328
10329 if(!pSession)
10330 {
10331 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10332 return;
10333 }
10334
Jeff Johnson295189b2012-06-20 16:38:30 -070010335 if(CSR_IS_ROAMING(pSession))
10336 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010337 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010338 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10339 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10340 {
10341 //No need to do anything in here because the handler takes care of it
10342 }
10343 else
10344 {
10345 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10346 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10347 //Roaming is stopped after here
10348 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10349 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010350 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010351 csrRoamStopRoamingTimer(pMac, sessionId);
10352 }
10353 }
10354}
10355
Jeff Johnson295189b2012-06-20 16:38:30 -070010356void csrRoamRoamingTimerHandler(void *pv)
10357{
10358 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10359 tpAniSirGlobal pMac = pInfo->pMac;
10360 tANI_U32 sessionId = pInfo->sessionId;
10361 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010362
10363 if(!pSession)
10364 {
10365 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10366 return;
10367 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010368
10369 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10370 {
10371 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10372 {
10373 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10374 pSession->roamingReason = eCsrNotRoaming;
10375 }
10376 }
10377}
10378
Jeff Johnson295189b2012-06-20 16:38:30 -070010379eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10380{
10381 eHalStatus status;
10382 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010383
10384 if(!pSession)
10385 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010386 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010387 return eHAL_STATUS_FAILURE;
10388 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010389
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010390 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010391 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010392 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010393
10394 return (status);
10395}
10396
Jeff Johnson295189b2012-06-20 16:38:30 -070010397eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10398{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010399 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010400}
10401
Jeff Johnson295189b2012-06-20 16:38:30 -070010402void csrRoamWaitForKeyTimeOutHandler(void *pv)
10403{
10404 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10405 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010406 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010407 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010408
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010409 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10410 macTraceGetNeighbourRoamState(
10411 pMac->roam.neighborRoamInfo.neighborRoamState),
10412 macTraceGetcsrRoamSubState(
10413 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010414
Jeff Johnson295189b2012-06-20 16:38:30 -070010415 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10416 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010417#ifdef FEATURE_WLAN_LFR
10418 if (csrNeighborRoamIsHandoffInProgress(pMac))
10419 {
10420 /*
10421 * Enable heartbeat timer when hand-off is in progress
10422 * and Key Wait timer expired.
10423 */
10424 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010425 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010426 pMac->roam.configParam.HeartbeatThresh24);
10427 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10428 pMac->roam.configParam.HeartbeatThresh24,
10429 NULL, eANI_BOOLEAN_FALSE);
10430 }
10431#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010432 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010433
Jeff Johnson295189b2012-06-20 16:38:30 -070010434 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010435 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10436 {
10437 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10438 pInfo->sessionId);
10439 }
10440
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010441 if (pSession)
10442 {
10443 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10444 {
10445 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10446 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010447 if( (pSession->connectedProfile.AuthType ==
10448 eCSR_AUTH_TYPE_SHARED_KEY) &&
10449 ( (pSession->connectedProfile.EncryptionType ==
10450 eCSR_ENCRYPT_TYPE_WEP40) ||
10451 (pSession->connectedProfile.EncryptionType ==
10452 eCSR_ENCRYPT_TYPE_WEP104) ))
10453 {
10454 status = sme_AcquireGlobalLock( &pMac->sme );
10455 if ( HAL_STATUS_SUCCESS( status ) )
10456 {
10457 csrRoamDisconnect( pMac, pInfo->sessionId,
10458 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10459 sme_ReleaseGlobalLock( &pMac->sme );
10460 }
10461 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010462 }
10463 else
10464 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010465 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010466 __func__);
10467 }
10468 }
10469 else
10470 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010471 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010472 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010473 }
10474
10475}
10476
Jeff Johnson295189b2012-06-20 16:38:30 -070010477eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10478{
10479 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010480#ifdef FEATURE_WLAN_LFR
10481 if (csrNeighborRoamIsHandoffInProgress(pMac))
10482 {
10483 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010484 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10485 macTraceGetNeighbourRoamState(
10486 pMac->roam.neighborRoamInfo.neighborRoamState),
10487 macTraceGetcsrRoamSubState(
10488 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10489 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010490 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10491 }
10492#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010493 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010494 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010495
10496 return (status);
10497}
10498
Jeff Johnson295189b2012-06-20 16:38:30 -070010499eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10500{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010501 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10502 macTraceGetNeighbourRoamState(
10503 pMac->roam.neighborRoamInfo.neighborRoamState),
10504 macTraceGetcsrRoamSubState(
10505 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010506#ifdef FEATURE_WLAN_LFR
10507 if (csrNeighborRoamIsHandoffInProgress(pMac))
10508 {
10509 /*
10510 * Enable heartbeat timer when hand-off is in progress
10511 * and Key Wait timer got stopped for some reason
10512 */
10513 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010514 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010515 pMac->roam.configParam.HeartbeatThresh24);
10516 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10517 pMac->roam.configParam.HeartbeatThresh24,
10518 NULL, eANI_BOOLEAN_FALSE);
10519 }
10520#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010521 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010522}
10523
Jeff Johnson295189b2012-06-20 16:38:30 -070010524void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10525 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10526{
10527 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10528 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010529 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10530 /* To silence the KW tool Null chaeck is added */
10531 if(!pSession)
10532 {
10533 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10534 return;
10535 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010536
10537 if(pCommand)
10538 {
10539 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010540 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010541 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010542 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10543 {
10544 //if success, force roaming completion
10545 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10546 }
10547 else
10548 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010549 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010550 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010551 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10552 }
10553}
10554
Jeff Johnson295189b2012-06-20 16:38:30 -070010555eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10556{
10557 eHalStatus status = eHAL_STATUS_SUCCESS;
10558 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10559 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10560 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10561 tCsrRoamInfo *pRoamInfo = NULL;
10562 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010563 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010564 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010565 /* To silence the KW tool Null chaeck is added */
10566 if(!pSession)
10567 {
10568 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10569 return eHAL_STATUS_FAILURE;
10570 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010571 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010572 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010573 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10574 if ( eWNI_SME_DISASSOC_IND == type )
10575 {
10576 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10577 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10578 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010579 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010580 }
10581 else if ( eWNI_SME_DEAUTH_IND == type )
10582 {
10583 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10584 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10585 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010586 /* Convert into proper reason code */
10587 pSession->joinFailStatusCode.reasonCode =
10588 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010589 0 : pDeauthIndMsg->reasonCode;
10590 /* cfg layer expects 0 as reason code if
10591 the driver dosent know the reason code
10592 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010593 }
10594 else
10595 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010596 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010597 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010598 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010599 }
10600
10601 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010602 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010603 {
10604 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10605 }
10606
10607 if ( eWNI_SME_DISASSOC_IND == type )
10608 {
10609 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10610 }
10611 else if ( eWNI_SME_DEAUTH_IND == type )
10612 {
10613 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10614 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010615 if(!HAL_STATUS_SUCCESS(status))
10616 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010617 //If fail to send confirmation to PE, not to trigger roaming
10618 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010619 }
10620
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010621 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010622 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010623 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10624 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010625 if( eWNI_SME_DISASSOC_IND == type)
10626 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010627 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010628 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10629 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010630 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10631 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010632 else if( eWNI_SME_DEAUTH_IND == type )
10633 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010634 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010635 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10636 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010637 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10638 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010639 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010640
10641 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10642 that we are roaming. But if we cannot possibly roam, or if we are unable to
10643 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010644 if(fToRoam)
10645 {
10646 //Only remove the connected BSS in infrastructure mode
10647 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10648 //Not to do anying for lostlink with WDS
10649 if( pMac->roam.configParam.nRoamingTime )
10650 {
10651 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10652 ( eWNI_SME_DEAUTH_IND == type ) ?
10653 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10654 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010655 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010656 //For IBSS, we need to give some more info to HDD
10657 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10658 {
10659 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10660 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10661 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10662 }
10663 else
10664 {
10665 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10666 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010667 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010668 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10669 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10670 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10671 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10672 }
10673 else
10674 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010675 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010676 fToRoam = eANI_BOOLEAN_FALSE;
10677 }
10678 }
10679 else
10680 {
10681 //We are told not to roam, indicate lostlink
10682 fToRoam = eANI_BOOLEAN_FALSE;
10683 }
10684 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010685 if(!fToRoam)
10686 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010687 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010688 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010689 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010690 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10691 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10692 * csrRoamCheckForLinkStatusChange API.
10693 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010694 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10695 }
10696
10697 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010698 Still enable idle scan for polling in case concurrent sessions are running */
10699 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10700 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010701 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010702 }
10703 }
10704
10705 return (status);
10706}
10707
Jeff Johnson295189b2012-06-20 16:38:30 -070010708eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10709{
10710 eHalStatus status = eHAL_STATUS_SUCCESS;
10711 tListElem *pEntry = NULL;
10712 tSmeCmd *pCommand = NULL;
10713 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010714
10715 if(!pSession)
10716 {
10717 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10718 return eHAL_STATUS_FAILURE;
10719 }
10720
Jeff Johnson295189b2012-06-20 16:38:30 -070010721 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010722 //Only remove the connected BSS in infrastructure mode
10723 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10724 if(pMac->roam.configParam.nRoamingTime)
10725 {
10726 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10727 {
10728 //before starting the lost link logic release the roam command for handoff
10729 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10730 if(pEntry)
10731 {
10732 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10733 }
10734 if(pCommand)
10735 {
10736 if (( eSmeCommandRoam == pCommand->command ) &&
10737 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10738 {
10739 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10740 {
10741 csrReleaseCommandRoam( pMac, pCommand );
10742 }
10743 }
10744 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010745 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010746 }
10747 }
10748 else
10749 {
10750 //We are told not to roam, indicate lostlink
10751 status = eHAL_STATUS_FAILURE;
10752 }
10753
10754 return (status);
10755}
Jeff Johnson295189b2012-06-20 16:38:30 -070010756void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10757{
10758 tListElem *pEntry;
10759 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010760 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10761 if ( pEntry )
10762 {
10763 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10764 if ( eSmeCommandWmStatusChange == pCommand->command )
10765 {
10766 // Nothing to process in a Lost Link completion.... It just kicks off a
10767 // roaming sequence.
10768 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10769 {
10770 csrReleaseCommandWmStatusChange( pMac, pCommand );
10771 }
10772 else
10773 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010774 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010775 }
10776
10777 }
10778 else
10779 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010780 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010781 }
10782 }
10783 else
10784 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010785 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010786 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010787 smeProcessPendingQueue( pMac );
10788}
10789
Jeff Johnson295189b2012-06-20 16:38:30 -070010790void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10791{
10792 eHalStatus status = eHAL_STATUS_FAILURE;
10793 tSirSmeRsp *pSirSmeMsg;
10794 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010795
10796 if(!pSession)
10797 {
10798 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10799 return;
10800 }
10801
Jeff Johnson295189b2012-06-20 16:38:30 -070010802 switch ( pCommand->u.wmStatusChangeCmd.Type )
10803 {
10804 case eCsrDisassociated:
10805 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10806 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10807 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010808 case eCsrDeauthenticated:
10809 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10810 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10811 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010812 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010813 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010814 break;
10815 }
10816 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10817 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10818 {
10819 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10820 {
10821 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010822 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010823 }
10824 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010825 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10826 // command here since there is nothing else to do.
10827 csrRoamWmStatusChangeComplete( pMac );
10828}
10829
Jeff Johnson295189b2012-06-20 16:38:30 -070010830//This function returns band and mode information.
10831//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10832//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010833static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10834 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010835{
Jeff Johnson295189b2012-06-20 16:38:30 -070010836 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10837 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10838 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010839 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010840
Jeff Johnson295189b2012-06-20 16:38:30 -070010841 //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 -070010842 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10843 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10844 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10845 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010846 {
10847 switch( pMac->roam.configParam.uCfgDot11Mode )
10848 {
10849 case eCSR_CFG_DOT11_MODE_11A:
10850 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10851 eBand = eCSR_BAND_5G;
10852 break;
10853 case eCSR_CFG_DOT11_MODE_11B:
10854 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10855 eBand = eCSR_BAND_24;
10856 break;
10857 case eCSR_CFG_DOT11_MODE_11G:
10858 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10859 eBand = eCSR_BAND_24;
10860 break;
10861 case eCSR_CFG_DOT11_MODE_11N:
10862 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010863 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10864 break;
10865#ifdef WLAN_FEATURE_11AC
10866 case eCSR_CFG_DOT11_MODE_11AC:
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;
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 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10887 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10888 }
10889 break;
10890 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10891 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10892 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010893 /* If the operating channel is in 2.4 GHz band, check for
10894 * INI item to disable VHT operation in 2.4 GHz band
10895 */
10896 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10897 !pMac->roam.configParam.enableVhtFor24GHz)
10898 {
10899 /* Disable 11AC operation */
10900 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10901 }
10902 else
10903 {
10904 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10905 }
10906 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010907 }
10908 else
10909 {
10910 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10911 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10912 }
10913 break;
10914#endif
10915 case eCSR_CFG_DOT11_MODE_AUTO:
10916 eBand = pMac->roam.configParam.eBand;
10917 if (eCSR_BAND_24 == eBand)
10918 {
10919 // WiFi tests require IBSS networks to start in 11b mode
10920 // without any change to the default parameter settings
10921 // on the adapter. We use ACU to start an IBSS through
10922 // creation of a startIBSS profile. This startIBSS profile
10923 // has Auto MACProtocol and the adapter property setting
10924 // for dot11Mode is also AUTO. So in this case, let's
10925 // start the IBSS network in 11b mode instead of 11g mode.
10926 // So this is for Auto=profile->MacProtocol && Auto=Global.
10927 // dot11Mode && profile->channel is < 14, then start the IBSS
10928 // in b mode.
10929 //
10930 // Note: we used to have this start as an 11g IBSS for best
10931 // performance... now to specify that the user will have to
10932 // set the do11Mode in the property page to 11g to force it.
10933 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10934 }
10935 else
10936 {
10937#ifdef WLAN_FEATURE_11AC
10938 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10939 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010940 /* If the operating channel is in 2.4 GHz band, check for
10941 * INI item to disable VHT operation in 2.4 GHz band
10942 */
10943 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10944 !pMac->roam.configParam.enableVhtFor24GHz)
10945 {
10946 /* Disable 11AC operation */
10947 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10948 }
10949 else
10950 {
10951 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10952 }
10953 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010954 }
10955 else
10956 {
10957 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10958 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10959 }
10960#else
10961 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10962 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10963#endif
10964 }
10965 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010966 default:
10967 // Global dot11 Mode setting is 11a/b/g.
10968 // use the channel number to determine the Mode setting.
10969 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10970 {
10971 eBand = pMac->roam.configParam.eBand;
10972 if(eCSR_BAND_24 == eBand)
10973 {
10974 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10975 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10976 }
10977 else
10978 {
10979 //prefer 5GHz
10980 eBand = eCSR_BAND_5G;
10981 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10982 }
10983 }
10984 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10985 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010986 // WiFi tests require IBSS networks to start in 11b mode
10987 // without any change to the default parameter settings
10988 // on the adapter. We use ACU to start an IBSS through
10989 // creation of a startIBSS profile. This startIBSS profile
10990 // has Auto MACProtocol and the adapter property setting
10991 // for dot11Mode is also AUTO. So in this case, let's
10992 // start the IBSS network in 11b mode instead of 11g mode.
10993 // So this is for Auto=profile->MacProtocol && Auto=Global.
10994 // dot11Mode && profile->channel is < 14, then start the IBSS
10995 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010996 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010997 // Note: we used to have this start as an 11g IBSS for best
10998 // performance... now to specify that the user will have to
10999 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011000 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11001 eBand = eCSR_BAND_24;
11002 }
11003 else
11004 {
11005 // else, it's a 5.0GHz channel. Set mode to 11a.
11006 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11007 eBand = eCSR_BAND_5G;
11008 }
11009 break;
11010 }//switch
11011 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11012 else
11013 {
11014 //dot11 mode is set, lets pick the band
11015 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11016 {
11017 // channel is Auto also.
11018 eBand = pMac->roam.configParam.eBand;
11019 if(eCSR_BAND_ALL == eBand)
11020 {
11021 //prefer 5GHz
11022 eBand = eCSR_BAND_5G;
11023 }
11024 }
11025 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11026 {
11027 eBand = eCSR_BAND_24;
11028 }
11029 else
11030 {
11031 eBand = eCSR_BAND_5G;
11032 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011033 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011034 if(pBand)
11035 {
11036 *pBand = eBand;
11037 }
11038
11039 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011040 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011041 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11042 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011043
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011044 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11045 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 -070011046 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011047#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011048 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011049#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011050 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11051 {
11052 //We cannot do 11n here
11053 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11054 {
11055 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11056 }
11057 else
11058 {
11059 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11060 }
11061 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011062 return( cfgDot11Mode );
11063}
11064
Jeff Johnson295189b2012-06-20 16:38:30 -070011065eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11066{
11067 eHalStatus status;
11068 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011069
11070 if(!pSession)
11071 {
11072 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11073 return eHAL_STATUS_FAILURE;
11074 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011075
11076#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11077 {
11078 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011079 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11080 if(pIbssLog)
11081 {
11082 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11083 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11084 }
11085 }
11086#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011087 // Set the roaming substate to 'stop Bss request'...
11088 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11089
11090 // attempt to stop the Bss (reason code is ignored...)
11091 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011092 if(!HAL_STATUS_SUCCESS(status))
11093 {
11094 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011096 return (status);
11097}
11098
Jeff Johnson295189b2012-06-20 16:38:30 -070011099//pNumChan is a caller allocated space with the sizeof pChannels
11100eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11101{
11102
11103 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11104 (tANI_U8 *)pChannels,
11105 pNumChan));
11106}
11107
Kiran4a17ebe2013-01-31 10:43:43 -080011108tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11109{
11110 tANI_U32 cfgLength = 0;
11111 tANI_U16 cfgId = 0;
11112 tPowerdBm maxTxPwr = 0;
11113 tANI_U8 *pCountryInfo = NULL;
11114 eHalStatus status;
11115 tANI_U8 count = 0;
11116 tANI_U8 firstChannel;
11117 tANI_U8 maxChannels;
11118
11119 if (CSR_IS_CHANNEL_5GHZ(channel))
11120 {
11121 cfgId = WNI_CFG_MAX_TX_POWER_5;
11122 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11123 }
11124 else if (CSR_IS_CHANNEL_24GHZ(channel))
11125 {
11126 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11127 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11128 }
11129 else
11130 return maxTxPwr;
11131
Kiet Lam64c1b492013-07-12 13:56:44 +053011132 pCountryInfo = vos_mem_malloc(cfgLength);
11133 if ( NULL == pCountryInfo )
11134 status = eHAL_STATUS_FAILURE;
11135 else
11136 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011137 if (status != eHAL_STATUS_SUCCESS)
11138 {
11139 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011140 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011141 __FUNCTION__, status);
11142 goto error;
11143 }
11144 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11145 if (status != eHAL_STATUS_SUCCESS)
11146 {
11147 goto error;
11148 }
11149 /* Identify the channel and maxtxpower */
11150 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11151 {
11152 firstChannel = pCountryInfo[count++];
11153 maxChannels = pCountryInfo[count++];
11154 maxTxPwr = pCountryInfo[count++];
11155
11156 if ((channel >= firstChannel) &&
11157 (channel < (firstChannel + maxChannels)))
11158 {
11159 break;
11160 }
11161 }
11162
11163error:
11164 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011165 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011166
11167 return maxTxPwr;
11168}
11169
11170
Jeff Johnson295189b2012-06-20 16:38:30 -070011171tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11172{
11173 tANI_BOOLEAN fValid = FALSE;
11174 tANI_U32 idxValidChannels;
11175 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11176
11177 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11178 {
11179 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11180 {
11181 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11182 {
11183 fValid = TRUE;
11184 break;
11185 }
11186 }
11187 }
11188 pMac->roam.numValidChannels = len;
11189 return fValid;
11190}
11191
Jeff Johnson295189b2012-06-20 16:38:30 -070011192tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11193{
11194 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11195 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011196 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11197 {
11198 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11199 {
11200 fValid = eANI_BOOLEAN_TRUE;
11201 break;
11202 }
11203 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011204 return (fValid);
11205}
11206
Jeff Johnson295189b2012-06-20 16:38:30 -070011207//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011208 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011209{
Jeff Johnsone7245742012-09-05 17:12:55 -070011210 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011211 tANI_U8 centerChn;
11212 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011213
Jeff Johnson295189b2012-06-20 16:38:30 -070011214 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11215 {
11216 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11217 }
11218 else
11219 {
11220 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11221 }
11222 //Figure what the other side's CB mode
11223 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11224 {
11225 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11226 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011227 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11228 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11229 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11230 "\x00\x0f\xac\x02",4))
11231 //In Case WPA1 and TKIP is the only one cipher suite in Unicast.
11232 ||(pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
11233 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
11234 "\x00\x50\xf2\x02",4)))
11235
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011236 {
11237 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11238 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11239 }
11240
11241 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011242 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011243 /* This is called during INFRA STA/CLIENT and should use the merged value of
11244 * supported channel width and recommended tx width as per standard
11245 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011246 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011247 pIes->HTCaps.supportedChannelWidthSet,
11248 pIes->HTInfo.recommendedTxWidthSet,
11249 pIes->HTInfo.secondaryChannelOffset);
11250
11251 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11252 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011253 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011254 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11255 switch (eRet) {
11256 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11257 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11258 break;
11259 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11260 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11261 break;
11262 case PHY_SINGLE_CHANNEL_CENTERED:
11263 default:
11264 centerChn = primaryChn;
11265 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011266 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011267 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011268 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011269 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053011270 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011271 }
11272 }
11273 }
11274 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011275 return eRet;
11276}
Jeff Johnson295189b2012-06-20 16:38:30 -070011277tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11278{
11279 tANI_BOOLEAN fFound = FALSE;
11280 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011281 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11282 {
11283 if( pCipherList->encryptionType[idx] == encryptionType )
11284 {
11285 fFound = TRUE;
11286 break;
11287 }
11288 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011289 return fFound;
11290}
Jeff Johnson295189b2012-06-20 16:38:30 -070011291tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11292{
11293 tANI_BOOLEAN fFound = FALSE;
11294 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011295 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11296 {
11297 if( pAuthList->authType[idx] == authType )
11298 {
11299 fFound = TRUE;
11300 break;
11301 }
11302 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011303 return fFound;
11304}
Jeff Johnson295189b2012-06-20 16:38:30 -070011305tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11306{
11307 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11308 tCsrScanResultFilter *pScanFilter = NULL;
11309 eHalStatus status = eHAL_STATUS_SUCCESS;
11310
11311 if(pProfile1 && pProfile2)
11312 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011313 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11314 if ( NULL == pScanFilter )
11315 status = eHAL_STATUS_FAILURE;
11316 else
11317 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011318 if(HAL_STATUS_SUCCESS(status))
11319 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011320 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011321 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11322 if(HAL_STATUS_SUCCESS(status))
11323 {
11324 fCheck = eANI_BOOLEAN_FALSE;
11325 do
11326 {
11327 tANI_U32 i;
11328 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11329 {
11330 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11331 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11332 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11333 if ( fCheck ) break;
11334 }
11335 if(!fCheck)
11336 {
11337 break;
11338 }
11339 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11340 || pProfile2->BSSType != pProfile1->BSSType
11341 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11342 )
11343 {
11344 fCheck = eANI_BOOLEAN_FALSE;
11345 break;
11346 }
11347#ifdef WLAN_FEATURE_VOWIFI_11R
11348 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11349 {
11350 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11351 {
11352 fCheck = eANI_BOOLEAN_FALSE;
11353 break;
11354 }
11355 }
11356#endif
11357 //Match found
11358 fCheck = eANI_BOOLEAN_TRUE;
11359 }while(0);
11360 csrFreeScanFilter(pMac, pScanFilter);
11361 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011362 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011363 }
11364 }
11365
11366 return (fCheck);
11367}
11368
Jeff Johnson295189b2012-06-20 16:38:30 -070011369tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11370{
11371 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11372 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011373 do
11374 {
11375 //Only check for static WEP
11376 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11377 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11378 {
11379 fCheck = eANI_BOOLEAN_TRUE;
11380 break;
11381 }
11382 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11383 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11384 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11385 {
11386 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011387 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11388 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011389 {
11390 break;
11391 }
11392 }
11393 if( i == CSR_MAX_NUM_KEY)
11394 {
11395 fCheck = eANI_BOOLEAN_TRUE;
11396 }
11397 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011398 return (fCheck);
11399}
11400
Jeff Johnson295189b2012-06-20 16:38:30 -070011401//IBSS
11402
Jeff Johnson295189b2012-06-20 16:38:30 -070011403tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11404{
11405 tANI_U8 channel = 0;
11406 tANI_U32 idx;
11407 tANI_U32 idxValidChannels;
11408 tANI_BOOLEAN fFound = FALSE;
11409 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11410
11411 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11412 {
11413 channel = pMac->roam.configParam.AdHocChannel5G;
11414 if(!csrRoamIsChannelValid(pMac, channel))
11415 {
11416 channel = 0;
11417 }
11418 }
11419 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11420 {
11421 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11422 {
11423 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11424 {
11425 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11426 {
11427 fFound = TRUE;
11428 channel = csrStartIbssChannels50[ idx ];
11429 }
11430 }
11431 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011432 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11433 if (!fFound)
11434 {
11435 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11436 {
11437 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11438 {
11439 channel = csrStartIbssChannels50[ idx ];
11440 break;
11441 }
11442 }
11443 }
11444 }//if
11445
11446 return( channel );
11447}
11448
Jeff Johnson295189b2012-06-20 16:38:30 -070011449tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11450{
11451 tANI_U8 channel = 1;
11452 tANI_U32 idx;
11453 tANI_U32 idxValidChannels;
11454 tANI_BOOLEAN fFound = FALSE;
11455 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11456
11457 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11458 {
11459 channel = pMac->roam.configParam.AdHocChannel24;
11460 if(!csrRoamIsChannelValid(pMac, channel))
11461 {
11462 channel = 0;
11463 }
11464 }
11465
11466 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11467 {
11468 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11469 {
11470 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11471 {
11472 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11473 {
11474 fFound = TRUE;
11475 channel = csrStartIbssChannels24[ idx ];
11476 }
11477 }
11478 }
11479 }
11480
11481 return( channel );
11482}
11483
Jeff Johnson295189b2012-06-20 16:38:30 -070011484static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11485 tCsrRoamStartBssParams *pParam )
11486{
11487 eCsrCfgDot11Mode cfgDot11Mode;
11488 eCsrBand eBand;
11489 tANI_U8 channel = 0;
11490 tSirNwType nwType;
11491 tANI_U8 operationChannel = 0;
11492
11493 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11494 {
11495 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11496 }
11497
Jeff Johnson295189b2012-06-20 16:38:30 -070011498 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011499
Jeff Johnson295189b2012-06-20 16:38:30 -070011500 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11501 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11502 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11503 )
11504 {
11505 /* This should never happen */
11506 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011507 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011508 pProfile->csrPersona);
11509 VOS_ASSERT(0);
11510 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011511 switch( cfgDot11Mode )
11512 {
11513 case eCSR_CFG_DOT11_MODE_11G:
11514 nwType = eSIR_11G_NW_TYPE;
11515 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011516 case eCSR_CFG_DOT11_MODE_11B:
11517 nwType = eSIR_11B_NW_TYPE;
11518 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011519 case eCSR_CFG_DOT11_MODE_11A:
11520 nwType = eSIR_11A_NW_TYPE;
11521 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011522 default:
11523 case eCSR_CFG_DOT11_MODE_11N:
11524 case eCSR_CFG_DOT11_MODE_TAURUS:
11525 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11526 if(eCSR_BAND_24 == eBand)
11527 {
11528 nwType = eSIR_11G_NW_TYPE;
11529 }
11530 else
11531 {
11532 nwType = eSIR_11A_NW_TYPE;
11533 }
11534 break;
11535 }
11536
11537 pParam->extendedRateSet.numRates = 0;
11538
11539 switch ( nwType )
11540 {
11541 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011542 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011543 case eSIR_11A_NW_TYPE:
11544
11545 pParam->operationalRateSet.numRates = 8;
11546
11547 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11548 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11549 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11550 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11551 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11552 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11553 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11554 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11555
11556 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11557 {
11558 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11559 if( 0 == channel &&
11560 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11561 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11562 )
11563 {
11564 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11565 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11566 nwType = eSIR_11B_NW_TYPE;
11567 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11568 pParam->operationalRateSet.numRates = 4;
11569 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11570 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11571 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11572 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11573 }
11574 }
11575 else
11576 {
11577 channel = operationChannel;
11578 }
11579 break;
11580
11581 case eSIR_11B_NW_TYPE:
11582 pParam->operationalRateSet.numRates = 4;
11583 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11584 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11585 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11586 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011587 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11588 {
11589 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11590 }
11591 else
11592 {
11593 channel = operationChannel;
11594 }
11595
11596 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011597 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011598 /* For P2P Client and P2P GO, disable 11b rates */
11599 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11600 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11601 )
11602 {
11603 pParam->operationalRateSet.numRates = 8;
11604
11605 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11606 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11607 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11608 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11609 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11610 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11611 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11612 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11613 }
11614 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011615 {
11616 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011617 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11618 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11619 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11620 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11621
11622 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011623 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11624 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11625 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11626 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11627 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11628 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11629 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11630 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11631 }
11632
11633 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11634 {
11635 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11636 }
11637 else
11638 {
11639 channel = operationChannel;
11640 }
11641
11642 break;
11643 }
11644 pParam->operationChn = channel;
11645 pParam->sirNwType = nwType;
11646}
11647
Jeff Johnson295189b2012-06-20 16:38:30 -070011648static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11649 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11650{
11651
11652 if( pParam )
11653 {
11654 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011655 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011656 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011657 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011658
11659 if( pIes )
11660 {
11661 if(pIes->SuppRates.present)
11662 {
11663 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11664 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11665 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011666 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 -070011667 pIes->SuppRates.num_rates);
11668 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11669 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011670 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11671 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011672 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011673 if (pIes->ExtSuppRates.present)
11674 {
11675 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011676 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011677 {
11678 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11679 SIR_MAC_RATESET_EID_MAX, resetting to \
11680 SIR_MAC_RATESET_EID_MAX"),
11681 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011682 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011683 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011684 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011685 pIes->ExtSuppRates.rates,
11686 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11687 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011688 if( pIes->SSID.present )
11689 {
11690 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011691 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11692 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011693 }
11694 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011695 }
11696 else
11697 {
11698 pParam->ssId.length = 0;
11699 pParam->operationalRateSet.numRates = 0;
11700 }
11701 }
11702}
11703
Jeff Johnson295189b2012-06-20 16:38:30 -070011704static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11705{
11706 tANI_U8 MaxRate = 0;
11707 tANI_U32 i;
11708 tANI_U8 *pRate;
11709
11710 pRate = pSirRateSet->rate;
11711 for ( i = 0; i < pSirRateSet->numRates; i++ )
11712 {
11713 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11714 }
11715
11716 // Save the max rate in the connected state information...
11717
11718 // modify LastRates variable as well
11719
11720 return;
11721}
11722
Jeff Johnson295189b2012-06-20 16:38:30 -070011723eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11724 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11725{
11726 eHalStatus status = eHAL_STATUS_SUCCESS;
11727 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011728 // Set the roaming substate to 'Start BSS attempt'...
11729 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011730#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11731 //Need to figure out whether we need to log WDS???
11732 if( CSR_IS_IBSS( pProfile ) )
11733 {
11734 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011735 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11736 if(pIbssLog)
11737 {
11738 if(pBssDesc)
11739 {
11740 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011741 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011742 }
11743 else
11744 {
11745 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11746 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011747 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011748 if(pProfile->ChannelInfo.numOfChannels == 0)
11749 {
11750 pIbssLog->channelSetting = AUTO_PICK;
11751 }
11752 else
11753 {
11754 pIbssLog->channelSetting = SPECIFIED;
11755 }
11756 pIbssLog->operatingChannel = pParam->operationChn;
11757 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11758 }
11759 }
11760#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11761 //Put RSN information in for Starting BSS
11762 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11763 pParam->pRSNIE = pProfile->pRSNReqIE;
11764
Jeff Johnson295189b2012-06-20 16:38:30 -070011765 pParam->privacy = pProfile->privacy;
11766 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11767 pParam->authType = pProfile->csr80211AuthType;
11768 pParam->beaconInterval = pProfile->beaconInterval;
11769 pParam->dtimPeriod = pProfile->dtimPeriod;
11770 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11771 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11772 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11773 {
11774 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11775 {
11776 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11777 }
11778 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011779 pParam->protEnabled = pProfile->protEnabled;
11780 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11781 pParam->ht_protection = pProfile->cfg_protection;
11782 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011783
Jeff Johnson295189b2012-06-20 16:38:30 -070011784 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11785 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011786 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080011787
11788#ifdef WLAN_FEATURE_11W
11789 pParam->mfpCapable = (0 != pProfile->MFPCapable);
11790 pParam->mfpRequired = (0 != pProfile->MFPRequired);
11791#endif
11792
Jeff Johnson295189b2012-06-20 16:38:30 -070011793 // When starting an IBSS, start on the channel from the Profile.
11794 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011795 return (status);
11796}
11797
Jeff Johnson295189b2012-06-20 16:38:30 -070011798static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011799 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011800{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011801 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011802 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011803 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011804
11805 if(!pSession)
11806 {
11807 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11808 return;
11809 }
11810
Jeff Johnson295189b2012-06-20 16:38:30 -070011811 if( pBssDesc )
11812 {
11813 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11814 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11815 //The following code has to be do after that.
11816 //For WDS station, use selfMac as the self BSSID
11817 if( CSR_IS_WDS_STA( pProfile ) )
11818 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011819 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11820 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011821 }
11822 }
11823 else
11824 {
11825 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 //Use the first SSID
11827 if(pProfile->SSIDs.numOfSSIDs)
11828 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011829 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11830 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011831 }
11832 //For WDS station, use selfMac as the self BSSID
11833 if( CSR_IS_WDS_STA( pProfile ) )
11834 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011835 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11836 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011837 }
11838 //Use the first BSSID
11839 else if( pProfile->BSSIDs.numOfBSSIDs )
11840 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011841 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11842 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011843 }
11844 else
11845 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011846 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011847 }
11848 }
11849 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011850 //Set operating channel in pProfile which will be used
11851 //in csrRoamSetBssConfigCfg() to determine channel bonding
11852 //mode and will be configured in CFG later
11853 pProfile->operationChannel = Channel;
11854
11855 if(Channel == 0)
11856 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053011857 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011858 }
11859 else
11860 {
11861
11862 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011863 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011864 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011865 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011866 {
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053011867 /* TODO- SAP: HT40 Support in SAP 2.4Ghz mode is not enabled.
11868 so channel bonding in 2.4Ghz is configured as 20MHZ
11869 irrespective of the 'channelBondingMode24GHz' Parameter */
11870 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -070011871 }
11872 else
11873 {
11874 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11875 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011876 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011877 pBssConfig->cbMode = cbMode;
11878 pSession->bssParams.cbMode = cbMode;
11879 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011880 }
11881}
11882
Jeff Johnson295189b2012-06-20 16:38:30 -070011883static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11884 tANI_BOOLEAN *pfSameIbss )
11885{
11886 eHalStatus status = eHAL_STATUS_SUCCESS;
11887 tANI_BOOLEAN fSameIbss = FALSE;
11888
11889 if ( csrIsConnStateIbss( pMac, sessionId ) )
11890 {
11891 // Check if any profile parameter has changed ? If any profile parameter
11892 // has changed then stop old BSS and start a new one with new parameters
11893 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11894 {
11895 fSameIbss = TRUE;
11896 }
11897 else
11898 {
11899 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11900 }
11901 }
11902 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11903 {
11904 // Disassociate from the connected Infrastructure network...
11905 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11906 }
11907 else
11908 {
11909 tBssConfigParam *pBssConfig;
11910
Kiet Lam64c1b492013-07-12 13:56:44 +053011911 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11912 if ( NULL == pBssConfig )
11913 status = eHAL_STATUS_FAILURE;
11914 else
11915 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011916 if(HAL_STATUS_SUCCESS(status))
11917 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011918 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011919 // there is no Bss description before we start an IBSS so we need to adopt
11920 // all Bss configuration parameters from the Profile.
11921 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11922 if(HAL_STATUS_SUCCESS(status))
11923 {
11924 //save dotMode
11925 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11926 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011927 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011928 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11929 NULL, pBssConfig,
11930 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011931 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011932
11933 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011934 }//Allocate memory
11935 }
11936
11937 if(pfSameIbss)
11938 {
11939 *pfSameIbss = fSameIbss;
11940 }
11941 return( status );
11942}
11943
Jeff Johnson295189b2012-06-20 16:38:30 -070011944static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11945 tSirSmeNewBssInfo *pNewBss )
11946{
11947 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011948
11949 if(!pSession)
11950 {
11951 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11952 return;
11953 }
11954
Jeff Johnson295189b2012-06-20 16:38:30 -070011955 if( pNewBss )
11956 {
11957 // Set the operating channel.
11958 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11959 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011960 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11961 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011962 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011963 return;
11964}
11965
Jeff Johnson295189b2012-06-20 16:38:30 -070011966#ifdef FEATURE_WLAN_WAPI
11967eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11968 tANI_U32 numItems )
11969{
11970 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11971 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011972 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011974 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011975 return status;
11976 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011977 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011978 pSession = CSR_GET_SESSION( pMac, sessionId );
11979 if(numItems <= CSR_MAX_BKID_ALLOWED)
11980 {
11981 status = eHAL_STATUS_SUCCESS;
11982 //numItems may be 0 to clear the cache
11983 pSession->NumBkidCache = (tANI_U16)numItems;
11984 if(numItems && pBKIDCache)
11985 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011986 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
11987 sizeof(tBkidCacheInfo) * numItems);
11988 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011989 }
11990 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011991 return (status);
11992}
Jeff Johnson295189b2012-06-20 16:38:30 -070011993eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11994 tBkidCacheInfo *pBkidCache)
11995{
11996 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11997 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011998 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11999 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012000 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012001 return status;
12002 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012003 pSession = CSR_GET_SESSION( pMac, sessionId );
12004 if(pNum && pBkidCache)
12005 {
12006 if(pSession->NumBkidCache == 0)
12007 {
12008 *pNum = 0;
12009 status = eHAL_STATUS_SUCCESS;
12010 }
12011 else if(*pNum >= pSession->NumBkidCache)
12012 {
12013 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
12014 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012015 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 -070012016 pSession->NumBkidCache);
12017 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
12018 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012019 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12020 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012021 *pNum = pSession->NumBkidCache;
12022 status = eHAL_STATUS_SUCCESS;
12023 }
12024 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012025 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012026}
Jeff Johnson295189b2012-06-20 16:38:30 -070012027tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12028{
12029 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012030}
12031#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012032eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
12033 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
12034{
12035 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12036 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012037
12038 if(!pSession)
12039 {
12040 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12041 return eHAL_STATUS_FAILURE;
12042 }
12043
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012044 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012045 if(numItems <= CSR_MAX_PMKID_ALLOWED)
12046 {
12047#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12048 {
12049 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012050 vos_mem_set(&secEvent,
12051 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012052 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12053 secEvent.encryptionModeMulticast =
12054 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12055 secEvent.encryptionModeUnicast =
12056 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012057 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012058 secEvent.authMode =
12059 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12060 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12061 }
12062#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012063 status = eHAL_STATUS_SUCCESS;
12064 //numItems may be 0 to clear the cache
12065 pSession->NumPmkidCache = (tANI_U16)numItems;
12066 if(numItems && pPMKIDCache)
12067 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012068 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12069 sizeof(tPmkidCacheInfo) * numItems);
12070 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012071 }
12072 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012073 return (status);
12074}
12075
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012076eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
12077 tANI_U8 *pBSSId )
12078{
12079 eHalStatus status = eHAL_STATUS_FAILURE;
12080 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12081 tANI_BOOLEAN fMatchFound = FALSE;
12082 tANI_U32 Index;
12083 if(!pSession)
12084 {
12085 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12086 return eHAL_STATUS_FAILURE;
12087 }
12088 do
12089 {
12090 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
12091 {
Arif Hussaina7c8e412013-11-20 11:06:42 -080012092 smsLog(pMac, LOGW, "Delete PMKID for "
12093 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Kiet Lamf2f201e2013-11-16 21:24:16 +053012094 if( vos_mem_compare( pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012095 {
12096 fMatchFound = TRUE;
12097 break;
12098 }
12099 }
12100 if( !fMatchFound ) break;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012101 vos_mem_set(pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid), 0);
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012102 status = eHAL_STATUS_SUCCESS;
12103 }
12104 while( 0 );
12105 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
12106 fMatchFound, status);
12107 return status;
12108}
Jeff Johnson295189b2012-06-20 16:38:30 -070012109tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12110{
12111 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12112}
12113
Jeff Johnson295189b2012-06-20 16:38:30 -070012114eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12115{
12116 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12117 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012118
12119 if(!pSession)
12120 {
12121 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12122 return eHAL_STATUS_FAILURE;
12123 }
12124
Jeff Johnson295189b2012-06-20 16:38:30 -070012125 if(pNum && pPmkidCache)
12126 {
12127 if(pSession->NumPmkidCache == 0)
12128 {
12129 *pNum = 0;
12130 status = eHAL_STATUS_SUCCESS;
12131 }
12132 else if(*pNum >= pSession->NumPmkidCache)
12133 {
12134 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12135 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012136 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 -070012137 pSession->NumPmkidCache);
12138 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12139 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012140 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
12141 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012142 *pNum = pSession->NumPmkidCache;
12143 status = eHAL_STATUS_SUCCESS;
12144 }
12145 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012146 return (status);
12147}
12148
Jeff Johnson295189b2012-06-20 16:38:30 -070012149eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12150{
12151 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12152 tANI_U32 len;
12153 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012154
12155 if(!pSession)
12156 {
12157 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12158 return eHAL_STATUS_FAILURE;
12159 }
12160
Jeff Johnson295189b2012-06-20 16:38:30 -070012161 if(pLen)
12162 {
12163 len = *pLen;
12164 *pLen = pSession->nWpaRsnReqIeLength;
12165 if(pBuf)
12166 {
12167 if(len >= pSession->nWpaRsnReqIeLength)
12168 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012169 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12170 pSession->nWpaRsnReqIeLength);
12171 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012172 }
12173 }
12174 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012175 return (status);
12176}
12177
Jeff Johnson295189b2012-06-20 16:38:30 -070012178eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12179{
12180 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12181 tANI_U32 len;
12182 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012183
12184 if(!pSession)
12185 {
12186 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12187 return eHAL_STATUS_FAILURE;
12188 }
12189
Jeff Johnson295189b2012-06-20 16:38:30 -070012190 if(pLen)
12191 {
12192 len = *pLen;
12193 *pLen = pSession->nWpaRsnRspIeLength;
12194 if(pBuf)
12195 {
12196 if(len >= pSession->nWpaRsnRspIeLength)
12197 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012198 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12199 pSession->nWpaRsnRspIeLength);
12200 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012201 }
12202 }
12203 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012204 return (status);
12205}
Jeff Johnson295189b2012-06-20 16:38:30 -070012206#ifdef FEATURE_WLAN_WAPI
12207eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12208{
12209 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12210 tANI_U32 len;
12211 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012212
12213 if(!pSession)
12214 {
12215 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12216 return eHAL_STATUS_FAILURE;
12217 }
12218
Jeff Johnson295189b2012-06-20 16:38:30 -070012219 if(pLen)
12220 {
12221 len = *pLen;
12222 *pLen = pSession->nWapiReqIeLength;
12223 if(pBuf)
12224 {
12225 if(len >= pSession->nWapiReqIeLength)
12226 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012227 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12228 pSession->nWapiReqIeLength);
12229 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012230 }
12231 }
12232 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012233 return (status);
12234}
Jeff Johnson295189b2012-06-20 16:38:30 -070012235eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12236{
12237 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12238 tANI_U32 len;
12239 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012240
12241 if(!pSession)
12242 {
12243 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12244 return eHAL_STATUS_FAILURE;
12245 }
12246
Jeff Johnson295189b2012-06-20 16:38:30 -070012247 if(pLen)
12248 {
12249 len = *pLen;
12250 *pLen = pSession->nWapiRspIeLength;
12251 if(pBuf)
12252 {
12253 if(len >= pSession->nWapiRspIeLength)
12254 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012255 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12256 pSession->nWapiRspIeLength);
12257 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012258 }
12259 }
12260 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012261 return (status);
12262}
12263#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012264eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12265{
12266 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12267 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012268
12269 if(!pSession)
12270 {
12271 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12272 return (retStatus);
12273 }
12274
Jeff Johnson295189b2012-06-20 16:38:30 -070012275 if(CSR_IS_ROAMING(pSession))
12276 {
12277 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12278 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12279 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012280 return (retStatus);
12281}
12282
Jeff Johnson295189b2012-06-20 16:38:30 -070012283//This function remove the connected BSS from te cached scan result
12284eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12285 tCsrRoamConnectedProfile *pConnProfile)
12286{
12287 eHalStatus status = eHAL_STATUS_FAILURE;
12288 tCsrScanResultFilter *pScanFilter = NULL;
12289 tListElem *pEntry;
12290 tCsrScanResult *pResult;
12291 tDot11fBeaconIEs *pIes;
12292 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012293 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12294 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12295 {
12296 do
12297 {
12298 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012299 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12300 if ( NULL == pScanFilter )
12301 status = eHAL_STATUS_FAILURE;
12302 else
12303 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012304 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012305 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12306 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12307 if ( NULL == pScanFilter->BSSIDs.bssid )
12308 status = eHAL_STATUS_FAILURE;
12309 else
12310 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012311 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012312 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12313 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012314 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12315 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12316 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012317 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12318 if ( NULL == pScanFilter->SSIDs.SSIDList )
12319 status = eHAL_STATUS_FAILURE;
12320 else
12321 status = eHAL_STATUS_SUCCESS;
12322 if (!HAL_STATUS_SUCCESS(status)) break;
12323 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12324 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012325 }
12326 pScanFilter->authType.numEntries = 1;
12327 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12328 pScanFilter->BSSType = pConnProfile->BSSType;
12329 pScanFilter->EncryptionType.numEntries = 1;
12330 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12331 pScanFilter->mcEncryptionType.numEntries = 1;
12332 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12333 //We ignore the channel for now, BSSID should be enough
12334 pScanFilter->ChannelInfo.numOfChannels = 0;
12335 //Also ignore the following fields
12336 pScanFilter->uapsd_mask = 0;
12337 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012338 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012339 pScanFilter->countryCode[0] = 0;
12340 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012341 csrLLLock(&pMac->scan.scanResultList);
12342 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12343 while( pEntry )
12344 {
12345 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12346 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12347 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12348 pScanFilter, NULL, NULL, NULL, &pIes);
12349 //Release the IEs allocated by csrMatchBSS is needed
12350 if( !pResult->Result.pvIes )
12351 {
12352 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012353 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012354 }
12355 if(fMatch)
12356 {
12357 //We found the one
12358 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12359 {
12360 //Free the memory
12361 csrFreeScanResultEntry( pMac, pResult );
12362 }
12363 break;
12364 }
12365 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12366 }//while
12367 csrLLUnlock(&pMac->scan.scanResultList);
12368 }while(0);
12369 if(pScanFilter)
12370 {
12371 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012372 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012373 }
12374 }
12375 return (status);
12376}
12377
Jeff Johnson295189b2012-06-20 16:38:30 -070012378//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012379eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12380{
12381 eHalStatus status = eHAL_STATUS_SUCCESS;
12382 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012383 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12384 {
12385 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12386 {
12387 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12388 {
12389 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012390 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012391 status = eHAL_STATUS_CSR_WRONG_STATE;
12392 break;
12393 }
12394 if( csrIsConnStateInfra( pMac, sessionId ) )
12395 {
12396 if( chnId &&
12397 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12398 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012399 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012400 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12401 status = eHAL_STATUS_CSR_WRONG_STATE;
12402 break;
12403 }
12404 }
12405 }
12406 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012407 return ( status );
12408}
12409
Jeff Johnson295189b2012-06-20 16:38:30 -070012410static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12411{
12412 eHalStatus status = eHAL_STATUS_SUCCESS;
12413 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12414 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012415
12416 if(!pSession)
12417 {
12418 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12419 return eHAL_STATUS_FAILURE;
12420 }
12421
Jeff Johnson295189b2012-06-20 16:38:30 -070012422 if ( csrIsConnStateIbss( pMac, sessionId ) )
12423 {
12424 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12425 }
12426 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12427 {
12428 // Disassociate from the connected Infrastructure network...
12429 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12430 }
12431 else
12432 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012433 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12434 //Otherwise we need to add code to handle the
12435 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12436 //send stop_bss to PE, before we can continue.
12437 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012438 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012439 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012440 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12441 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012442 // there is no Bss description before we start an WDS so we need
12443 // to adopt all Bss configuration parameters from the Profile.
12444 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12445 if(HAL_STATUS_SUCCESS(status))
12446 {
12447 //Save profile for late use
12448 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012449 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12450 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012451 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012452 vos_mem_set(pSession->pCurRoamProfile,
12453 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012454 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12455 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012456 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012457 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012458 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12459 NULL, &bssConfig,
12460 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012461 }
12462 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012463
Jeff Johnson295189b2012-06-20 16:38:30 -070012464 return( status );
12465}
12466
Jeff Johnson295189b2012-06-20 16:38:30 -070012467////////////////////Mail box
12468
Jeff Johnson295189b2012-06-20 16:38:30 -070012469//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12470//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012471static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12472 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012473 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12474{
12475 tCsrChannelSet channelGroup;
12476 tSirMacCapabilityInfo *pAP_capabilityInfo;
12477 tAniBool fTmp;
12478 tANI_BOOLEAN found = FALSE;
12479 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012480 tANI_S8 pwrLimit = 0;
12481 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012482 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12483 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12484 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12485 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012486 // 802.11h
12487 //We can do this because it is in HOST CPU order for now.
12488 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012489 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12490 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12491 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012492 fTmp = (tAniBool)pal_cpu_to_be32(1);
12493 }
12494 else
12495 fTmp = (tAniBool)0;
12496
12497 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012498 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012499 pBuf += sizeof(tAniBool);
12500 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012501 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012502 // This is required for 11k test VoWiFi Ent: Test 2.
12503 // We need the power capabilities for Assoc Req.
12504 // This macro is provided by the halPhyCfg.h. We pick our
12505 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012506 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12507 if (0 != pwrLimit)
12508 {
12509 *pBuf++ = pwrLimit;
12510 }
12511 else
12512 {
12513 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12514 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012515 size = sizeof(pMac->roam.validChannelList);
12516 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12517 {
12518 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12519 for ( i = 0; i < size; i++)
12520 {
12521 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12522
12523 }
12524 }
12525 else
12526 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012527 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012528 *pBuf++ = 0; //tSirSupChnl->numChnl
12529 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012530 //Check whether it is ok to enter UAPSD
12531#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12532 if( btcIsReadyForUapsd(pMac) )
12533#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12534 {
12535 *pBuf++ = uapsdMask;
12536 }
12537#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12538 else
12539 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012540 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012541 *pBuf++ = 0;
12542 }
12543#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12544
Jeff Johnson295189b2012-06-20 16:38:30 -070012545 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012546 vos_mem_copy(pBuf, pBssDescription,
12547 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012548 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12549}
12550
Jeff Johnson295189b2012-06-20 16:38:30 -070012551/*
12552 * The communication between HDD and LIM is thru mailbox (MB).
12553 * Both sides will access the data structure "tSirSmeJoinReq".
12554 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12555 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12556 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12557 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12558 */
12559eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012560 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012561{
12562 eHalStatus status = eHAL_STATUS_SUCCESS;
12563 tSirSmeJoinReq *pMsg;
12564 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012565 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012566 tANI_U16 msgLen, wTmp, ieLen;
12567 tSirMacRateSet OpRateSet;
12568 tSirMacRateSet ExRateSet;
12569 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12570 tANI_U32 dwTmp;
12571 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012572 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012573
12574 if(!pSession)
12575 {
12576 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12577 return eHAL_STATUS_FAILURE;
12578 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012579 /* To satisfy klockworks */
12580 if (NULL == pBssDescription)
12581 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012582 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012583 return eHAL_STATUS_FAILURE;
12584 }
12585
Jeff Johnson295189b2012-06-20 16:38:30 -070012586 do {
12587 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12588 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012589 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012590 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12591 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12592 // IE fields, but the length field in the bssDescription needs to be interpreted to
12593 // determine length of the IE fields.
12594 //
12595 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12596 // add in the length from the bssDescription (then add the size of the 'length' field
12597 // itself because that is NOT included in the length field).
12598 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12599 pBssDescription->length + sizeof( pBssDescription->length ) +
12600 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 +053012601 pMsg = vos_mem_malloc(msgLen);
12602 if (NULL == pMsg)
12603 status = eHAL_STATUS_FAILURE;
12604 else
12605 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012606 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012607 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012608 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012609 pMsg->length = pal_cpu_to_be16(msgLen);
12610 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012611 // sessionId
12612 *pBuf = (tANI_U8)sessionId;
12613 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012614 // transactionId
12615 *pBuf = 0;
12616 *( pBuf + 1 ) = 0;
12617 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012618 // ssId
12619 if( pIes->SSID.present && pIes->SSID.num_ssid )
12620 {
12621 // ssId len
12622 *pBuf = pIes->SSID.num_ssid;
12623 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012624 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 pBuf += pIes->SSID.num_ssid;
12626 }
12627 else
12628 {
12629 *pBuf = 0;
12630 pBuf++;
12631 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012632 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012633 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12634 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012635 pBuf += sizeof(tSirMacAddr);
12636 // bsstype
12637 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12638 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012639 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012640 pBuf += sizeof(tSirBssType);
12641 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012642 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12643 if (pBssDescription->channelId <= 14 &&
12644 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12645 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12646 {
12647 //Need to disable VHT operation in 2.4 GHz band
12648 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12649 }
12650 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012651 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012652 //Persona
12653 *pBuf = (tANI_U8)pProfile->csrPersona;
12654 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012655 //CBMode
12656 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12657 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012658
12659 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012660 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12661
Jeff Johnson295189b2012-06-20 16:38:30 -070012662 // uapsdPerAcBitmask
12663 *pBuf = pProfile->uapsd_mask;
12664 pBuf++;
12665
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012666
12667
Jeff Johnson295189b2012-06-20 16:38:30 -070012668 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012669 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012670 {
12671 // OperationalRateSet
12672 if (OpRateSet.numRates) {
12673 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012674 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012675 pBuf += OpRateSet.numRates;
12676 } else *pBuf++ = 0;
12677 // ExtendedRateSet
12678 if (ExRateSet.numRates) {
12679 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012680 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012681 pBuf += ExRateSet.numRates;
12682 } else *pBuf++ = 0;
12683 }
12684 else
12685 {
12686 *pBuf++ = 0;
12687 *pBuf++ = 0;
12688 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012689 // rsnIE
12690 if ( csrIsProfileWpa( pProfile ) )
12691 {
12692 // Insert the Wpa IE into the join request
12693 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12694 (tCsrWpaIe *)( wpaRsnIE ) );
12695 }
12696 else if( csrIsProfileRSN( pProfile ) )
12697 {
12698 // Insert the RSN IE into the join request
12699 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12700 (tCsrRSNIe *)( wpaRsnIE ) );
12701 }
12702#ifdef FEATURE_WLAN_WAPI
12703 else if( csrIsProfileWapi( pProfile ) )
12704 {
12705 // Insert the WAPI IE into the join request
12706 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12707 (tCsrWapiIe *)( wpaRsnIE ) );
12708 }
12709#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012710 else
12711 {
12712 ieLen = 0;
12713 }
12714 //remember the IE for future use
12715 if( ieLen )
12716 {
12717 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12718 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012719 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 -070012720 ieLen = DOT11F_IE_RSN_MAX_LEN;
12721 }
12722#ifdef FEATURE_WLAN_WAPI
12723 if( csrIsProfileWapi( pProfile ) )
12724 {
12725 //Check whether we need to allocate more memory
12726 if(ieLen > pSession->nWapiReqIeLength)
12727 {
12728 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12729 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012730 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012731 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012732 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12733 if (NULL == pSession->pWapiReqIE)
12734 status = eHAL_STATUS_FAILURE;
12735 else
12736 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012737 if(!HAL_STATUS_SUCCESS(status)) break;
12738 }
12739 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012740 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012741 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012742 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012743 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012744 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012745 pBuf += ieLen;
12746 }
12747 else//should be WPA/WPA2 otherwise
12748#endif /* FEATURE_WLAN_WAPI */
12749 {
12750 //Check whether we need to allocate more memory
12751 if(ieLen > pSession->nWpaRsnReqIeLength)
12752 {
12753 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12754 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012755 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012756 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012757 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12758 if (NULL == pSession->pWpaRsnReqIE)
12759 status = eHAL_STATUS_FAILURE;
12760 else
12761 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012762 if(!HAL_STATUS_SUCCESS(status)) break;
12763 }
12764 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012765 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012766 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012767 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012768 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012769 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 pBuf += ieLen;
12771 }
12772 }
12773 else
12774 {
12775 //free whatever old info
12776 pSession->nWpaRsnReqIeLength = 0;
12777 if(pSession->pWpaRsnReqIE)
12778 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012779 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012780 pSession->pWpaRsnReqIE = NULL;
12781 }
12782#ifdef FEATURE_WLAN_WAPI
12783 pSession->nWapiReqIeLength = 0;
12784 if(pSession->pWapiReqIE)
12785 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012786 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012787 pSession->pWapiReqIE = NULL;
12788 }
12789#endif /* FEATURE_WLAN_WAPI */
12790 //length is two bytes
12791 *pBuf = 0;
12792 *(pBuf + 1) = 0;
12793 pBuf += 2;
12794 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012795#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012796 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012797 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012798 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012799 //length is two bytes
12800 *pBuf = 0;
12801 *(pBuf + 1) = 0;
12802 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012803 }
12804 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012805 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012806 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012807 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012808 {
12809 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012810#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012811 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080012812 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012813 pSession->suppCckmIeInfo.cckmIe, ieLen);
12814#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012815 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012816 pSession,
12817 pProfile,
12818 pBssDescription,
12819 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012820 pSession->nWpaRsnReqIeLength,
12821 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012822#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012823 }
12824 else
12825 {
12826 ieLen = 0;
12827 }
12828 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12829 if( ieLen )
12830 {
12831 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12832 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012833 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012834 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012835 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012836 pBuf += ieLen;
12837 }
12838 else
12839 {
12840 //Indicate you have no CCKM IE
12841 //length is two bytes
12842 *pBuf = 0;
12843 *(pBuf + 1) = 0;
12844 pBuf += 2;
12845 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012846 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012847#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070012848 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053012849 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070012850 {
12851 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012852 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012853 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012854 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012855 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012856 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012857 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053012858 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012859 pBuf += ieLen;
12860 }
12861 else
12862 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053012863 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012864 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012865 *pBuf = 0;
12866 *(pBuf + 1) = 0;
12867 pBuf += 2;
12868 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012869 // addIEAssoc
12870 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12871 {
12872 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012873 if(ieLen > pSession->nAddIEAssocLength)
12874 {
12875 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012876 {
12877 vos_mem_free(pSession->pAddIEAssoc);
12878 }
12879 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12880 if (NULL == pSession->pAddIEAssoc)
12881 status = eHAL_STATUS_FAILURE;
12882 else
12883 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012884 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012885 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012886 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012887 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012888 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012889 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012890 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012891 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012892 pBuf += ieLen;
12893 }
12894 else
12895 {
12896 pSession->nAddIEAssocLength = 0;
12897 if(pSession->pAddIEAssoc)
12898 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012899 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012900 pSession->pAddIEAssoc = NULL;
12901 }
12902 *pBuf = 0;
12903 *(pBuf + 1) = 0;
12904 pBuf += 2;
12905 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012906
12907 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012908 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012909 //Unmask any AC in reassoc that is ACM-set
12910 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12911 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012912 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012913 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12914 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012915#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012916 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012917#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012918 }
12919 else
12920 {
12921 uapsd_mask = 0;
12922 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012923 }
12924 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012925
Jeff Johnson295189b2012-06-20 16:38:30 -070012926 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012927 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012928 pBuf += sizeof(tANI_U32);
12929
Jeff Johnson295189b2012-06-20 16:38:30 -070012930 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012931 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012932 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012933#ifdef WLAN_FEATURE_11W
12934 //MgmtEncryption
12935 if (pProfile->MFPEnabled)
12936 {
12937 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12938 }
12939 else
12940 {
12941 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12942 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012943 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012944 pBuf += sizeof(tANI_U32);
12945#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012946#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012947 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012948 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012949#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012950 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012951 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012952#endif
12953 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012954 {
12955 // is11Rconnection;
12956 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012957 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012958 pBuf += sizeof(tAniBool);
12959 }
12960 else
12961 {
12962 // is11Rconnection;
12963 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012964 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012965 pBuf += sizeof(tAniBool);
12966 }
12967#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012968#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012969
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012970 // isESEFeatureIniEnabled
12971 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012972 {
12973 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012974 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012975 pBuf += sizeof(tAniBool);
12976 }
12977 else
12978 {
12979 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080012980 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012981 pBuf += sizeof(tAniBool);
12982 }
12983
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012984 /* A profile can not be both ESE and 11R. But an 802.11R AP
12985 * may be advertising support for ESE as well. So if we are
12986 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012987 * If we are associating explictly 11R only then we will get
12988 * 11R.
12989 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012990 if ((csrIsProfileESE(pProfile) ||
12991 ((pIes->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +053012992 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012993 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012994 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012995 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012996 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012997 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012998 pBuf += sizeof(tAniBool);
12999 }
13000 else
13001 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013002 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013003 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013004 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013005 pBuf += sizeof(tAniBool);
13006 }
13007
13008 if (eWNI_SME_JOIN_REQ == messageType)
13009 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013010 tESETspecInfo eseTspec;
13011 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013012 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013013 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13014 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13015 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013016 }
13017 else if (eWNI_SME_REASSOC_REQ == messageType)
13018 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013019 if ((csrIsProfileESE(pProfile) ||
13020 ((pIes->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +053013021 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013022 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013023 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013024 tESETspecInfo eseTspec;
13025 // ESE Tspec information
13026 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13027 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13028 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013029 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013030 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013031 if (eseTspec.numTspecs) {
13032 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13033 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013034 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013035 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013036 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013037 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013038 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013039 tESETspecInfo eseTspec;
13040 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013041 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013042 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13043 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13044 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013045 }
13046 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013047#endif // FEATURE_WLAN_ESE
13048#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013049 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013050 if (pMac->roam.configParam.isFastTransitionEnabled
13051#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013052 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013053#endif
13054 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013055 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013056 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013057 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013058 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013059 }
13060 else
13061 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013062 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013063 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013064 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013065 }
13066#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013067#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013068 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013069 {
13070 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013071 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013072 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013073 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013074 }
13075 else
13076 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013077 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013078 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013079 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013080 }
13081#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013082
13083 // txLdpcIniFeatureEnabled
13084 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13085 pBuf++;
13086
Kiran4a17ebe2013-01-31 10:43:43 -080013087 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13088 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13089 {
13090 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13091 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13092 csrApplyPower2Current(pMac);
13093 }
13094
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013095#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013096 // txBFIniFeatureEnabled
13097 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13098 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013099
13100 // txBFCsnValue
13101 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13102 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013103#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013104 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13105 pBuf++;
13106
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013107 // WME
13108 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13109 {
13110 //WME enabled
13111 dwTmp = pal_cpu_to_be32(TRUE);
13112 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13113 pBuf += sizeof(tAniBool);
13114 }
13115 else
13116 {
13117 dwTmp = pal_cpu_to_be32(FALSE);
13118 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13119 pBuf += sizeof(tAniBool);
13120 }
13121
13122 // QOS
13123 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13124 {
13125 //QOS enabled
13126 dwTmp = pal_cpu_to_be32(TRUE);
13127 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13128 pBuf += sizeof(tAniBool);
13129 }
13130 else
13131 {
13132 dwTmp = pal_cpu_to_be32(FALSE);
13133 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13134 pBuf += sizeof(tAniBool);
13135 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013136 //BssDesc
13137 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13138 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013139
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013140 status = palSendMBMessage(pMac->hHdd, pMsg );
13141 if(!HAL_STATUS_SUCCESS(status))
13142 {
13143 break;
13144 }
13145 else
13146 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013147#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013148 if (eWNI_SME_JOIN_REQ == messageType)
13149 {
13150 //Tush-QoS: notify QoS module that join happening
13151 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13152 }
13153 else if (eWNI_SME_REASSOC_REQ == messageType)
13154 {
13155 //Tush-QoS: notify QoS module that reassoc happening
13156 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13157 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013158#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013159 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013160 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013161 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013162}
13163
Jeff Johnson295189b2012-06-20 16:38:30 -070013164//
13165eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13166{
13167 eHalStatus status = eHAL_STATUS_SUCCESS;
13168 tSirSmeDisassocReq *pMsg;
13169 tANI_U8 *pBuf;
13170 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013171 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13172 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13173 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013174 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013175 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13176 if (NULL == pMsg)
13177 status = eHAL_STATUS_FAILURE;
13178 else
13179 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013180 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013181 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013182 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13183 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013184 pBuf = &pMsg->sessionId;
13185 // sessionId
13186 *pBuf++ = (tANI_U8)sessionId;
13187 // transactionId
13188 *pBuf = 0;
13189 *( pBuf + 1 ) = 0;
13190 pBuf += sizeof(tANI_U16);
13191
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013192 if ( (pSession->pCurRoamProfile != NULL) &&
13193 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13194 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013195 {
13196 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013197 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13198 sizeof( tSirMacAddr ));
13199 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013200 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013201 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013202 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13203 //perMacAddr is passed as bssId for softAP
13204 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013205 pBuf = pBuf + sizeof ( tSirMacAddr );
13206 }
13207 else
13208 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013209 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013210 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13211 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013212 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013213 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13214 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013215 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013217 if(!HAL_STATUS_SUCCESS(status))
13218 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013219 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013220 break;
13221 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 // reasonCode
13223 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013224 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13225 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013226 if(!HAL_STATUS_SUCCESS(status))
13227 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013228 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013229 break;
13230 }
13231 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013232 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13233 Here we should not send the disassoc over the air to the AP */
13234 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13235#ifdef WLAN_FEATURE_VOWIFI_11R
13236 && csrRoamIs11rAssoc(pMac)
13237#endif
13238 )
13239 {
13240 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13241 }
13242 pBuf += sizeof(tANI_U8);
13243 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013244 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 return( status );
13246}
Jeff Johnson295189b2012-06-20 16:38:30 -070013247eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13248{
13249 eHalStatus status = eHAL_STATUS_SUCCESS;
13250 tSirSmeTkipCntrMeasReq *pMsg;
13251 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013252 do
13253 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013254 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13255 if ( NULL == pMsg )
13256 status = eHAL_STATUS_FAILURE;
13257 else
13258 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013259 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013260 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013261 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13262 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013263 pBuf = &pMsg->sessionId;
13264 // sessionId
13265 *pBuf++ = (tANI_U8)sessionId;
13266 // transactionId
13267 *pBuf = 0;
13268 *( pBuf + 1 ) = 0;
13269 pBuf += sizeof(tANI_U16);
13270 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013271 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13272 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013273 pBuf = pBuf + sizeof ( tSirMacAddr );
13274 // bEnable
13275 *pBuf = (tANI_BOOLEAN)bEnable;
13276 if(!HAL_STATUS_SUCCESS(status))
13277 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013278 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013279 break;
13280 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013281 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013282 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013283 return( status );
13284}
Jeff Johnson295189b2012-06-20 16:38:30 -070013285eHalStatus
13286csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13287 VOS_MODULE_ID modId, tSirMacAddr bssId,
13288 void *pUsrContext, void *pfnSapEventCallback,
13289 tANI_U8 *pAssocStasBuf )
13290{
13291 eHalStatus status = eHAL_STATUS_SUCCESS;
13292 tSirSmeGetAssocSTAsReq *pMsg;
13293 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13294 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013295 do
13296 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013297 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13298 if ( NULL == pMsg )
13299 status = eHAL_STATUS_FAILURE;
13300 else
13301 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013302 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013303 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013304 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013305 pBuf = (tANI_U8 *)&pMsg->bssId;
13306 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013307 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013308 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013309 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 // modId
13311 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013312 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013313 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013314 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013315 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13316 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013317 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013318 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13319 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013320 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013321 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13322 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013324 status = palSendMBMessage( pMac->hHdd, pMsg );
13325 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013326 return( status );
13327 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013328eHalStatus
13329csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13330 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13331 {
13332 eHalStatus status = eHAL_STATUS_SUCCESS;
13333 tSirSmeGetWPSPBCSessionsReq *pMsg;
13334 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013335
Jeff Johnson295189b2012-06-20 16:38:30 -070013336 do
13337 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013338 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13339 if ( NULL == pMsg )
13340 status = eHAL_STATUS_FAILURE;
13341 else
13342 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013343 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013344 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013345 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013346 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013347 VOS_ASSERT(pBuf);
13348
Jeff Johnson295189b2012-06-20 16:38:30 -070013349 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013350 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013351 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13352 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013353 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013354 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13355 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013356 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013357 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013358 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013359 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013360 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013361 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013362 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013363 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013364 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013365 return( status );
13366}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013367
13368eHalStatus
13369csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13370{
13371 tpSirChangeBIParams pMsg;
13372 tANI_U16 len = 0;
13373 eHalStatus status = eHAL_STATUS_SUCCESS;
13374 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13375
13376 if(!pSession)
13377 {
13378 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13379 return eHAL_STATUS_FAILURE;
13380 }
13381
13382 //NO need to update the Beacon Params if update beacon parameter flag is not set
13383 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13384 return eHAL_STATUS_SUCCESS;
13385
13386 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13387
13388 /* Create the message and send to lim */
13389 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013390 pMsg = vos_mem_malloc(len);
13391 if ( NULL == pMsg )
13392 status = eHAL_STATUS_FAILURE;
13393 else
13394 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013395 if(HAL_STATUS_SUCCESS(status))
13396 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013397 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013398 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13399 pMsg->length = len;
13400
13401 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013402 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13403 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013404 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13405 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013406 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013407 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013408 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13409 status = palSendMBMessage(pMac->hHdd, pMsg);
13410 }
13411 return status;
13412}
13413
Jeff Johnson295189b2012-06-20 16:38:30 -070013414eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13415{
13416 eHalStatus status = eHAL_STATUS_SUCCESS;
13417 tSirSmeDeauthReq *pMsg;
13418 tANI_U8 *pBuf;
13419 tANI_U16 wTmp;
13420 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13421 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13422 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013423 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013424 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13425 if ( NULL == pMsg )
13426 status = eHAL_STATUS_FAILURE;
13427 else
13428 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013429 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013430 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013431 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13432 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13433 //sessionId
13434 pBuf = &pMsg->sessionId;
13435 *pBuf++ = (tANI_U8)sessionId;
13436
13437 //tansactionId
13438 *pBuf = 0;
13439 *(pBuf + 1 ) = 0;
13440 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013441 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013442 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013443 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13444 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013445 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13446 sizeof( pMsg->peerMacAddr ) );
13447 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013448 pBuf = pBuf + sizeof(tSirMacAddr);
13449 }
13450 else
13451 {
13452 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013453 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13454 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013455 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013456 }
13457 if(!HAL_STATUS_SUCCESS(status))
13458 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013459 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013460 break;
13461 }
13462 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013463 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13464 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013465 pBuf = pBuf + sizeof(tSirMacAddr);
13466 if(!HAL_STATUS_SUCCESS(status))
13467 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013468 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013469 break;
13470 }
13471 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013472 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13473 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013474 if(!HAL_STATUS_SUCCESS(status))
13475 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013476 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013477 break;
13478 }
13479 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013480 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 return( status );
13482}
13483
Jeff Johnson295189b2012-06-20 16:38:30 -070013484eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13485{
13486 eHalStatus status = eHAL_STATUS_SUCCESS;
13487 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013488 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013489 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13490 if ( NULL == pMsg )
13491 status = eHAL_STATUS_FAILURE;
13492 else
13493 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013494 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013495 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013496 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13497 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13498 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013499 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13500 sizeof(pMsg->peerMacAddr));
13501 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013502 if(!HAL_STATUS_SUCCESS(status))
13503 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013504 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013505 break;
13506 }
13507//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013508 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13509 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013510 if(!HAL_STATUS_SUCCESS(status))
13511 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013512 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013513 break;
13514 }
13515//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013516 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013517 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013518 return( status );
13519}
13520
Jeff Johnson295189b2012-06-20 16:38:30 -070013521eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13522{
13523 eHalStatus status = eHAL_STATUS_SUCCESS;
13524 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013525 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013526 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13527 if ( NULL == pMsg )
13528 status = eHAL_STATUS_FAILURE;
13529 else
13530 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013531 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013532 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013533 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13534 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13535 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013536 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13537 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 if(!HAL_STATUS_SUCCESS(status))
13539 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013540 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013541 break;
13542 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013543 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13544 sizeof(pMsg->peerMacAddr));
13545 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 if(!HAL_STATUS_SUCCESS(status))
13547 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013548 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013549 break;
13550 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013551 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013552 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013553 return( status );
13554}
Jeff Johnson295189b2012-06-20 16:38:30 -070013555eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13556{
13557 eHalStatus status = eHAL_STATUS_SUCCESS;
13558 tSirSmeAssocCnf *pMsg;
13559 tANI_U8 *pBuf;
13560 tSirResultCodes statusCode;
13561 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013562 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013563 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13564 if ( NULL == pMsg )
13565 status = eHAL_STATUS_FAILURE;
13566 else
13567 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013568 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013569 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013570 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13571 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013572 pBuf = (tANI_U8 *)&pMsg->statusCode;
13573 if(HAL_STATUS_SUCCESS(Halstatus))
13574 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13575 else
13576 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013577 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013578 pBuf += sizeof(tSirResultCodes);
13579 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013580 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13581 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013582 pBuf += sizeof (tSirMacAddr);
13583 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013584 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13585 sizeof(tSirMacAddr));
13586 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013587 pBuf += sizeof (tSirMacAddr);
13588 // aid
13589 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013590 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013591 pBuf += sizeof (tANI_U16);
13592 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013593 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13594 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013595 pBuf += sizeof (tSirMacAddr);
13596 // alternateChannelId
13597 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013598 status = palSendMBMessage( pMac->hHdd, pMsg );
13599 if(!HAL_STATUS_SUCCESS(status))
13600 {
13601 //pMsg is freed by palSendMBMessage
13602 break;
13603 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013604 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013605 return( status );
13606}
Jeff Johnson295189b2012-06-20 16:38:30 -070013607eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13608 tpSirSmeAssocInd pAssocInd,
13609 eHalStatus Halstatus,
13610 tANI_U8 sessionId)
13611{
13612 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013613 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13614 tANI_U8 *pBuf;
13615 tSirResultCodes statusCode;
13616 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013617 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013618 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13619 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13620 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013621
Jeff Johnson295189b2012-06-20 16:38:30 -070013622 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13623 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13624
13625 pMsg->sessionId = sessionId;
13626
13627 pBuf = (tANI_U8 *)&pMsg->statusCode;
13628 if(HAL_STATUS_SUCCESS(Halstatus))
13629 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13630 else
13631 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013632 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013633 pBuf += sizeof(tSirResultCodes);
13634 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013635 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013636 pBuf += sizeof (tSirMacAddr);
13637 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013638 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13639 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013640 pBuf += sizeof (tSirMacAddr);
13641 // StaId
13642 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013643 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013644 pBuf += sizeof (tANI_U16);
13645 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013646 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013647 pBuf += sizeof (tSirMacAddr);
13648 // alternateChannelId
13649 *pBuf = 11;
13650 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013651 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013652 //Wmm
13653 *pBuf = pAssocInd->wmmEnabledSta;
13654 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013655 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013656 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013657 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013658 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013659 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013660 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013661 //reassocReq
13662 *pBuf = pAssocInd->reassocReq;
13663 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013664 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13665 msgQ.bodyptr = pMsg;
13666 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013667 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013668 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013669 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013670}
Jeff Johnson295189b2012-06-20 16:38:30 -070013671
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013672eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13674 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13675 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13676 tANI_U8 *pKeyRsc )
13677{
13678 tSirSmeSetContextReq *pMsg;
13679 tANI_U16 msgLen;
13680 eHalStatus status = eHAL_STATUS_FAILURE;
13681 tAniEdType tmpEdType;
13682 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013683 tANI_U8 *pBuf = NULL;
13684 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013685 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013686 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013688 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13689 // key set. Since we only support upto one key, we always allocate memory for 1 key
13690 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13691 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13692 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13693 ( sizeof( pMsg->keyMaterial.key ) );
13694
Kiet Lam64c1b492013-07-12 13:56:44 +053013695 pMsg = vos_mem_malloc(msgLen);
13696 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13697 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013698 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13699 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013700 //sessionId
13701 pBuf = &pMsg->sessionId;
13702 *pBuf = (tANI_U8)sessionId;
13703 pBuf++;
13704 // transactionId
13705 *pBuf = 0;
13706 *(pBuf + 1) = 0;
13707 pBuf += sizeof(tANI_U16);
13708 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013709 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013710
13711 pBuf += sizeof(tSirMacAddr);
13712
13713 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013714 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13715 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013716
13717 pBuf += sizeof(tSirMacAddr);
13718
13719 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013720 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13721 // in the tSirKeyMaterial keyMaterial; field).
13722 //
13723 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13724 // shorter than this max size. Is LIM interpreting this ok ?
13725 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 -070013726 // set pMsg->keyMaterial.edType
13727 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013728 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013729 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013730 // set the pMsg->keyMaterial.numKeys field
13731 *p = numKeys;
13732 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013733 // set pSirKey->keyId = keyId;
13734 *p = keyId;
13735 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013736 // set pSirKey->unicast = (tANI_U8)fUnicast;
13737 *p = (tANI_U8)fUnicast;
13738 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 // set pSirKey->keyDirection = aniKeyDirection;
13740 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013741 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013742 p += sizeof(tAniKeyDirection);
13743 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013744 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013745 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013746 // set pSirKey->paeRole
13747 *p = paeRole; // 0 is Supplicant
13748 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013749 // set pSirKey->keyLength = keyLength;
13750 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 if ( keyLength && pKey )
13752 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013753 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013754 if(keyLength == 16)
13755 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013756 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 -070013757 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13758 pKey[5], pKey[6], pKey[7], pKey[8],
13759 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13760 }
13761 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013762 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013764 return( status );
13765}
13766
Jeff Johnson295189b2012-06-20 16:38:30 -070013767eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13768 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13769{
13770 eHalStatus status;
13771 tSirSmeStartBssReq *pMsg;
13772 tANI_U8 *pBuf = NULL;
13773 tANI_U8 *wTmpBuf = NULL;
13774 tANI_U16 msgLen, wTmp;
13775 tANI_U32 dwTmp;
13776 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013777 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013778 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013779 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013780
13781 if(!pSession)
13782 {
13783 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13784 return eHAL_STATUS_FAILURE;
13785 }
13786
Jeff Johnson295189b2012-06-20 16:38:30 -070013787 do {
13788 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13789 pSession->joinFailStatusCode.reasonCode = 0;
13790 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013791 pMsg = vos_mem_malloc(msgLen);
13792 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13793 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013794 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013795 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013796 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013797 //sessionId
13798 *pBuf = (tANI_U8)sessionId;
13799 pBuf++;
13800 // transactionId
13801 *pBuf = 0;
13802 *(pBuf + 1) = 0;
13803 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013804 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013805 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013806 pBuf += sizeof(tSirMacAddr);
13807 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013808 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013809 pBuf += sizeof(tSirMacAddr);
13810 // beaconInterval
13811 if( pBssDesc && pBssDesc->beaconInterval )
13812 {
13813 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13814 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 else if(pParam->beaconInterval)
13816 {
13817 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13818 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013819 else
13820 {
13821 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13822 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013823 if(csrIsconcurrentsessionValid (pMac, sessionId,
13824 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013825 == eHAL_STATUS_SUCCESS )
13826 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013827 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013828 pParam->bssPersona);
13829 //Update the beacon Interval
13830 pParam->beaconInterval = wTmp;
13831 }
13832 else
13833 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013834 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013835 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013836 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013837 return status;
13838 }
13839
Kiet Lam64c1b492013-07-12 13:56:44 +053013840 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013841 pBuf += sizeof(tANI_U16);
13842 // dot11mode
13843 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13844 pBuf += 1;
13845 // bssType
13846 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013847 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013848 pBuf += sizeof(tSirBssType);
13849 // ssId
13850 if( pParam->ssId.length )
13851 {
13852 // ssId len
13853 *pBuf = pParam->ssId.length;
13854 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013855 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013856 pBuf += pParam->ssId.length;
13857 }
13858 else
13859 {
13860 *pBuf = 0;
13861 pBuf++;
13862 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013863 // set the channel Id
13864 *pBuf = pParam->operationChn;
13865 pBuf++;
13866 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013867 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013868 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013869 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013870
Jeff Johnson295189b2012-06-20 16:38:30 -070013871 // Set privacy
13872 *pBuf = pParam->privacy;
13873 pBuf++;
13874
13875 //Set Uapsd
13876 *pBuf = pParam->ApUapsdEnable;
13877 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013878 //Set SSID hidden
13879 *pBuf = pParam->ssidHidden;
13880 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13882 pBuf++;
13883
13884 //Ht protection Enable/Disable
13885 *pBuf = (tANI_U8)pParam->protEnabled;
13886 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013887 //Enable Beacons to Receive for OBSS protection Enable/Disable
13888 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13889 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013890 //set cfg related to protection
13891 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013892 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013894 // Set Auth type
13895 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013896 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013897 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013898 // Set DTIM
13899 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013900 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013901 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013902 // Set wps_state
13903 *pBuf = pParam->wps_state;
13904 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080013905 // set isCoalesingInIBSSAllowed
13906 *pBuf = pMac->isCoalesingInIBSSAllowed;
13907 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013908 //Persona
13909 *pBuf = (tANI_U8)pParam->bssPersona;
13910 pBuf++;
13911
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013912 //txLdpcIniFeatureEnabled
13913 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13914 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013915
Chet Lanctot8cecea22014-02-11 19:09:36 -080013916#ifdef WLAN_FEATURE_11W
13917 // Set MFP capable/required
13918 *pBuf = (tANI_U8)pParam->mfpCapable;
13919 pBuf++;
13920 *pBuf = (tANI_U8)pParam->mfpRequired;
13921 pBuf++;
13922#endif
13923
krunal soni4f087d22013-07-29 16:32:26 -070013924 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013925 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13926 {
13927 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013928 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013929 break;
13930 }
13931 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013932 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013933 pBuf += sizeof(tANI_U16);
13934 if( wTmp )
13935 {
13936 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013937 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013938 pBuf += wTmp;
13939 }
13940 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013941 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013942 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013943 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13944 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013945 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13946 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013947 pBuf += pParam->operationalRateSet.numRates ;
13948 *pBuf++ = pParam->extendedRateSet.numRates;
13949 if(0 != pParam->extendedRateSet.numRates)
13950 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013951 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13952 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013953 pBuf += pParam->extendedRateSet.numRates;
13954 }
krunal sonie9002db2013-11-25 14:24:17 -080013955
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13957 pMsg->length = pal_cpu_to_be16(msgLen);
13958
13959 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013960 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013961 return( status );
13962}
13963
Jeff Johnson295189b2012-06-20 16:38:30 -070013964eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13965{
13966 eHalStatus status = eHAL_STATUS_FAILURE;
13967 tSirSmeStopBssReq *pMsg;
13968 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13969 tANI_U8 *pBuf;
13970 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013971
13972 if(!pSession)
13973 {
13974 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13975 return eHAL_STATUS_FAILURE;
13976 }
13977
Jeff Johnson295189b2012-06-20 16:38:30 -070013978 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013979 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13980 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13981 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013982 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13983 pBuf = &pMsg->sessionId;
13984 //sessionId
13985 *pBuf = (tANI_U8)sessionId;
13986 pBuf++;
13987 // transactionId
13988 *pBuf = 0;
13989 pBuf += sizeof(tANI_U16);
13990 //reason code
13991 *pBuf = 0;
13992 pBuf += sizeof(tSirResultCodes);
13993 // bssid
13994 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13995 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13996 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013997 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
13998 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013999 }
14000 else
14001 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014002 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14003 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014004 }
14005 pBuf += sizeof(tSirMacAddr);
14006 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
14007 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014008 status = palSendMBMessage( pMac->hHdd, pMsg );
14009#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053014010 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14011 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14012 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14014 pMsg->reasonCode = 0;
14015 // bssid
14016 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14017 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14018 {
14019 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
14020 }
14021 else
14022 {
14023 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
14024 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014025 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014026 pMsg->transactionId = 0;
14027 pMsg->sessionId = (tANI_U8)sessionId;
14028 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
14029 status = palSendMBMessage( pMac->hHdd, pMsg );
14030#endif
14031 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014032 return( status );
14033}
14034
Jeff Johnson295189b2012-06-20 16:38:30 -070014035eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14036 tCsrRoamModifyProfileFields *pModProfileFields,
14037 tANI_U32 *pRoamId, v_BOOL_t fForce)
14038{
Jeff Johnson295189b2012-06-20 16:38:30 -070014039 eHalStatus status = eHAL_STATUS_FAILURE;
14040 tANI_U32 roamId = 0;
14041 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014042 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014043 (fForce || (!vos_mem_compare( &pModProfileFields,
14044 &pSession->connectedProfile.modifyProfileFields,
14045 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014046 {
14047 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14048 if(pRoamId)
14049 {
14050 *pRoamId = roamId;
14051 }
14052
Jeff Johnson295189b2012-06-20 16:38:30 -070014053 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14054 eCsrSmeIssuedReassocToSameAP, roamId,
14055 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014056 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014057 return status;
14058}
Jeff Johnson295189b2012-06-20 16:38:30 -070014059static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14060{
14061 eHalStatus status = eHAL_STATUS_SUCCESS;
14062 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014063 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014064 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14065 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14066 return (status);
14067}
Jeff Johnson295189b2012-06-20 16:38:30 -070014068eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14069{
14070 eHalStatus status = eHAL_STATUS_SUCCESS;
14071 tListElem *pEntry = NULL;
14072 tSmeCmd *pCommand = NULL;
14073 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014074 do
14075 {
14076 if(pMsg == NULL)
14077 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014078 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014079 status = eHAL_STATUS_FAILURE;
14080 break;
14081 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014082 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14083 if(pEntry)
14084 {
14085 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14086 if(eSmeCommandAddStaSession == pCommand->command)
14087 {
14088 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014089 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053014090 if (pRsp->status == eSIR_FAILURE) {
14091 VOS_ASSERT( 0 );
14092 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014093 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014094 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014095 //Remove this command out of the active list
14096 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14097 {
14098 //Now put this command back on the avilable command list
14099 csrReleaseCommand(pMac, pCommand);
14100 }
14101 smeProcessPendingQueue( pMac );
14102 }
14103 else
14104 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014105 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 -070014106 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014107 status = eHAL_STATUS_FAILURE;
14108 break;
14109 }
14110 }
14111 else
14112 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014113 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 -070014114 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014115 status = eHAL_STATUS_FAILURE;
14116 break;
14117 }
14118 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014119 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014120}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014121eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14122 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014123{
14124 tSirSmeAddStaSelfReq *pMsg;
14125 tANI_U16 msgLen;
14126 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014127 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014128 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014129 pMsg = vos_mem_malloc(msgLen);
14130 if ( NULL == pMsg ) break;
14131 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014132 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14133 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014134 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014135 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014136 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14137
14138 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14139
Arif Hussain24bafea2013-11-15 15:10:03 -080014140 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14141 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014142 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014143 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014144 return( status );
14145}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014146eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14147 tANI_U32 sessionId,
14148 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014149{
14150 eHalStatus status = eHAL_STATUS_SUCCESS;
14151 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014152 pCommand = csrGetCommandBuffer(pMac);
14153 if(NULL == pCommand)
14154 {
14155 status = eHAL_STATUS_RESOURCES;
14156 }
14157 else
14158 {
14159 pCommand->command = eSmeCommandAddStaSession;
14160 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014161 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14162 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014163 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014164 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14165 if( !HAL_STATUS_SUCCESS( status ) )
14166 {
14167 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014168 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014169 }
14170 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014171 return (status);
14172}
Jeff Johnson295189b2012-06-20 16:38:30 -070014173eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14174{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014175 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014176}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014177eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14178 csrRoamCompleteCallback callback,
14179 void *pContext, tANI_U8 *pSelfMacAddr,
14180 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014181{
14182 eHalStatus status = eHAL_STATUS_SUCCESS;
14183 tANI_U32 i;
14184 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014185 *pbSessionId = CSR_SESSION_ID_INVALID;
14186 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14187 {
14188 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14189 {
14190 pSession = CSR_GET_SESSION( pMac, i );
14191 status = eHAL_STATUS_SUCCESS;
14192 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14193 pSession->sessionId = (tANI_U8)i;
14194 pSession->callback = callback;
14195 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014196 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014197 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014198 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14199 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014200 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014201 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014202 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014203 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014204 break;
14205 }
14206#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014207 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14208 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014209 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014210 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014211 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014212 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014213 break;
14214 }
14215#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014216 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014217 break;
14218 }
14219 }
14220 if( CSR_ROAM_SESSION_MAX == i )
14221 {
14222 //No session is available
14223 status = eHAL_STATUS_RESOURCES;
14224 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014225 return ( status );
14226}
Jeff Johnson295189b2012-06-20 16:38:30 -070014227eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14228{
14229 eHalStatus status = eHAL_STATUS_SUCCESS;
14230 tListElem *pEntry = NULL;
14231 tSmeCmd *pCommand = NULL;
14232 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014233 do
14234 {
14235 if(pMsg == NULL)
14236 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014237 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014238 status = eHAL_STATUS_FAILURE;
14239 break;
14240 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014241 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14242 if(pEntry)
14243 {
14244 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14245 if(eSmeCommandDelStaSession == pCommand->command)
14246 {
14247 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014248 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014249 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014250 //This session is done.
14251 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014252 if(pCommand->u.delStaSessionCmd.callback)
14253 {
14254
14255 status = sme_ReleaseGlobalLock( &pMac->sme );
14256 if ( HAL_STATUS_SUCCESS( status ) )
14257 {
14258 pCommand->u.delStaSessionCmd.callback(
14259 pCommand->u.delStaSessionCmd.pContext);
14260 status = sme_AcquireGlobalLock( &pMac->sme );
14261 if (! HAL_STATUS_SUCCESS( status ) )
14262 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014263 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014264 return status;
14265 }
14266 }
14267 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014268 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014269 }
14270 }
14271
14272 //Remove this command out of the active list
14273 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14274 {
14275 //Now put this command back on the avilable command list
14276 csrReleaseCommand(pMac, pCommand);
14277 }
14278 smeProcessPendingQueue( pMac );
14279 }
14280 else
14281 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014282 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 -070014283 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014284 status = eHAL_STATUS_FAILURE;
14285 break;
14286 }
14287 }
14288 else
14289 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014290 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 -070014291 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014292 status = eHAL_STATUS_FAILURE;
14293 break;
14294 }
14295 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014296 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014297}
Jeff Johnson295189b2012-06-20 16:38:30 -070014298eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14299{
14300 tSirSmeDelStaSelfReq *pMsg;
14301 tANI_U16 msgLen;
14302 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014303 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014304 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14305 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014306 pMsg = vos_mem_malloc(msgLen);
14307 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14308 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014309 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14310 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014311 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014312 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14313 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014314 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014315 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014316 return( status );
14317}
Jeff Johnson295189b2012-06-20 16:38:30 -070014318eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14319 tSirMacAddr sessionMacAddr,
14320 csrRoamSessionCloseCallback callback,
14321 void *pContext)
14322{
14323 eHalStatus status = eHAL_STATUS_SUCCESS;
14324 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014325 pCommand = csrGetCommandBuffer(pMac);
14326 if(NULL == pCommand)
14327 {
14328 status = eHAL_STATUS_RESOURCES;
14329 }
14330 else
14331 {
14332 pCommand->command = eSmeCommandDelStaSession;
14333 pCommand->sessionId = (tANI_U8)sessionId;
14334 pCommand->u.delStaSessionCmd.callback = callback;
14335 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014336 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14337 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014338 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14339 if( !HAL_STATUS_SUCCESS( status ) )
14340 {
14341 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014342 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014343 }
14344 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014345 return (status);
14346}
Jeff Johnson295189b2012-06-20 16:38:30 -070014347eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14348{
14349 return csrSendMBDelSelfStaReqMsg( pMac,
14350 pCommand->u.delStaSessionCmd.selfMacAddr );
14351}
Jeff Johnson295189b2012-06-20 16:38:30 -070014352static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14353{
14354 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14355 tListElem *pEntry, *pNext;
14356 tSmeCmd *pCommand;
14357 tDblLinkList localList;
14358
14359 vos_mem_zero(&localList, sizeof(tDblLinkList));
14360 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14361 {
14362 smsLog(pMac, LOGE, FL(" failed to open list"));
14363 return;
14364 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014365 csrLLLock(pList);
14366 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14367 while(pEntry != NULL)
14368 {
14369 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14370 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14371 if(pCommand->sessionId == sessionId)
14372 {
14373 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14374 {
14375 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14376 }
14377 }
14378 pEntry = pNext;
14379 }
14380 csrLLUnlock(pList);
14381
14382 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14383 {
14384 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14385 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14386 }
14387 csrLLClose(&localList);
14388}
14389
Jeff Johnson295189b2012-06-20 16:38:30 -070014390void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14391{
14392 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14393 {
14394 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014395 csrRoamStop(pMac, sessionId);
14396 csrFreeConnectBssDesc(pMac, sessionId);
14397 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14398 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014399 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014400#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014401 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014402#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014403 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14404 if (pMac->fScanOffload)
14405 {
14406 purgeSmeSessionCmdList(pMac, sessionId,
14407 &pMac->sme.smeScanCmdPendingList);
14408 }
14409
Jeff Johnson295189b2012-06-20 16:38:30 -070014410 purgeCsrSessionCmdList(pMac, sessionId);
14411 csrInitSession(pMac, sessionId);
14412 }
14413}
14414
Jeff Johnson295189b2012-06-20 16:38:30 -070014415eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14416 tANI_BOOLEAN fSync,
14417 csrRoamSessionCloseCallback callback,
14418 void *pContext )
14419{
14420 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014421 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14422 {
14423 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14424 if(fSync)
14425 {
14426 csrCleanupSession(pMac, sessionId);
14427 }
14428 else
14429 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014430 purgeSmeSessionCmdList(pMac, sessionId,
14431 &pMac->sme.smeCmdPendingList);
14432 if (pMac->fScanOffload)
14433 {
14434 purgeSmeSessionCmdList(pMac, sessionId,
14435 &pMac->sme.smeScanCmdPendingList);
14436 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014437 purgeCsrSessionCmdList(pMac, sessionId);
14438 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14439 pSession->selfMacAddr, callback, pContext);
14440 }
14441 }
14442 else
14443 {
14444 status = eHAL_STATUS_INVALID_PARAMETER;
14445 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014446 return ( status );
14447}
14448
Jeff Johnson295189b2012-06-20 16:38:30 -070014449static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14450{
14451 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014452
14453 if(!pSession)
14454 {
14455 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14456 return;
14457 }
14458
Jeff Johnson295189b2012-06-20 16:38:30 -070014459 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14460 pSession->sessionId = CSR_SESSION_ID_INVALID;
14461 pSession->callback = NULL;
14462 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014463 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14464 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14465 csrFreeRoamProfile( pMac, sessionId );
14466 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14467 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14468 csrFreeConnectBssDesc(pMac, sessionId);
14469 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014470 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14471 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014472 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014473 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014474 pSession->pWpaRsnReqIE = NULL;
14475 }
14476 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014477 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014478 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014479 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014480 pSession->pWpaRsnRspIE = NULL;
14481 }
14482 pSession->nWpaRsnRspIeLength = 0;
14483#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014484 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014485 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014486 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014487 pSession->pWapiReqIE = NULL;
14488 }
14489 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014490 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014491 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014492 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014493 pSession->pWapiRspIE = NULL;
14494 }
14495 pSession->nWapiRspIeLength = 0;
14496#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014497 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014498 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014499 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014500 }
14501 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014502
Kiet Lam64c1b492013-07-12 13:56:44 +053014503 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014504 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014505 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014506 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014507 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014508 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014509}
14510
Jeff Johnson295189b2012-06-20 16:38:30 -070014511eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14512{
14513 eHalStatus status = eHAL_STATUS_FAILURE;
14514 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014515 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14516 {
14517 if( CSR_IS_SESSION_VALID( pMac, i ) )
14518 {
14519 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14520 {
14521 //Found it
14522 status = eHAL_STATUS_SUCCESS;
14523 *pSessionId = i;
14524 break;
14525 }
14526 }
14527 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014528 return( status );
14529}
14530
Jeff Johnson295189b2012-06-20 16:38:30 -070014531//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14532//session because for IBSS, the bssid changes.
14533static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14534{
14535 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14536 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014537 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14538 {
14539 if( CSR_IS_SESSION_VALID( pMac, i ) )
14540 {
14541 pSession = CSR_GET_SESSION( pMac, i );
14542 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14543 {
14544 //Found it
14545 nRet = i;
14546 break;
14547 }
14548 }
14549 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014550 return (nRet);
14551}
Jeff Johnson295189b2012-06-20 16:38:30 -070014552static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14553{
14554 /* Update the current BSS info in ho control block based on connected
14555 profile info from pmac global structure */
14556
Arif Hussain24bafea2013-11-15 15:10:03 -080014557 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14558 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014559 /* Check for user misconfig of RSSI trigger threshold */
14560 pMac->roam.configParam.vccRssiThreshold =
14561 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14562 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14563 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014564 /* Check for user misconfig of UL MAC Loss trigger threshold */
14565 pMac->roam.configParam.vccUlMacLossThreshold =
14566 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14567 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014568#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14569 {
14570 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014571 /* Indicate the neighbor roal algorithm about the connect indication */
14572 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14573 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14574 }
14575#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014576}
14577
Jeff Johnson295189b2012-06-20 16:38:30 -070014578static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14579{
14580 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014581
14582 if(!pSession)
14583 {
14584 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14585 return;
14586 }
14587
Jeff Johnson295189b2012-06-20 16:38:30 -070014588 //Only to handle the case for Handover on infra link
14589 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14590 {
14591 return;
14592 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014593 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14594 csrRoamDeregStatisticsReq(pMac);
14595 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14596#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14597 /* Indicate the neighbor roal algorithm about the disconnect indication */
14598 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14599#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014600
14601 //Remove this code once SLM_Sessionization is supported
14602 //BMPS_WORKAROUND_NOT_NEEDED
14603 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014604 csrIsInfraApStarted( pMac ) &&
14605 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014606 {
14607 pMac->roam.configParam.doBMPSWorkaround = 0;
14608 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014609}
14610
Jeff Johnson295189b2012-06-20 16:38:30 -070014611void csrRoamTlStatsTimerHandler(void *pv)
14612{
14613 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14614 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014615 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14616
Jeff Johnsone7245742012-09-05 17:12:55 -070014617 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14618
Jeff Johnson295189b2012-06-20 16:38:30 -070014619#if 0
14620 // TODO Persession .???
14621 //req TL for stats
14622 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14623 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014624 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014625 }
14626 else
14627 {
14628 //save in SME
14629 csrRoamSaveStatsFromTl(pMac, tlStats);
14630 }
14631#endif
14632 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14633 {
14634 if(pMac->roam.tlStatsReqInfo.periodicity)
14635 {
14636 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014637 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14638 pMac->roam.tlStatsReqInfo.periodicity);
14639 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014640 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014641 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014642 return;
14643 }
14644 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14645 }
14646 }
14647}
Jeff Johnson295189b2012-06-20 16:38:30 -070014648void csrRoamPeStatsTimerHandler(void *pv)
14649{
14650 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14651 eHalStatus status;
14652 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14653 VOS_STATUS vosStatus;
14654 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014655 pPeStatsReqListEntry->timerRunning = FALSE;
14656 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14657 {
14658 // If we entered here, meaning the timer could not be successfully
14659 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14660
14661 /* Destroy the timer */
14662 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14663 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14664 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014665 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014666 }
14667
14668 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014669 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014670 pPeStatsReqListEntry = NULL;
14671 }
14672 else
14673 {
14674 if(!pPeStatsReqListEntry->rspPending)
14675 {
14676 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14677 pPeStatsReqListEntry->staId);
14678 if(!HAL_STATUS_SUCCESS(status))
14679 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014680 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014681 }
14682 else
14683 {
14684 pPeStatsReqListEntry->rspPending = TRUE;
14685 }
14686 }
14687
14688 //send down a req
14689 if(pPeStatsReqListEntry->periodicity &&
14690 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14691 {
14692 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14693 if(ePMC_FULL_POWER == powerState)
14694 {
14695 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14696 {
14697 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14698 }
14699 }
14700 else
14701 {
14702 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14703 {
14704 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14705 }
14706 }
14707 //start timer
14708 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14709 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14710 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014711 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014712 return;
14713 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014714 pPeStatsReqListEntry->timerRunning = TRUE;
14715
14716 }
14717
14718 }
14719}
Jeff Johnson295189b2012-06-20 16:38:30 -070014720void csrRoamStatsClientTimerHandler(void *pv)
14721{
14722 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014723 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14724 {
14725#if 0
14726 // TODO Stats fix for multisession
14727 //start the timer
14728 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14729
14730 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14731 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014732 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014733 }
14734#endif
14735 }
14736#if 0
14737 //send up the stats report
14738 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14739 pStaEntry->staId, pStaEntry->pContext);
14740#endif
14741}
14742
14743
14744
Jeff Johnson295189b2012-06-20 16:38:30 -070014745eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14746{
14747 tAniGetPEStatsReq *pMsg;
14748 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014749 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14750 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014751 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014752 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053014753 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014754 }
14755 // need to initiate a stats request to PE
14756 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14757 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14758 pMsg->staId = staId;
14759 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014760 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014761 if(!HAL_STATUS_SUCCESS(status))
14762 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014763 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070014764 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014765 return status;
14766}
Jeff Johnson295189b2012-06-20 16:38:30 -070014767void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14768{
14769 tAniGetPEStatsRsp *pSmeStatsRsp;
14770 eHalStatus status = eHAL_STATUS_FAILURE;
14771 tListElem *pEntry = NULL;
14772 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14773 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14774 tANI_U32 tempMask = 0;
14775 tANI_U8 counter = 0;
14776 tANI_U8 *pStats = NULL;
14777 tANI_U32 length = 0;
14778 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014779 v_S7_t rssi = 0, snr = 0;
14780 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014781 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014782 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14783 if(pSmeStatsRsp->rc)
14784 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014785 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014786 goto post_update;
14787 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014788 tempMask = pSmeStatsRsp->statsMask;
14789 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014790 /* subtract all statistics from this length, and after processing the entire
14791 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14792 * in this 'stats' message.
14793 */
14794 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014795 //new stats info from PE, fill up the stats strucutres in PMAC
14796 while(tempMask)
14797 {
14798 if(tempMask & 1)
14799 {
14800 switch(counter)
14801 {
14802 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014803 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014804 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14805 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014806 pStats += sizeof(tCsrSummaryStatsInfo);
14807 length -= sizeof(tCsrSummaryStatsInfo);
14808 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014809 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014810 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014811 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14812 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014813 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14814 length -= sizeof(tCsrGlobalClassAStatsInfo);
14815 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014816 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014817 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014818 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14819 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014820 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14821 length -= sizeof(tCsrGlobalClassBStatsInfo);
14822 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014823 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014824 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014825 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14826 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014827 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14828 length -= sizeof(tCsrGlobalClassCStatsInfo);
14829 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014830 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014831 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014832 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14833 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014834 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14835 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014836 }
14837 else
14838 {
14839 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014840 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014841 VOS_ASSERT( 0 );
14842 }
14843 if(!HAL_STATUS_SUCCESS(status))
14844 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014845 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014846 }
14847 pStats += sizeof(tCsrPerStaStatsInfo);
14848 length -= sizeof(tCsrPerStaStatsInfo);
14849 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014850 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014851 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014852 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014853 }
14854 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014855 tempMask >>=1;
14856 counter++;
14857 }
14858 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14859 if (length != 0)
14860 {
14861 pRssi = (tANI_U32*)pStats;
14862 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014863 pStats += sizeof(tANI_U32);
14864 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014865 }
14866 else
14867 {
14868 /* If riva is not sending rssi, continue to use the hack */
14869 rssi = RSSI_HACK_BMPS;
14870 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014871
Jeff Johnson295189b2012-06-20 16:38:30 -070014872 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014873
14874 if (length != 0)
14875 {
14876 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014877 pStats += sizeof(tANI_U32);
14878 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014879 }
14880 else
14881 {
14882 linkCapacity = 0;
14883 }
14884
14885 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014886
14887 if (length != 0)
14888 {
14889 pSnr = (tANI_U32*)pStats;
14890 snr = (v_S7_t)*pSnr;
14891 }
14892 else
14893 {
14894 snr = SNR_HACK_BMPS;
14895 }
14896
14897 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014898post_update:
14899 //make sure to update the pe stats req list
14900 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14901 if(pEntry)
14902 {
14903 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14904 pPeStaEntry->rspPending = FALSE;
14905
14906 }
14907 //check the one timer cases
14908 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14909 if(pEntry)
14910 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014911 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014912 if(pTempStaEntry->timerExpired)
14913 {
14914 //send up the stats report
14915 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14916 pTempStaEntry->staId, pTempStaEntry->pContext);
14917 //also remove from the client list
14918 csrRoamRemoveStatListEntry(pMac, pEntry);
14919 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014920 }
14921 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014922}
Jeff Johnson295189b2012-06-20 16:38:30 -070014923tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14924{
14925 tListElem *pEntry = NULL;
14926 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014927 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014928 if(!pEntry)
14929 {
14930 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014931 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014932 return NULL;
14933 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014934 while( pEntry )
14935 {
14936 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014937 if(pTempStaEntry->statsMask == statsMask)
14938 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014939 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014940 break;
14941 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014942 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14943 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014944 return pEntry;
14945}
14946
Jeff Johnson295189b2012-06-20 16:38:30 -070014947tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14948 tANI_BOOLEAN update)
14949{
14950 tListElem *pEntry;
14951 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014952 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014953 if(!pEntry)
14954 {
14955 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014956 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014957 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014958 return NULL;
14959 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014960 while( pEntry )
14961 {
14962 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014963 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14964 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14965 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014966 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014967 if(update)
14968 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014969 pTempStaEntry->periodicity = pStaEntry->periodicity;
14970 pTempStaEntry->callback = pStaEntry->callback;
14971 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014972 }
14973 break;
14974 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014975 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14976 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014977 return pEntry;
14978}
Jeff Johnson295189b2012-06-20 16:38:30 -070014979tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14980{
14981 tListElem *pEntry;
14982 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014983 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014984 if(!pEntry)
14985 {
14986 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014987 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014988 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014989 return NULL;
14990 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014991 while( pEntry )
14992 {
14993 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014994 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14995 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014996 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014997 break;
14998 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014999 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15000 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015001 return pEntry;
15002}
Jeff Johnson295189b2012-06-20 16:38:30 -070015003eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
15004 csrRoamLinkQualityIndCallback callback,
15005 void *pContext)
15006{
15007 pMac->roam.linkQualityIndInfo.callback = callback;
15008 pMac->roam.linkQualityIndInfo.context = pContext;
15009 if( NULL == callback )
15010 {
15011 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
15012 }
15013 else
15014 {
15015 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070015016 /* do we need to invoke the callback to notify client of initial value ?? */
15017 }
15018 return eHAL_STATUS_SUCCESS;
15019}
Jeff Johnson295189b2012-06-20 16:38:30 -070015020void csrRoamVccTrigger(tpAniSirGlobal pMac)
15021{
15022 eCsrRoamLinkQualityInd newVccLinkQuality;
15023 tANI_U32 ul_mac_loss = 0;
15024 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015025 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15026 /*-------------------------------------------------------------------------
15027 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015028 Check for a change in link quality and notify client if necessary
15029 -------------------------------------------------------------------------*/
15030 ul_mac_loss_trigger_threshold =
15031 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015032 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015033 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015034 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015035 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15036 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015037 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015038 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15039 }
15040 else
15041 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015042 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015043 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15044 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015045 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15046 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015047 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15048 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015049 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015050 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15051 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015052 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015053 newVccLinkQuality );
15054
15055 /* we now invoke the callback once to notify client of initial value */
15056 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15057 pMac->roam.linkQualityIndInfo.context );
15058 //event: EVENT_WLAN_VCC
15059 }
15060 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015061 pMac->roam.vccLinkQuality = newVccLinkQuality;
15062
Jeff Johnson295189b2012-06-20 16:38:30 -070015063}
Jeff Johnson295189b2012-06-20 16:38:30 -070015064VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15065 v_U8_t rssiNotification,
15066 void * context)
15067{
15068 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15069 eCsrRoamLinkQualityInd newVccLinkQuality;
15070 // TODO : Session info unavailable
15071 tANI_U32 sessionId = 0;
15072 VOS_STATUS status = VOS_STATUS_SUCCESS;
15073 /*-------------------------------------------------------------------------
15074 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015075 Check for a change in link quality and notify client if necessary
15076 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015077 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015078 pMac->roam.configParam.vccRssiThreshold);
15079 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15080 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015081 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015082 return VOS_STATUS_SUCCESS;
15083 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015084 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15085 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015086 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015087 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15088 }
15089 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15090 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015091 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015092 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15093 }
15094 else
15095 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015096 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015097 //Set to this so the code below won't do anything
15098 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015099 VOS_ASSERT(0);
15100 }
15101
Jeff Johnson295189b2012-06-20 16:38:30 -070015102 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15103 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015104 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015105 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15106 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015107 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015108 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015109 /* we now invoke the callback once to notify client of initial value */
15110 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15111 pMac->roam.linkQualityIndInfo.context );
15112 //event: EVENT_WLAN_VCC
15113 }
15114 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015115 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015116 return status;
15117}
Jeff Johnson295189b2012-06-20 16:38:30 -070015118tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15119 tDblLinkList *pStaList,
15120 tCsrStatsClientReqInfo *pStaEntry)
15121{
15122 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015123 //if same entity requested for same set of stats with different periodicity &
15124 // callback update it
15125 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15126 {
15127
Kiet Lam64c1b492013-07-12 13:56:44 +053015128 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15129 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015130 {
15131 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015132 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015133 return NULL;
15134 }
15135
Jeff Johnson295189b2012-06-20 16:38:30 -070015136 pNewStaEntry->callback = pStaEntry->callback;
15137 pNewStaEntry->pContext = pStaEntry->pContext;
15138 pNewStaEntry->periodicity = pStaEntry->periodicity;
15139 pNewStaEntry->requesterId = pStaEntry->requesterId;
15140 pNewStaEntry->statsMask = pStaEntry->statsMask;
15141 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15142 pNewStaEntry->pMac = pStaEntry->pMac;
15143 pNewStaEntry->staId = pStaEntry->staId;
15144 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15145
15146 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15147 }
15148 return pNewStaEntry;
15149}
15150
Jeff Johnson295189b2012-06-20 16:38:30 -070015151tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15152 tDblLinkList *pStaList,
15153 tCsrPeStatsReqInfo *pStaEntry)
15154{
15155 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015156 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15157 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015158 {
15159 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015160 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015161 return NULL;
15162 }
15163
Jeff Johnson295189b2012-06-20 16:38:30 -070015164 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15165 pNewStaEntry->numClient = pStaEntry->numClient;
15166 pNewStaEntry->periodicity = pStaEntry->periodicity;
15167 pNewStaEntry->statsMask = pStaEntry->statsMask;
15168 pNewStaEntry->pMac = pStaEntry->pMac;
15169 pNewStaEntry->staId = pStaEntry->staId;
15170 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15171 pNewStaEntry->rspPending = pStaEntry->rspPending;
15172
15173 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015174 return pNewStaEntry;
15175}
Jeff Johnson295189b2012-06-20 16:38:30 -070015176eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15177 tCsrRssiCallback callback,
15178 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15179{
15180 eHalStatus status = eHAL_STATUS_SUCCESS;
15181 vos_msg_t msg;
15182 tANI_U32 sessionId;
15183
15184 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015185 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015186 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15187 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015188 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015189 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015190 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015191 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015192 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15193
15194 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15195 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15196 pMsg->sessionId = sessionId;
15197 pMsg->staId = staId;
15198 pMsg->rssiCallback = callback;
15199 pMsg->pDevContext = pContext;
15200 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015201 msg.type = eWNI_SME_GET_RSSI_REQ;
15202 msg.bodyptr = pMsg;
15203 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015204 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15205 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015206 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015207 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015208 status = eHAL_STATUS_FAILURE;
15209 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015210 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015211 return status;
15212}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015213
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015214eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15215 tCsrSnrCallback callback,
15216 tANI_U8 staId, tCsrBssid bssId,
15217 void *pContext)
15218{
15219 eHalStatus status = eHAL_STATUS_SUCCESS;
15220 vos_msg_t msg;
15221 tANI_U32 sessionId;
15222
15223 tAniGetSnrReq *pMsg;
15224
15225 smsLog(pMac, LOG2, FL("called"));
15226
15227 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15228 if (NULL == pMsg )
15229 {
15230 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15231 return status;
15232 }
15233
15234 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15235
15236 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15237 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15238 pMsg->sessionId = sessionId;
15239 pMsg->staId = staId;
15240 pMsg->snrCallback = callback;
15241 pMsg->pDevContext = pContext;
15242 msg.type = eWNI_SME_GET_SNR_REQ;
15243 msg.bodyptr = pMsg;
15244 msg.reserved = 0;
15245
15246 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15247 {
15248 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15249 vos_mem_free((v_VOID_t *)pMsg);
15250 status = eHAL_STATUS_FAILURE;
15251 }
15252
15253 smsLog(pMac, LOG2, FL("returned"));
15254 return status;
15255}
15256
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015257#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015258eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15259 tCsrRssiCallback callback,
15260 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15261{
15262 eHalStatus status = eHAL_STATUS_SUCCESS;
15263 tAniGetRssiReq *pMsg;
15264
Kiet Lam64c1b492013-07-12 13:56:44 +053015265 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15266 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015267 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015268 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015269 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015270 }
15271 // need to initiate a stats request to PE
15272 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15273 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15274 pMsg->staId = staId;
15275 pMsg->rssiCallback = callback;
15276 pMsg->pDevContext = pContext;
15277 pMsg->pVosContext = pVosContext;
15278 status = palSendMBMessage(pMac->hHdd, pMsg );
15279 if(!HAL_STATUS_SUCCESS(status))
15280 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015281 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015282 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015283 status = eHAL_STATUS_FAILURE;
15284 }
15285 return status;
15286}
15287#endif
15288
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015289
15290
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015291#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015292eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15293 tCsrTsmStatsCallback callback,
15294 tANI_U8 staId,
15295 tCsrBssid bssId,
15296 void *pContext,
15297 void* pVosContext,
15298 tANI_U8 tid)
15299{
15300 eHalStatus status = eHAL_STATUS_SUCCESS;
15301 tAniGetTsmStatsReq *pMsg = NULL;
15302
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015303 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15304 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015305 {
15306 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015307 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015308 }
15309 // need to initiate a stats request to PE
15310 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15311 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15312 pMsg->staId = staId;
15313 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015314 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015315 pMsg->tsmStatsCallback = callback;
15316 pMsg->pDevContext = pContext;
15317 pMsg->pVosContext = pVosContext;
15318 status = palSendMBMessage(pMac->hHdd, pMsg );
15319 if(!HAL_STATUS_SUCCESS(status))
15320 {
15321 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15322 //pMsg is freed by palSendMBMessage
15323 status = eHAL_STATUS_FAILURE;
15324 }
15325 return status;
15326}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015327#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015328
15329
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015330/* ---------------------------------------------------------------------------
15331 \fn csrGetTLSTAState
15332 \helper function to get teh TL STA State whenever the function is called.
15333
15334 \param staId - The staID to be passed to the TL
15335 to get the relevant TL STA State
15336 \return the state as tANI_U16
15337 ---------------------------------------------------------------------------*/
15338tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15339{
15340 WLANTL_STAStateType tlSTAState;
15341 tlSTAState = WLANTL_STA_INIT;
15342
15343 //request TL for STA State
15344 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15345 {
15346 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15347 }
15348
15349 return tlSTAState;
15350}
15351
Jeff Johnson295189b2012-06-20 16:38:30 -070015352eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15353 tANI_U32 statsMask,
15354 tCsrStatsCallback callback,
15355 tANI_U32 periodicity, tANI_BOOLEAN cache,
15356 tANI_U8 staId, void *pContext)
15357{
15358 tCsrStatsClientReqInfo staEntry;
15359 tCsrStatsClientReqInfo *pStaEntry = NULL;
15360 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15361 tListElem *pEntry = NULL;
15362 tANI_BOOLEAN found = FALSE;
15363 eHalStatus status = eHAL_STATUS_SUCCESS;
15364 tANI_BOOLEAN insertInClientList = FALSE;
15365 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015366 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015367
15368 if( csrIsAllSessionDisconnected(pMac) )
15369 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015370 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015371 return eHAL_STATUS_FAILURE;
15372 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015373
15374 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15375 {
15376 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15377 return eHAL_STATUS_FAILURE;
15378 }
15379
Jeff Johnson295189b2012-06-20 16:38:30 -070015380 if((!statsMask) && (!callback))
15381 {
15382 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015383 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015384 return eHAL_STATUS_FAILURE;
15385 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015386 //for the search list method for deregister
15387 staEntry.requesterId = requesterId;
15388 staEntry.statsMask = statsMask;
15389 //requester wants to deregister or just an error
15390 if((statsMask) && (!callback))
15391 {
15392 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15393 if(!pEntry)
15394 {
15395 //msg
15396 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015397 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015398 return eHAL_STATUS_FAILURE;
15399 }
15400 else
15401 {
15402 //clean up & return
15403 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015404 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015405 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015406 pStaEntry->pPeStaEntry->numClient--;
15407 //check if we need to delete the entry from peStatsReqList too
15408 if(!pStaEntry->pPeStaEntry->numClient)
15409 {
15410 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15411 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015412 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015413
Jeff Johnson295189b2012-06-20 16:38:30 -070015414 //check if we need to stop the tl stats timer too
15415 pMac->roam.tlStatsReqInfo.numClient--;
15416 if(!pMac->roam.tlStatsReqInfo.numClient)
15417 {
15418 if(pMac->roam.tlStatsReqInfo.timerRunning)
15419 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015420 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15421 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015422 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015423 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015424 return eHAL_STATUS_FAILURE;
15425 }
15426 }
15427 pMac->roam.tlStatsReqInfo.periodicity = 0;
15428 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15429 }
15430 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015431 // Destroy the vos timer...
15432 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15433 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15434 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015435 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015436 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015437 csrRoamRemoveStatListEntry(pMac, pEntry);
15438 pStaEntry = NULL;
15439 return eHAL_STATUS_SUCCESS;
15440 }
15441 }
15442
15443 if(cache && !periodicity)
15444 {
15445 //return the cached stats
15446 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15447 }
15448 else
15449 {
15450 //add the request in the client req list
15451 staEntry.callback = callback;
15452 staEntry.pContext = pContext;
15453 staEntry.periodicity = periodicity;
15454 staEntry.pPeStaEntry = NULL;
15455 staEntry.staId = staId;
15456 staEntry.pMac = pMac;
15457 staEntry.timerExpired = FALSE;
15458
15459
Jeff Johnson295189b2012-06-20 16:38:30 -070015460 //if periodic report requested with non cached result from PE/TL
15461 if(periodicity)
15462 {
15463
15464 //if looking for stats from PE
15465 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15466 {
15467
15468 //check if same request made already & waiting for rsp
15469 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15470 periodicity, &found, staId);
15471 if(!pPeStaEntry)
15472 {
15473 //bail out, maxed out on number of req for PE
15474 return eHAL_STATUS_FAILURE;
15475 }
15476 else
15477 {
15478 staEntry.pPeStaEntry = pPeStaEntry;
15479 }
15480
15481 }
15482 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15483 if(statsMask & (1 << eCsrGlobalClassDStats))
15484 {
15485 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15486 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015487 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015488 }
15489 else
15490 {
15491
15492 //update periodicity
15493 if(pMac->roam.tlStatsReqInfo.periodicity)
15494 {
15495 pMac->roam.tlStatsReqInfo.periodicity =
15496 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15497 }
15498 else
15499 {
15500 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15501 }
15502 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15503 {
15504 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15505 }
15506
15507 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15508 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015509 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015510 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015511 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015512 //req TL for class D stats
15513 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15514 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015515 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015516 }
15517 else
15518 {
15519 //save in SME
15520 csrRoamSaveStatsFromTl(pMac, pTlStats);
15521 }
15522 vos_mem_free(pTlStats);
15523 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015524 }
15525 else
15526 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015527 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015528 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015529
Jeff Johnson295189b2012-06-20 16:38:30 -070015530 if(pMac->roam.tlStatsReqInfo.periodicity)
15531 {
15532 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015533 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15534 pMac->roam.tlStatsReqInfo.periodicity);
15535 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015536 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015537 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015538 return eHAL_STATUS_FAILURE;
15539 }
15540 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15541 }
15542 }
15543 }
15544 pMac->roam.tlStatsReqInfo.numClient++;
15545 }
15546
15547 insertInClientList = TRUE;
15548 }
15549 //if one time report requested with non cached result from PE/TL
15550 else if(!cache && !periodicity)
15551 {
15552 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15553 {
15554 //send down a req
15555 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15556 if(!HAL_STATUS_SUCCESS(status))
15557 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015558 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015559 }
15560 //so that when the stats rsp comes back from PE we respond to upper layer
15561 //right away
15562 staEntry.timerExpired = TRUE;
15563 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015564 }
15565 if(statsMask & (1 << eCsrGlobalClassDStats))
15566 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015567 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015568 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015569 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015570 //req TL for class D stats
15571 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15572 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015573 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015574 }
15575 else
15576 {
15577 //save in SME
15578 csrRoamSaveStatsFromTl(pMac, pTlStats);
15579 }
15580 vos_mem_free(pTlStats);
15581 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015582 }
15583 else
15584 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015585 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015586 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015587
15588 }
15589 //if looking for stats from TL only
15590 if(!insertInClientList)
15591 {
15592 //return the stats
15593 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15594 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015595 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015596 if(insertInClientList)
15597 {
15598 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15599 if(!pStaEntry)
15600 {
15601 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015602 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015603 return eHAL_STATUS_FAILURE;
15604 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015605 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015606 //Init & start timer if needed
15607 if(periodicity)
15608 {
15609 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15610 csrRoamStatsClientTimerHandler, pStaEntry );
15611 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15612 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015613 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015614 return eHAL_STATUS_FAILURE;
15615 }
15616 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15617 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15618 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015619 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015620 return eHAL_STATUS_FAILURE;
15621 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015622 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015623 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015624 }
15625 return eHAL_STATUS_SUCCESS;
15626}
15627
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015628#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15629
15630static tSirRetStatus
15631csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15632 tANI_U8* pBD,
15633 tANI_U8 type,
15634 tANI_U8 subType,
15635 tSirMacAddr peerAddr,
15636 tSirMacAddr selfMacAddr)
15637{
15638 tSirRetStatus statusCode = eSIR_SUCCESS;
15639 tpSirMacMgmtHdr pMacHdr;
15640
15641 /* Prepare MAC management header */
15642 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15643
15644 /* Prepare FC */
15645 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15646 pMacHdr->fc.type = type;
15647 pMacHdr->fc.subType = subType;
15648
15649 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015650 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15651 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015652
15653 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15654
15655 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015656 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15657 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015658 return statusCode;
15659} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15660
15661static tSirRetStatus
15662csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15663 tANI_U8 nChannelNum,
15664 tANI_U32 dot11mode,
15665 tSirMacAddr selfMacAddr,
15666 tANI_U8 *pFrame,
15667 tANI_U16 *pusLen)
15668{
15669 tDot11fProbeRequest pr;
15670 tANI_U32 nStatus, nBytes, nPayload;
15671 tSirRetStatus nSirStatus;
15672 /*Bcast tx*/
15673 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15674 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15675
15676
Kiet Lam64c1b492013-07-12 13:56:44 +053015677 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015678
15679 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15680
15681 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15682 {
15683 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15684 }
15685
15686
15687 if (IS_DOT11_MODE_HT(dot11mode))
15688 {
15689 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15690 }
15691
15692
15693 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15694 if ( DOT11F_FAILED( nStatus ) )
15695 {
15696 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15697 "Failed to calculate the packed size f"
15698 "or a Probe Request (0x%08x).\n", nStatus );
15699
15700
15701 nPayload = sizeof( tDot11fProbeRequest );
15702 }
15703 else if ( DOT11F_WARNED( nStatus ) )
15704 {
15705 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15706 "There were warnings while calculating"
15707 "the packed size for a Probe Request ("
15708 "0x%08x).\n", nStatus );
15709 }
15710
15711 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15712
15713 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015714 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015715
15716
15717 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015718 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015719
15720 if ( eSIR_SUCCESS != nSirStatus )
15721 {
15722 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15723 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15724 nSirStatus );
15725 return nSirStatus;
15726 }
15727
15728
15729 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15730 sizeof( tSirMacMgmtHdr ),
15731 nPayload, &nPayload );
15732 if ( DOT11F_FAILED( nStatus ) )
15733 {
15734 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15735 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15736 return eSIR_FAILURE;
15737 }
15738 else if ( DOT11F_WARNED( nStatus ) )
15739 {
15740 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015741 "There were warnings while packing a Probe Request (0x%08x).\n",
15742 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015743 }
15744
15745 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15746 return eSIR_SUCCESS;
15747}
15748
15749eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15750{
15751 vos_msg_t msg;
15752 tSirRoamOffloadScanReq *pRequestBuf;
15753 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15754 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015755 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015756 tANI_U8 *ChannelList = NULL;
15757 tANI_U32 sessionId;
15758 eHalStatus status = eHAL_STATUS_SUCCESS;
15759 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015760 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015761 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015762 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015763 tSirBssDescription *pBssDesc = NULL;
15764 tDot11fBeaconIEs *pIes = NULL;
15765 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080015766 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015767
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015768 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15769
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015770 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015771 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015772 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015773 return eHAL_STATUS_FAILURE;
15774 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015775
15776 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15777 {
15778 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15779 return eHAL_STATUS_FAILURE;
15780 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015781 status = csrRoamGetSessionIdFromBSSID(pMac,
15782 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15783 &sessionId);
15784 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15785 * It is important to ensure that the command is passed down to the FW only
15786 * if the Infra Station is in a connected state.A connected station could also be
15787 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15788 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15789 * irrespective of whichever state we are in.*/
15790 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15791 (command != ROAM_SCAN_OFFLOAD_STOP))
15792 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053015793 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
15794 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
15795 macTraceGetNeighbourRoamState(
15796 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015797 return eHAL_STATUS_FAILURE;
15798 }
15799
15800 if ( !HAL_STATUS_SUCCESS( status ) )
15801 {
15802 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15803 return eHAL_STATUS_FAILURE;
15804 }
15805 pSession = CSR_GET_SESSION( pMac, sessionId );
krunal soni587bf012014-02-04 12:35:11 -080015806 if (NULL == pSession)
15807 {
15808 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15809 "%s:pSession is null", __func__);
15810 return eHAL_STATUS_FAILURE;
15811 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015812 pBssDesc = pSession->pConnectBssDesc;
15813 if (pBssDesc == NULL)
15814 {
15815 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: pBssDesc not found for current session", __func__);
15816 return eHAL_STATUS_FAILURE;
15817 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015818 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15819 if (NULL == pRequestBuf)
15820 {
15821 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15822 return eHAL_STATUS_FAILED_ALLOC;
15823 }
15824
Kiet Lam64c1b492013-07-12 13:56:44 +053015825 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015826 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15827 * host driver reloads, but Riva still up and running*/
Mukul Sharma90506b42014-04-24 13:24:12 +053015828 pRequestBuf->Command = command;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015829 if(command == ROAM_SCAN_OFFLOAD_STOP)
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015830 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015831 pRequestBuf->RoamScanOffloadEnabled = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015832 /*For a STOP Command, there is no need to
15833 * go through filling up all the below parameters
15834 * since they are not required for the STOP command*/
15835 goto send_roam_scan_offload_cmd;
15836 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015837 else
15838 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015839 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15840 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015841 sizeof(tCsrBssid));
15842 pRequestBuf->ConnectedNetwork.ssId.length =
15843 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15844 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15845 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15846 pRequestBuf->ConnectedNetwork.ssId.length);
15847 pRequestBuf->ConnectedNetwork.authentication =
15848 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15849 pRequestBuf->ConnectedNetwork.encryption =
15850 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15851 pRequestBuf->ConnectedNetwork.mcencryption =
15852 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015853 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
15854 {
15855 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015856 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015857 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15858 }
15859 else
15860 {
15861 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
15862 operationChannel = pSession->connectedProfile.operationChannel;
15863
15864 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
15865 {
15866 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15867 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
15868 vos_mem_free(pRequestBuf);
15869 return eHAL_STATUS_FAILURE;
15870 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053015871 if(NULL == pIes)
15872 {
15873 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15874 "%s : pIes is Null", __func__);
15875 return eHAL_STATUS_FAILURE;
15876 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015877 if (pIes->SuppRates.present)
15878 {
15879 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
15880 /*Check for both basic rates and extended rates.*/
15881 for (i = 0; i < pIes->SuppRates.num_rates; i++)
15882 {
15883 /*Check if the Rate is Mandatory or Not*/
15884 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
15885 && (pIes->SuppRates.rates[i] & 0x80))
15886 {
15887 /*Retrieve the actual data rate*/
15888 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
15889 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15890 if (minRate == 0)
15891 minRate = dataRate;
15892 else
15893 minRate = (minRate < dataRate) ? minRate:dataRate;
15894 }
15895 }
15896
15897 if (pIes->ExtSuppRates.present)
15898 {
15899 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
15900 {
15901 /*Check if the Rate is Mandatory or Not*/
15902 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
15903 && (pIes->ExtSuppRates.rates[i] & 0x80))
15904 {
15905 /*Retrieve the actual data rate*/
15906 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
15907 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15908 if (minRate == 0)
15909 minRate = dataRate;
15910 else
15911 minRate = (minRate < dataRate) ? minRate:dataRate;
15912 }
15913 }
15914 }
15915 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
15916 }
15917 else
15918 {
15919 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15920 "%s: Supp Rates not present in pIes", __func__);
15921 vos_mem_free(pRequestBuf);
15922 return eHAL_STATUS_FAILURE;
15923 }
15924 if (NULL != pIes)
15925 {
15926 vos_mem_free(pIes);
15927 pIes = NULL;
15928 }
15929 switch (minRate)
15930 {
15931 case 1:
15932 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
15933 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
15934 break;
15935 case 2:
15936 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
15937 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
15938 break;
15939 case 5:
15940 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
15941 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
15942 break;
15943 case 6:
15944 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15945 {
15946 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
15947 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
15948 }
15949 else
15950 {
15951 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
15952 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
15953 }
15954 break;
15955 case 11:
15956 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
15957 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
15958 break;
15959 case 12:
15960 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15961 {
15962 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
15963 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
15964 }
15965 else
15966 {
15967 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
15968 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
15969 }
15970 break;
15971 case 24:
15972 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15973 {
15974 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
15975 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
15976 }
15977 else
15978 {
15979 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
15980 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
15981 }
15982 break;
15983 default:
15984 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
15985 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15986 break;
15987 }
15988 }
15989 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15990 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
15991 operationChannel, minRate,
15992 pRequestBuf->RxSensitivityThreshold,
15993 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015994 pRequestBuf->RoamRssiDiff =
15995 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015996 pRequestBuf->StartScanReason = reason;
15997 pRequestBuf->NeighborScanTimerPeriod =
15998 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
15999 pRequestBuf->NeighborRoamScanRefreshPeriod =
16000 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
16001 pRequestBuf->NeighborScanChannelMinTime =
16002 pNeighborRoamInfo->cfgParams.minChannelScanTime;
16003 pRequestBuf->NeighborScanChannelMaxTime =
16004 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
16005 pRequestBuf->EmptyRefreshScanPeriod =
16006 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080016007 /* MAWC feature */
16008 pRequestBuf->MAWCEnabled =
16009 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016010#ifdef FEATURE_WLAN_ESE
16011 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016012#endif
16013 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016014#ifdef FEATURE_WLAN_ESE
16015 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016016 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
16017 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016018 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
16019#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016020 currChannelListInfo->numOfChannels == 0)
16021 {
16022
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016023 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
16024 * Give Preference to INI Channels.*/
16025 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
16026 {
16027 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
16028 /*The INI channels need to be filtered with respect to the current
16029 * band that is supported.*/
16030 eBand = pMac->roam.configParam.bandCapability;
16031 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016032 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016033 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16034 "Invalid band, No operation carried out (Band %d)", eBand);
16035 vos_mem_free(pRequestBuf);
16036 return eHAL_STATUS_FAILURE;
16037 }
16038 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
16039 {
16040 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
16041 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
16042 (eCSR_BAND_ALL == eBand))
16043 {
16044 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
16045 csrRoamIsChannelValid(pMac, *ChannelList) &&
16046 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16047 {
16048 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16049 }
16050 }
16051 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016052 }
16053 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16054 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016055 }
16056 else
16057 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016058 ChannelList = pMac->scan.occupiedChannels.channelList;
16059 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
16060 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016061 /*Allow DFS channels only if the DFS channel roam flag is enabled */
16062 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16063 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016064 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16065 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016066 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016067 }
16068 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016069 }
16070 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16071 /* If the profile changes as to what it was earlier, inform the FW through
16072 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
16073 * for the earlier profile and try to learn them afresh.*/
16074 if (reason == REASON_FLUSH_CHANNEL_LIST)
16075 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16076 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016077 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16078 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16079 else
16080 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016081 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016082 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016083 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016084#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016085 else
16086 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016087 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016088 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016089 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016090 if (currChannelListInfo->numOfChannels != 0)
16091 {
16092 ChannelList = currChannelListInfo->ChannelList;
16093 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016094 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016095 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16096 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016097 {
16098 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16099 }
16100 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016101 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016102 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16103 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16104 }
16105 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016106#endif
Kaushik, Sushant5ed8ab62014-03-05 11:21:11 +053016107 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0])) && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016108 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016109 if (j < sizeof(ChannelCacheStr))
16110 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016111 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16112 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016113 }
16114 else
16115 {
16116 break;
16117 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016118 }
16119 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16120 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16121 pRequestBuf->ChannelCacheType,
16122 pRequestBuf->ConnectedNetwork.ChannelCount,
16123 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016124 num_channels = 0;
16125 ChannelList = NULL;
16126
16127 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016128 host_channels = sizeof(pMac->roam.validChannelList);
16129 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016130 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016131 ChannelList = pMac->roam.validChannelList;
16132 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016133 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016134 else
16135 {
16136 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16137 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016138 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016139 return eHAL_STATUS_FAILURE;
16140 }
16141 for(i=0; i<pMac->roam.numValidChannels; i++)
16142 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016143 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16144 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Srinivas Girigowda56076852013-08-20 14:00:50 -070016145 {
16146 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16147 }
16148 ChannelList++;
16149 }
16150 pRequestBuf->ValidChannelCount = num_channels;
16151
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016152 pRequestBuf->MDID.mdiePresent =
16153 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16154 pRequestBuf->MDID.mobilityDomain =
16155 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016156 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16157
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016158 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016159 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16160 * where RFS is the RF Switching time. It is twice RFS to consider the
16161 * time to go off channel and return to the home channel. */
16162 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16163 {
16164 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16165 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16166 " Hence enforcing home away time to disable (0)",
16167 __func__, pRequestBuf->HomeAwayTime,
16168 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16169 pRequestBuf->HomeAwayTime = 0;
16170 }
16171 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016172
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016173 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16174 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16175 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16176 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16177 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16178
16179 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16180 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016181send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016182 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016183 msg.reserved = 0;
16184 msg.bodyptr = pRequestBuf;
16185 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16186 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016187 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16188 vos_mem_free(pRequestBuf);
16189 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016190 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016191 else
16192 {
16193 if (ROAM_SCAN_OFFLOAD_START == command)
16194 bRoamScanOffloadStarted = VOS_TRUE;
16195 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16196 bRoamScanOffloadStarted = VOS_FALSE;
16197 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016198
16199 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16200 return status;
16201}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016202
16203eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16204{
16205 switch(reason)
16206 {
16207 case 0:
16208 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16209 break;
16210 case REASON_OS_REQUESTED_ROAMING_NOW:
16211 csrNeighborRoamProceedWithHandoffReq(pMac);
16212 break;
16213 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016214 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 -070016215 }
16216 return eHAL_STATUS_SUCCESS;
16217}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016218#endif
16219
Jeff Johnson295189b2012-06-20 16:38:30 -070016220tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16221 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16222{
16223 tANI_BOOLEAN found = FALSE;
16224 eHalStatus status = eHAL_STATUS_SUCCESS;
16225 tCsrPeStatsReqInfo staEntry;
16226 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16227 tListElem *pStaEntry = NULL;
16228 VOS_STATUS vosStatus;
16229 tPmcPowerState powerState;
16230 *pFound = FALSE;
16231
16232 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16233 if(pStaEntry)
16234 {
16235 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16236 if(pTempStaEntry->periodicity)
16237 {
16238 pTempStaEntry->periodicity =
16239 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16240 }
16241 else
16242 {
16243 pTempStaEntry->periodicity = periodicity;
16244 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016245 pTempStaEntry->numClient++;
16246 found = TRUE;
16247 }
16248 else
16249 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016250 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016251 staEntry.numClient = 1;
16252 staEntry.periodicity = periodicity;
16253 staEntry.pMac = pMac;
16254 staEntry.rspPending = FALSE;
16255 staEntry.staId = staId;
16256 staEntry.statsMask = statsMask;
16257 staEntry.timerRunning = FALSE;
16258 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16259 if(!pTempStaEntry)
16260 {
16261 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016262 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016263 return NULL;
16264 }
16265 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016266 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16267 if(ePMC_FULL_POWER == powerState)
16268 {
16269 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16270 {
16271 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16272 }
16273 }
16274 else
16275 {
16276 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16277 {
16278 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16279 }
16280 }
16281 if(!pTempStaEntry->timerRunning)
16282 {
16283 //send down a req in case of one time req, for periodic ones wait for timer to expire
16284 if(!pTempStaEntry->rspPending &&
16285 !pTempStaEntry->periodicity)
16286 {
16287 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16288 if(!HAL_STATUS_SUCCESS(status))
16289 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016290 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016291 }
16292 else
16293 {
16294 pTempStaEntry->rspPending = TRUE;
16295 }
16296 }
16297 if(pTempStaEntry->periodicity)
16298 {
16299 if(!found)
16300 {
16301
16302 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16303 csrRoamPeStatsTimerHandler, pTempStaEntry );
16304 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16305 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016306 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016307 return NULL;
16308 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016309 }
16310 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016311 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016312 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16313 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16314 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016315 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016316 return NULL;
16317 }
16318 pTempStaEntry->timerRunning = TRUE;
16319 }
16320 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016321 *pFound = found;
16322 return pTempStaEntry;
16323}
16324
Jeff Johnson295189b2012-06-20 16:38:30 -070016325/*
16326 pStaEntry is no longer invalid upon the return of this function.
16327*/
16328static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16329{
16330 if(pEntry)
16331 {
16332 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16333 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016334 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016335 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016336 }
16337 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016338
16339void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16340{
16341 tListElem *pEntry;
16342 tCsrPeStatsReqInfo *pTempStaEntry;
16343 VOS_STATUS vosStatus;
16344 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016345 if(!pEntry)
16346 {
16347 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016348 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016349 return;
16350 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016351 while( pEntry )
16352 {
16353 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016354 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16355 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016356 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016357 if(pTempStaEntry->timerRunning)
16358 {
16359 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16360 /* If we are not able to stop the timer here, just remove
16361 * the entry from the linked list. Destroy the timer object
16362 * and free the memory in the timer CB
16363 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016364 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016365 {
16366 /* the timer is successfully stopped */
16367 pTempStaEntry->timerRunning = FALSE;
16368
16369 /* Destroy the timer */
16370 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16371 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16372 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016373 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016374 }
16375 }
16376 else
16377 {
16378 // the timer could not be stopped. Hence destroy and free the
16379 // memory for the PE stat entry in the timer CB.
16380 pTempStaEntry->timerStopFailed = TRUE;
16381 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016382 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016383
16384 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16385 {
16386 // Only free the memory if we could stop the timer successfully
16387 if(!pTempStaEntry->timerStopFailed)
16388 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016389 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016390 pTempStaEntry = NULL;
16391 }
16392 break;
16393 }
16394
16395 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16396 }
16397 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016398 return;
16399}
16400
16401
Jeff Johnsone7245742012-09-05 17:12:55 -070016402void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016403{
16404
Jeff Johnsone7245742012-09-05 17:12:55 -070016405 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16406 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16407 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16408 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16409 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16410 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16411 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016412 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016413 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16414 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16415 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16416 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16417 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16418 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016419 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016420 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16421 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016422
16423}
16424
Jeff Johnson295189b2012-06-20 16:38:30 -070016425void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16426 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16427{
16428 tANI_U8 stats[500];
16429 tANI_U8 *pStats = NULL;
16430 tANI_U32 tempMask = 0;
16431 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016432 if(!callback)
16433 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016434 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016435 return;
16436 }
16437 if(!statsMask)
16438 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016439 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016440 return;
16441 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016442 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016443 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016444 while(tempMask)
16445 {
16446 if(tempMask & 1)
16447 {
16448 //new stats info from PE, fill up the stats strucutres in PMAC
16449 switch(counter)
16450 {
16451 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016452 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016453 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16454 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016455 pStats += sizeof(tCsrSummaryStatsInfo);
16456 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016457 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016458 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016459 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16460 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016461 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016462 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016463 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016464 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016465 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16466 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016467 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016468 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016469 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016470 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016471 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16472 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016473 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016474 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016475 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016476 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016477 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16478 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016479 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016480 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016481 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016482 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016483 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16484 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016485 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016486 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016487 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016488 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016489 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016490 }
16491 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016492 tempMask >>=1;
16493 counter++;
16494 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016495 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016496}
16497
Jeff Johnson295189b2012-06-20 16:38:30 -070016498eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16499{
16500 tListElem *pEntry = NULL;
16501 tListElem *pPrevEntry = NULL;
16502 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16503 eHalStatus status = eHAL_STATUS_SUCCESS;
16504 VOS_STATUS vosStatus;
16505 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016506 if(!pEntry)
16507 {
16508 //list empty
16509 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016510 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016511 return status;
16512 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016513 while( pEntry )
16514 {
16515 if(pPrevEntry)
16516 {
16517 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16518 //send up the stats report
16519 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16520 pTempStaEntry->staId, pTempStaEntry->pContext);
16521 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16522 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016523 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016524 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16525 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016526 pTempStaEntry->pPeStaEntry->numClient--;
16527 //check if we need to delete the entry from peStatsReqList too
16528 if(!pTempStaEntry->pPeStaEntry->numClient)
16529 {
16530 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16531 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016532 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016533 //check if we need to stop the tl stats timer too
16534 pMac->roam.tlStatsReqInfo.numClient--;
16535 if(!pMac->roam.tlStatsReqInfo.numClient)
16536 {
16537 if(pMac->roam.tlStatsReqInfo.timerRunning)
16538 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016539 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16540 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016541 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016542 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016543 //we will continue
16544 }
16545 }
16546 pMac->roam.tlStatsReqInfo.periodicity = 0;
16547 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16548 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016549 if (pTempStaEntry->periodicity)
16550 {
16551 //While creating StaEntry in csrGetStatistics,
16552 //Initializing and starting timer only when periodicity is set.
16553 //So Stop and Destroy timer only when periodicity is set.
16554
Jeff Johnsone7245742012-09-05 17:12:55 -070016555 vos_timer_stop( &pTempStaEntry->timer );
16556 // Destroy the vos timer...
16557 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16558 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16559 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016560 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016561 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016562 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016563
Jeff Johnson295189b2012-06-20 16:38:30 -070016564
16565 pPrevEntry = pEntry;
16566 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16567 }
16568 //the last one
16569 if(pPrevEntry)
16570 {
16571 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16572 //send up the stats report
16573 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16574 pTempStaEntry->staId, pTempStaEntry->pContext);
16575 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16576 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016577 return status;
16578
16579}
16580
Jeff Johnson295189b2012-06-20 16:38:30 -070016581eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16582 tRequestFullPowerReason *pReason,
16583 tANI_BOOLEAN *pfNeedPower )
16584{
16585 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16586 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16587 tPmcState pmcState;
16588 eHalStatus status = eHAL_STATUS_SUCCESS;
16589 // TODO : Session info unavailable
16590 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016591 if( pfNeedPower )
16592 {
16593 *pfNeedPower = eANI_BOOLEAN_FALSE;
16594 }
16595 //We only handle CSR commands
16596 if( !(eSmeCsrCommandMask & pCommand->command) )
16597 {
16598 return eHAL_STATUS_SUCCESS;
16599 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016600 //Check PMC state first
16601 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016602 switch( pmcState )
16603 {
16604 case REQUEST_IMPS:
16605 case IMPS:
16606 if( eSmeCommandScan == pCommand->command )
16607 {
16608 switch( pCommand->u.scanCmd.reason )
16609 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016610#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16611 case eCsrScanGetLfrResult:
16612#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016613 case eCsrScanGetResult:
16614 case eCsrScanBGScanAbort:
16615 case eCsrScanBGScanEnable:
16616 case eCsrScanGetScanChnInfo:
16617 //Internal process, no need for full power
16618 fNeedFullPower = eANI_BOOLEAN_FALSE;
16619 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016620 default:
16621 //Other scans are real scan, ask for power
16622 fNeedFullPower = eANI_BOOLEAN_TRUE;
16623 break;
16624 } //switch
16625 }
16626 else
16627 {
16628 //ask for power for roam and status change
16629 fNeedFullPower = eANI_BOOLEAN_TRUE;
16630 }
16631 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016632 case REQUEST_BMPS:
16633 case BMPS:
16634 case REQUEST_START_UAPSD:
16635 case UAPSD:
16636 //We treat WOWL same as BMPS
16637 case REQUEST_ENTER_WOWL:
16638 case WOWL:
16639 if( eSmeCommandRoam == pCommand->command )
16640 {
16641 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16642 tCsrScanResult *pScanResult;
16643 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016644 switch ( pCommand->u.roamCmd.roamReason )
16645 {
16646 case eCsrForcedDisassoc:
16647 case eCsrForcedDisassocMICFailure:
16648 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16649 fNeedFullPower = eANI_BOOLEAN_TRUE;
16650 break;
16651 case eCsrSmeIssuedDisassocForHandoff:
16652 case eCsrForcedDeauth:
16653 case eCsrHddIssuedReassocToSameAP:
16654 case eCsrSmeIssuedReassocToSameAP:
16655 fNeedFullPower = eANI_BOOLEAN_TRUE;
16656 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016657 case eCsrCapsChange:
16658 fNeedFullPower = eANI_BOOLEAN_TRUE;
16659 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016660 default:
16661 //Check whether the profile is already connected. If so, no need for full power
16662 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16663 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16664 {
16665 //Only need to check the first one
16666 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16667 if( pEntry )
16668 {
16669 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16670#if 0
16671 // TODO : Session Specific info pConnectBssDesc
16672 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16673 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16674 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16675 {
16676 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16677 // with Authenticating first. To force this, stop the current association (Disassociate) and
16678 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16679 // a new Association.
16680 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16681 {
16682 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16683 {
16684 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16685 //No need for full power
16686 //Set the flag so the code later can avoid to do the above
16687 //check again.
16688 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16689 break;
16690 }
16691 }
16692 }
16693#endif
16694 }
16695 }
16696 //If we are here, full power is needed
16697 fNeedFullPower = eANI_BOOLEAN_TRUE;
16698 break;
16699 }
16700 }
16701 else if( eSmeCommandWmStatusChange == pCommand->command )
16702 {
16703 //need full power for all
16704 fNeedFullPower = eANI_BOOLEAN_TRUE;
16705 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16706 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016707#ifdef FEATURE_WLAN_TDLS
16708 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16709 {
16710 //TDLS link is getting established. need full power
16711 fNeedFullPower = eANI_BOOLEAN_TRUE;
16712 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16713 }
16714#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016715 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016716 case REQUEST_STOP_UAPSD:
16717 case REQUEST_EXIT_WOWL:
16718 if( eSmeCommandRoam == pCommand->command )
16719 {
16720 fNeedFullPower = eANI_BOOLEAN_TRUE;
16721 switch ( pCommand->u.roamCmd.roamReason )
16722 {
16723 case eCsrForcedDisassoc:
16724 case eCsrForcedDisassocMICFailure:
16725 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16726 break;
16727 default:
16728 break;
16729 }
16730 }
16731 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016732 case STOPPED:
16733 case REQUEST_STANDBY:
16734 case STANDBY:
16735 case LOW_POWER:
16736 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053016737 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
16738 " stopped/standby state %s (%d)" ),
16739 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016740 status = eHAL_STATUS_FAILURE;
16741 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016742 case FULL_POWER:
16743 case REQUEST_FULL_POWER:
16744 default:
16745 //No need to ask for full power. This has to be FULL_POWER state
16746 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016747 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016748 if( pReason )
16749 {
16750 *pReason = reason;
16751 }
16752 if( pfNeedPower )
16753 {
16754 *pfNeedPower = fNeedFullPower;
16755 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016756 return ( status );
16757}
16758
Jeff Johnson295189b2012-06-20 16:38:30 -070016759static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16760{
16761 eHalStatus status = eHAL_STATUS_SUCCESS;
16762 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16763 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016764 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016765 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16766 {
16767 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16768 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016769 return ( status );
16770}
16771
Jeff Johnson295189b2012-06-20 16:38:30 -070016772tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16773{
16774 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016775 if( pCmd )
16776 {
16777 pMac->roam.sPendingCommands++;
16778 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016779 return ( pCmd );
16780}
16781
Jeff Johnson295189b2012-06-20 16:38:30 -070016782void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16783{
16784 if (pMac->roam.sPendingCommands > 0)
16785 {
16786 //All command allocated through csrGetCommandBuffer need to
16787 //decrement the pending count when releasing.
16788 pMac->roam.sPendingCommands--;
16789 smeReleaseCommand( pMac, pCommand );
16790 }
16791 else
16792 {
16793 smsLog(pMac, LOGE, FL( "no pending commands"));
16794 VOS_ASSERT(0);
16795 }
16796}
16797
Jeff Johnson295189b2012-06-20 16:38:30 -070016798//Return SUCCESS is the command is queued, failed
16799eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16800{
16801 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016802 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16803 {
16804 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16805 pCommand->u.scanCmd.reason);
16806 return eHAL_STATUS_CSR_WRONG_STATE;
16807 }
16808
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016809 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16810 {
16811 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16812 &pCommand->Link, LL_ACCESS_LOCK);
16813 // process the command queue...
16814 smeProcessPendingQueue(pMac);
16815 status = eHAL_STATUS_SUCCESS;
16816 goto end;
16817 }
16818
Jeff Johnson295189b2012-06-20 16:38:30 -070016819 //We can call request full power first before putting the command into pending Q
16820 //because we are holding SME lock at this point.
16821 status = csrRequestFullPower( pMac, pCommand );
16822 if( HAL_STATUS_SUCCESS( status ) )
16823 {
16824 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016825 //make sure roamCmdPendingList is not empty first
16826 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16827 if( fNoCmdPending )
16828 {
16829 smePushCommand( pMac, pCommand, fHighPriority );
16830 }
16831 else
16832 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016833 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016834 //no list lock is needed since SME lock is held
16835 if( !fHighPriority )
16836 {
16837 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16838 }
16839 else {
16840 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16841 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016842 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016843 }
16844 else if( eHAL_STATUS_PMC_PENDING == status )
16845 {
16846 //no list lock is needed since SME lock is held
16847 if( !fHighPriority )
16848 {
16849 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16850 }
16851 else {
16852 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16853 }
16854 //Let caller know the command is queue
16855 status = eHAL_STATUS_SUCCESS;
16856 }
16857 else
16858 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016859 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016860 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016861 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016862 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016863end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016864 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016865}
Jeff Johnson295189b2012-06-20 16:38:30 -070016866eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16867{
16868 eHalStatus status = eHAL_STATUS_SUCCESS;
16869 tSirUpdateAPWPSIEsReq *pMsg;
16870 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16871
16872 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16873 if (NULL == pSession)
16874 {
16875 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16876 return eHAL_STATUS_FAILURE;
16877 }
16878
Jeff Johnson295189b2012-06-20 16:38:30 -070016879 do
16880 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016881 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
16882 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16883 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016884 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
16885
16886 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070016887 VOS_ASSERT(pBuf);
16888
Jeff Johnson295189b2012-06-20 16:38:30 -070016889 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016890 // transactionId
16891 *pBuf = 0;
16892 *( pBuf + 1 ) = 0;
16893 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070016894 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016895 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16896 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016897 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016898 //sessionId
16899 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016900 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016901 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070016902 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070016903 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016904 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016905 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016906 return ( status );
16907}
Jeff Johnson295189b2012-06-20 16:38:30 -070016908eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
16909{
16910 eHalStatus status = eHAL_STATUS_SUCCESS;
16911 tSirUpdateAPWPARSNIEsReq *pMsg;
16912 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016913 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16914 if (NULL == pSession)
16915 {
16916 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16917 return eHAL_STATUS_FAILURE;
16918 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016919 do
16920 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016921 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
16922 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16923 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016924 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016925 pBuf = (tANI_U8 *)&pMsg->transactionId;
16926 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016927 // transactionId
16928 *pBuf = 0;
16929 *( pBuf + 1 ) = 0;
16930 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070016931 VOS_ASSERT(pBuf);
16932
Jeff Johnson295189b2012-06-20 16:38:30 -070016933 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016934 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16935 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016936 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016937 // sessionId
16938 *pBuf++ = (tANI_U8)sessionId;
16939
16940 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016941 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070016942 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070016943 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016944 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016945 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016946 return ( status );
16947}
Jeff Johnson295189b2012-06-20 16:38:30 -070016948
16949#ifdef WLAN_FEATURE_VOWIFI_11R
16950//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
16951eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
16952{
16953 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16954 tpSirFTPreAuthReq pftPreAuthReq;
16955 tANI_U16 auth_req_len = 0;
16956 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016957 auth_req_len = sizeof(tSirFTPreAuthReq);
16958 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053016959 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070016960 {
16961 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
16962 return eHAL_STATUS_RESOURCES;
16963 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016964 // Save the SME Session ID here. We need it while processing the preauth response
16965 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016966 vos_mem_zero(pftPreAuthReq, auth_req_len);
16967
16968 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
16969 sizeof(pBssDescription->length) + pBssDescription->length);
16970
16971 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
16972
16973 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
16974
Kiet Lam64c1b492013-07-12 13:56:44 +053016975 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
16976 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
16977 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
16978 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016979
Jeff Johnson295189b2012-06-20 16:38:30 -070016980#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080016981 if (csrRoamIs11rAssoc(pMac) &&
16982 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070016983 {
16984 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053016985 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
16986 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070016987 }
16988 else
16989#endif
16990 {
16991 pftPreAuthReq->ft_ies_length = 0;
16992 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070016993 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
16994 sizeof(pBssDescription->length) + pBssDescription->length);
16995 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070016996 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
16997}
Jeff Johnson295189b2012-06-20 16:38:30 -070016998/*--------------------------------------------------------------------------
16999 * This will receive and process the FT Pre Auth Rsp from the current
17000 * associated ap.
17001 *
17002 * This will invoke the hdd call back. This is so that hdd can now
17003 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
17004 ------------------------------------------------------------------------*/
17005void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
17006{
17007 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17008 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017009#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017010 tCsrRoamInfo roamInfo;
17011#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017012 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070017013
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017014#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080017015 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017016 if (status != eHAL_STATUS_SUCCESS) {
17017 /*
17018 * Bail out if pre-auth was not even processed.
17019 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017020 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
17021 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017022 return;
17023 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017024#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017025 /* The below function calls/timers should be invoked only if the pre-auth is successful */
17026 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
17027 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070017028 // Implies a success
17029 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017030 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
17031 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070017032 /* No need to notify qos module if this is a non 11r roam*/
17033 if (csrRoamIs11rAssoc(pMac))
17034 {
17035 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
17036 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017037 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
17038 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017039 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
17040 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070017041 if (eHAL_STATUS_SUCCESS != status)
17042 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017043 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017044 return;
17045 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017046 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017047 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
17048 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070017049 if (csrRoamIs11rAssoc(pMac))
17050 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
17051 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
17052
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017053#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17054 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017055 {
17056 /* read TSF */
17057 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
17058
17059 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017060 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017061 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
17062 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017063#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017064#ifdef FEATURE_WLAN_LFR
17065 // If Legacy Fast Roaming is enabled, signal the supplicant
17066 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053017067 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017068 {
17069 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017070 vos_mem_copy((void *)&roamInfo.bssid,
17071 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017072 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
17073 }
17074
17075#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017076
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017077 // If its an Open Auth, FT IEs are not provided by supplicant
17078 // Hence populate them here
17079 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
17080 pMac->ft.ftSmeContext.addMDIE = FALSE;
17081 if( csrRoamIs11rAssoc(pMac) &&
17082 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
17083 {
17084 tANI_U16 ft_ies_length;
17085 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
17086
17087 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
17088 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
17089 {
17090 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
17091 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
17092 }
17093
17094 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
17095 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
17096 {
17097 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
17098 }
17099 else
17100 {
17101 // Copy the RIC IEs to reassoc IEs
17102 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
17103 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
17104 pFTPreAuthRsp->ric_ies_length);
17105 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
17106 pMac->ft.ftSmeContext.addMDIE = TRUE;
17107 }
17108 }
17109
Jeff Johnson295189b2012-06-20 16:38:30 -070017110 // Done with it, init it.
17111 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
17112}
17113#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017114
Jeff Johnson295189b2012-06-20 16:38:30 -070017115#ifdef FEATURE_WLAN_BTAMP_UT_RF
17116void csrRoamJoinRetryTimerHandler(void *pv)
17117{
17118 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
17119 tpAniSirGlobal pMac = pInfo->pMac;
17120 tANI_U32 sessionId = pInfo->sessionId;
17121 tCsrRoamSession *pSession;
17122
17123 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17124 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017125 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017126 pSession = CSR_GET_SESSION( pMac, sessionId );
17127 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
17128 {
17129 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
17130 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017131 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017132 }
17133 }
17134 }
17135}
Jeff Johnson295189b2012-06-20 16:38:30 -070017136eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
17137{
17138 eHalStatus status = eHAL_STATUS_FAILURE;
17139 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17140
17141 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
17142 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017143 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070017144 pSession->maxRetryCount--;
17145 pSession->joinRetryTimerInfo.pMac = pMac;
17146 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017147 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
17148 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017149 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017150 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017151 }
17152 }
17153 else
17154 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017155 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070017156 pSession->maxRetryCount);
17157 }
17158
17159 return (status);
17160}
Jeff Johnson295189b2012-06-20 16:38:30 -070017161eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
17162{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017163 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070017164 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17165 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017166 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070017167 }
17168
17169 return eHAL_STATUS_SUCCESS;
17170}
17171#endif
17172
17173
17174/*
17175 pBuf points to the beginning of the message
17176 LIM packs disassoc rsp as below,
17177 messageType - 2 bytes
17178 messageLength - 2 bytes
17179 sessionId - 1 byte
17180 transactionId - 2 bytes (tANI_U16)
17181 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17182 peerMacAddr - 6 bytes
17183 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17184*/
17185static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17186{
17187 if(pBuf && pRsp)
17188 {
17189 pBuf += 4; //skip type and length
17190 pRsp->sessionId = *pBuf++;
17191 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17192 pBuf += 2;
17193 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17194 pBuf += 4;
17195 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17196 }
17197}
17198
Jeff Johnsond13512a2012-07-17 11:42:19 -070017199eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17200{
17201 static uNvTables nvTables;
17202 eHalStatus status = eHAL_STATUS_SUCCESS;
17203 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17204
17205 /* read the country code from NV and use it */
17206 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17207 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017208 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17209 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017210 return status;
17211 }
17212 else
17213 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017214 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017215 status = eHAL_STATUS_FAILURE;
17216 return status;
17217 }
17218}
17219
17220eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17221{
Kiet Lam64c1b492013-07-12 13:56:44 +053017222 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017223 return eHAL_STATUS_SUCCESS;
17224}
schang86c22c42013-03-13 18:41:24 -070017225
17226eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17227{
17228 tSirSetTxPowerReq *pMsg = NULL;
17229 eHalStatus status = eHAL_STATUS_SUCCESS;
17230 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17231
17232 if (!pSession)
17233 {
17234 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17235 return eHAL_STATUS_FAILURE;
17236 }
17237
Kiet Lam64c1b492013-07-12 13:56:44 +053017238 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17239 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17240 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17241 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17242 pMsg->length = sizeof(tSirSetTxPowerReq);
17243 pMsg->mwPower = mW;
17244 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17245 sizeof(tSirMacAddr));
17246 status = palSendMBMessage(pMac->hHdd, pMsg);
17247 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017248 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017249 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17250 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017251 }
17252 return status;
17253}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017254
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017255eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17256{
17257 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17258 eHalStatus status = eHAL_STATUS_SUCCESS;
17259 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17260
17261 if (!pSession)
17262 {
17263 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17264 return eHAL_STATUS_FAILURE;
17265 }
17266 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17267 {
17268 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053017269
17270 if( NULL == pMsg )
17271 {
17272 smsLog(pMac, LOGE, FL("PMsg is NULL "));
17273 return eHAL_STATUS_FAILURE;
17274 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017275 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17276 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17277 pMsg->length = sizeof(tANI_U8);
17278 pMsg->seesionId = sessionId;
17279 status = palSendMBMessage(pMac->hHdd, pMsg);
17280 if (!HAL_STATUS_SUCCESS(status))
17281 {
17282 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17283 //pMsg is freed by palSendMBMessage
17284 }
17285 }
17286 else
17287 {
17288 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17289 status = eHAL_STATUS_FAILURE;
17290 }
17291 return status;
17292}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017293/* Returns whether a session is in VOS_STA_MODE...or not */
17294tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17295{
17296 tCsrRoamSession *pSession = NULL;
17297 pSession = CSR_GET_SESSION ( pMac, sessionId );
17298 if(!pSession)
17299 {
17300 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17301 return eANI_BOOLEAN_FALSE;
17302 }
17303 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17304 {
17305 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17306 return eANI_BOOLEAN_FALSE;
17307 }
17308 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17309 {
17310 return eANI_BOOLEAN_FALSE;
17311 }
17312 /* There is a possibility that the above check may fail,because
17313 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17314 * when it is connected.So,we may sneak through the above check even
17315 * if we are not a STA mode INFRA station. So, if we sneak through
17316 * the above condition, we can use the following check if we are
17317 * really in STA Mode.*/
17318
17319 if ( NULL != pSession->pCurRoamProfile )
17320 {
17321 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17322 {
17323 return eANI_BOOLEAN_TRUE;
17324 } else {
17325 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17326 return eANI_BOOLEAN_FALSE;
17327 }
17328 }
17329
17330 return eANI_BOOLEAN_FALSE;
17331}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017332
17333#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17334eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17335 tCsrHandoffRequest *pHandoffInfo)
17336{
17337 eHalStatus status = eHAL_STATUS_SUCCESS;
17338 vos_msg_t msg;
17339
17340 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017341 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17342 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017343 {
17344 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017345 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017346 }
17347 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17348 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17349 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17350 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017351 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017352 pHandoffInfo->bssid,
17353 6);
17354 msg.type = eWNI_SME_HANDOFF_REQ;
17355 msg.bodyptr = pMsg;
17356 msg.reserved = 0;
17357 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17358 {
17359 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017360 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017361 status = eHAL_STATUS_FAILURE;
17362 }
17363 return status;
17364}
17365#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017366
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017367
17368#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017369/* ---------------------------------------------------------------------------
17370 \fn csrSetCCKMIe
17371 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17372 data structure and this IE will be packed inside reassociation request
17373 \param pMac - pMac global structure
17374 \param sessionId - Current session id
17375 \param pCckmIe - pointer to CCKM IE data
17376 \param ccKmIeLen - length of the CCKM IE
17377 \- return Success or failure
17378 -------------------------------------------------------------------------*/
17379VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17380 const tANI_U8 *pCckmIe,
17381 const tANI_U8 ccKmIeLen)
17382{
17383 eHalStatus status = eHAL_STATUS_SUCCESS;
17384 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17385
17386 if (!pSession)
17387 {
17388 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17389 return eHAL_STATUS_FAILURE;
17390 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017391 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017392 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17393 return status;
17394}
17395
17396/* ---------------------------------------------------------------------------
17397 \fn csrRoamReadTSF
17398 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17399 probe response reception from the hand off AP to arrive at the latest TSF value.
17400 \param pMac - pMac global structure
17401 \param pTimestamp - output TSF timestamp
17402 \- return Success or failure
17403 -------------------------------------------------------------------------*/
17404VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17405{
17406 eHalStatus status = eHAL_STATUS_SUCCESS;
17407 tCsrNeighborRoamBSSInfo handoffNode;
17408 tANI_U32 timer_diff = 0;
17409 tANI_U32 timeStamp[2];
17410 tpSirBssDescription pBssDescription = NULL;
17411
17412 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17413 pBssDescription = handoffNode.pBssDescription;
17414
17415 // Get the time diff in milli seconds
17416 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17417 // Convert msec to micro sec timer
17418 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17419
17420 timeStamp[0] = pBssDescription->timeStamp[0];
17421 timeStamp[1] = pBssDescription->timeStamp[1];
17422
17423 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17424
Kiet Lamf2f201e2013-11-16 21:24:16 +053017425 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017426 sizeof (tANI_U32) * 2);
17427 return status;
17428}
17429
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017430#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017431