blob: d5baea860f26253c2318a08682104cd88af4d7e3 [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 */
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053076#ifdef DEBUG_ROAM_DELAY
77#include "vos_utils.h"
78#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070079#define CSR_NUM_IBSS_START_CHANNELS_50 4
80#define CSR_NUM_IBSS_START_CHANNELS_24 3
81#define CSR_DEF_IBSS_START_CHANNEL_50 36
82#define CSR_DEF_IBSS_START_CHANNEL_24 1
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080083#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 -070084#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
85/*---------------------------------------------------------------------------
86 OBIWAN recommends [8 10]% : pick 9%
87---------------------------------------------------------------------------*/
88#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070089/*---------------------------------------------------------------------------
90 OBIWAN recommends -85dBm
91---------------------------------------------------------------------------*/
92#define CSR_VCC_RSSI_THRESHOLD 80
93#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
94#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
95#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
96#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -070097//We use constatnt 4 here
98//This macro returns true when higher AC parameter is bigger than lower AC for a difference
99//The bigger the number, the less chance of TX
100//It must put lower AC as the first parameter.
101#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700102//Flag to send/do not send disassoc frame over the air
103#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700104#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700105#define MAX_CB_VALUE_IN_INI (2)
106
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700107#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
108static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
109#endif
110
Jeff Johnson295189b2012-06-20 16:38:30 -0700111/*--------------------------------------------------------------------------
112 Static Type declarations
113 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800114static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800115
Jeff Johnson295189b2012-06-20 16:38:30 -0700116/*--------------------------------------------------------------------------
117 Type declarations
118 ------------------------------------------------------------------------*/
119#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700120int diagAuthTypeFromCSRType(eCsrAuthType authType)
121{
122 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700123 switch(authType)
124 {
125 case eCSR_AUTH_TYPE_SHARED_KEY:
126 n = AUTH_SHARED;
127 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700128 case eCSR_AUTH_TYPE_WPA:
129 n = AUTH_WPA_EAP;
130 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700131 case eCSR_AUTH_TYPE_WPA_PSK:
132 n = AUTH_WPA_PSK;
133 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700134 case eCSR_AUTH_TYPE_RSN:
135 n = AUTH_WPA2_EAP;
136 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700137 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700138#ifdef WLAN_FEATURE_11W
139 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
140#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700141 n = AUTH_WPA2_PSK;
142 break;
143#ifdef FEATURE_WLAN_WAPI
144 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
145 n = AUTH_WAPI_CERT;
146 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700147 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
148 n = AUTH_WAPI_PSK;
149 break;
150#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 default:
152 break;
153 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700154 return (n);
155}
Jeff Johnson295189b2012-06-20 16:38:30 -0700156int diagEncTypeFromCSRType(eCsrEncryptionType encType)
157{
158 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 switch(encType)
160 {
161 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
162 case eCSR_ENCRYPT_TYPE_WEP40:
163 n = ENC_MODE_WEP40;
164 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700165 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
166 case eCSR_ENCRYPT_TYPE_WEP104:
167 n = ENC_MODE_WEP104;
168 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 case eCSR_ENCRYPT_TYPE_TKIP:
170 n = ENC_MODE_TKIP;
171 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700172 case eCSR_ENCRYPT_TYPE_AES:
173 n = ENC_MODE_AES;
174 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700175#ifdef FEATURE_WLAN_WAPI
176 case eCSR_ENCRYPT_TYPE_WPI:
177 n = ENC_MODE_SMS4;
178 break;
179#endif /* FEATURE_WLAN_WAPI */
180 default:
181 break;
182 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700183 return (n);
184}
Jeff Johnson295189b2012-06-20 16:38:30 -0700185#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700186static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
187static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700188static void initConfigParam(tpAniSirGlobal pMac);
189static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
190 eCsrRoamCompleteResult Result, void *Context );
191static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
192 tCsrRoamProfile *pProfile,
193 tANI_BOOLEAN *pfSameIbss );
194static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
195static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700196 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
197static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700198eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
199static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
200eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
201eHalStatus csrRoamClose(tpAniSirGlobal pMac);
202void csrRoamMICErrorTimerHandler(void *pv);
203void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
204tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
205
206static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
207static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
208static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700209eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
210eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
211static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700212static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700213static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700214static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
215eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
216 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
217 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
218 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
219 tANI_U8 *pKeyRsc );
220static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
221 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
222 tCsrRoamProfile *pProfile );
223void csrRoamStatisticsTimerHandler(void *pv);
224void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700225static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
226VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
227 v_U8_t rssiNotification,
228 void * context);
229static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
230void csrRoamVccTrigger(tpAniSirGlobal pMac);
231eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
232/*
233 pStaEntry is no longer invalid upon the return of this function.
234*/
235static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700236static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700237static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700238tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
239 tDblLinkList *pStaList,
240 tCsrStatsClientReqInfo *pStaEntry);
241void csrRoamStatsClientTimerHandler(void *pv);
242tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
243 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
244void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
245 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700246void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700247void csrRoamTlStatsTimerHandler(void *pv);
248void csrRoamPeStatsTimerHandler(void *pv);
249tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
250void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
251tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
252eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
253static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
254static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
255static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
256static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
257 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
258//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
259static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
260void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
261#ifdef FEATURE_WLAN_BTAMP_UT_RF
262void csrRoamJoinRetryTimerHandler(void *pv);
263#endif
264extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700265extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700266static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700267void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700268
269//Initialize global variables
270static void csrRoamInitGlobals(tpAniSirGlobal pMac)
271{
272 if(pMac)
273 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800274 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
275 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700276 }
277 return;
278}
279
Jeff Johnson295189b2012-06-20 16:38:30 -0700280static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
281{
282 if(pMac)
283 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800284 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700285 }
286 return;
287}
Jeff Johnson295189b2012-06-20 16:38:30 -0700288eHalStatus csrOpen(tpAniSirGlobal pMac)
289{
290 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530291#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700292 static uNvTables nvTables;
293 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700294 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530295#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700296 tANI_U32 i;
297
298 do
299 {
300 /* Initialize CSR Roam Globals */
301 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700302 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
303 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
304
305 initConfigParam(pMac);
306 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
307 break;
308 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
309 break;
310 pMac->roam.nextRoamId = 1; //Must not be 0
311 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
312 break;
313 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
314 break;
315 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
316 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530317
318#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700319 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
320 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
321 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530322 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
323 WNI_CFG_COUNTRY_CODE_LEN);
324 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700325 }
326 else
327 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800328 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 //hardcoded for now
330 pMac->scan.countryCodeDefault[0] = 'U';
331 pMac->scan.countryCodeDefault[1] = 'S';
332 pMac->scan.countryCodeDefault[2] = 'I';
333 //status = eHAL_STATUS_SUCCESS;
334 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700335 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530336
337 if (!('0' == pMac->scan.countryCodeDefault[0] &&
338 '0' == pMac->scan.countryCodeDefault[1]))
339 {
340 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
341 &regId, COUNTRY_NV);
342 }
343 else
344 {
345 regId = REGDOMAIN_WORLD;
346 }
Abhishek Singha306a442013-11-07 18:39:01 +0530347 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700348 pMac->scan.domainIdDefault = regId;
349 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530350 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
351 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530353#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700354 }while(0);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530355
Jeff Johnson295189b2012-06-20 16:38:30 -0700356 return (status);
357}
358
Mihir Shetee1093ba2014-01-21 20:13:32 +0530359/* --------------------------------------------------------------------------
360 \fn csrInitChannels
361 \brief This function must be called to initialize CSR channel lists
362 \return eHalStatus
363 ----------------------------------------------------------------------------*/
364eHalStatus csrInitChannels(tpAniSirGlobal pMac)
365{
366 eHalStatus status = eHAL_STATUS_SUCCESS;
367 static uNvTables nvTables;
368 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530369 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530370
371 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
372 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
373 {
374 vos_mem_copy(pMac->scan.countryCodeDefault,
375 nvTables.defaultCountryTable.countryCode,
376 WNI_CFG_COUNTRY_CODE_LEN);
377 }
378 else
379 {
380 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
381 //hardcoded for now
382 pMac->scan.countryCodeDefault[0] = 'U';
383 pMac->scan.countryCodeDefault[1] = 'S';
384 pMac->scan.countryCodeDefault[2] = 'I';
385 }
386 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
387
Mihir Shetee1093ba2014-01-21 20:13:32 +0530388 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
389 pMac->scan.domainIdDefault = regId;
390 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
391 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
392 WNI_CFG_COUNTRY_CODE_LEN);
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530393 vos_mem_copy(pMac->scan.countryCodeElected, pMac->scan.countryCodeDefault,
394 WNI_CFG_COUNTRY_CODE_LEN);
Agarwal Ashishcd9b8e62014-07-21 19:48:24 +0530395 vos_mem_copy(pMac->scan.countryCode11d, pMac->scan.countryCodeDefault,
396 WNI_CFG_COUNTRY_CODE_LEN);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530397 status = csrInitGetChannels( pMac );
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530398 csrClearVotesForCountryInfo(pMac);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530399
400 return status;
401}
402
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530403eHalStatus csrInitChannelsForCC(tpAniSirGlobal pMac)
404{
405 eHalStatus status = eHAL_STATUS_SUCCESS;
406 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
407
408 if (!('0' == pMac->scan.countryCodeDefault[0] &&
409 '0' == pMac->scan.countryCodeDefault[1]))
410 {
411 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
412 &regId, COUNTRY_NV);
413
414 }
415 else
416 {
417 return status;
418 }
419 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
420 pMac->scan.domainIdDefault = regId;
421 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
422 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
423 WNI_CFG_COUNTRY_CODE_LEN);
424 status = csrInitGetChannels( pMac );
425 return status;
426}
427
Jeff Johnson295189b2012-06-20 16:38:30 -0700428eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
429{
430 eHalStatus status = eHAL_STATUS_SUCCESS;
431 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
432 v_REGDOMAIN_t regId;
433 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700434 if(NULL == apCntryCode)
435 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530436 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700437 return eHAL_STATUS_FAILURE;
438 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530439 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700440 /* To get correct Regulatory domain from NV table
441 * 2 character Country code should be used
442 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700443 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
444/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700445 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700446
447 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
448 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800449 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700450 return eHAL_STATUS_FAILURE;
451 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700452*/
Kiet Lam6c583332013-10-14 05:37:09 +0530453 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
454 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 if (status != eHAL_STATUS_SUCCESS)
456 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700457 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700458 return status;
459 }
Abhishek Singha306a442013-11-07 18:39:01 +0530460 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700461 if (status != eHAL_STATUS_SUCCESS)
462 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700463 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700464 return status;
465 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700466 pMac->scan.domainIdDefault = regId;
467 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530469 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
470
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530472 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
473
Jeff Johnson295189b2012-06-20 16:38:30 -0700474 /* If 2 bytes country code, 3rd byte must be filled with space */
475 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
476 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530477 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530479 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
480 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700482 return status;
483}
Jeff Johnson295189b2012-06-20 16:38:30 -0700484eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
485{
486 eHalStatus status = eHAL_STATUS_SUCCESS;
487 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
488 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530489 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
490 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700491 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
492 {
493 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
494 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
495 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
496 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
497 }
498 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
499
500 return status;
501}
Jeff Johnson295189b2012-06-20 16:38:30 -0700502eHalStatus csrClose(tpAniSirGlobal pMac)
503{
504 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800505
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 csrRoamClose(pMac);
507 csrScanClose(pMac);
508 csrLLClose(&pMac->roam.statsClientReqList);
509 csrLLClose(&pMac->roam.peStatsReqList);
510 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700511 /* DeInit Globals */
512 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 return (status);
514}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530515
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800516eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530517{
518 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800519 tCsrScanStruct *pScan = &pMac->scan;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530520 tANI_U8 numChan = pScan->base20MHzChannels.numChannels;
521 tANI_U32 bufLen = sizeof(tSirUpdateChanList) +
522 (sizeof(tSirUpdateChanParam) * (numChan - 1));
523 vos_msg_t msg;
524 tANI_U8 i;
525
526 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
527 if (!pChanList)
528 {
529 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
530 "Failed to allocate memory for tSirUpdateChanList");
531 return eHAL_STATUS_FAILED_ALLOC;
532 }
533
534 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
535 msg.reserved = 0;
536 msg.bodyptr = pChanList;
537 pChanList->numChan = numChan;
538 for (i = 0; i < pChanList->numChan; i++)
539 {
540 pChanList->chanParam[i].chanId = pScan->defaultPowerTable[i].chanId;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800541 pChanList->chanParam[i].pwr = cfgGetRegulatoryMaxTransmitPower(pMac,
542 pScan->defaultPowerTable[i].chanId);
543 if (vos_nv_getChannelEnabledState(pChanList->chanParam[i].chanId) ==
544 NV_CHANNEL_DFS)
545 pChanList->chanParam[i].dfsSet = VOS_TRUE;
546 else
547 pChanList->chanParam[i].dfsSet = VOS_FALSE;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530548 }
549
550 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
551 {
552 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
553 "%s: Failed to post msg to WDA", __func__);
554 vos_mem_free(pChanList);
555 return eHAL_STATUS_FAILURE;
556 }
557
558 return eHAL_STATUS_SUCCESS;
559}
560
Jeff Johnson295189b2012-06-20 16:38:30 -0700561eHalStatus csrStart(tpAniSirGlobal pMac)
562{
563 eHalStatus status = eHAL_STATUS_SUCCESS;
564 tANI_U32 i;
565
566 do
567 {
568 //save the global vos context
569 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
570 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
571 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
572
573 status = csrRoamStart(pMac);
574 if(!HAL_STATUS_SUCCESS(status)) break;
575 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
576 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
577 if(!HAL_STATUS_SUCCESS(status)) break;
578 pMac->roam.sPendingCommands = 0;
579 csrScanEnable(pMac);
580#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
581 status = csrNeighborRoamInit(pMac);
582#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
583 pMac->roam.tlStatsReqInfo.numClient = 0;
584 pMac->roam.tlStatsReqInfo.periodicity = 0;
585 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
586 //init the link quality indication also
587 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
588 if(!HAL_STATUS_SUCCESS(status))
589 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800590 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 break;
592 }
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800593#ifdef QCA_WIFI_2_0
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530594 if (pMac->fScanOffload)
595 {
596 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
597 "Scan offload is enabled, update default chan list");
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800598 status = csrUpdateChannelList(pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530599 }
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800600#else
601 status = csrUpdateChannelList(pMac);
602#endif
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530603
Jeff Johnson295189b2012-06-20 16:38:30 -0700604 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700605#if defined(ANI_LOGDUMP)
606 csrDumpInit(pMac);
607#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 return (status);
609}
610
Kiet Lama72a2322013-11-15 11:18:11 +0530611eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700612{
613 tANI_U32 sessionId;
614 tANI_U32 i;
615
616 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
617 {
618 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
619 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700620 csrScanDisable(pMac);
621 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
622 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700623 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
624
625#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
626 csrNeighborRoamClose(pMac);
627#endif
628 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 // deregister from PMC since we register during csrStart()
630 // (ignore status since there is nothing we can do if it fails)
631 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 //Reset the domain back to the deault
633 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800634 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700635
636 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
637 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530638 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
640 }
641
Kiet Lama72a2322013-11-15 11:18:11 +0530642#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
643 /* When HAL resets all the context information
644 * in HAL is lost, so we might need to send the
645 * scan offload request again when it comes
646 * out of reset for scan offload to be functional
647 */
648 if (HAL_STOP_TYPE_SYS_RESET == stopType)
649 {
650 bRoamScanOffloadStarted = VOS_FALSE;
651 }
652#endif
653
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 return (eHAL_STATUS_SUCCESS);
655}
656
Jeff Johnson295189b2012-06-20 16:38:30 -0700657eHalStatus csrReady(tpAniSirGlobal pMac)
658{
659 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 csrScanGetSupportedChannels( pMac );
661 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
662 //use it to init the background scan list
663 csrInitBGScanChannelList(pMac);
664 /* HDD issues the init scan */
665 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800666 /* If the gScanAgingTime is set to '0' then scan results aging timeout
667 based on timer feature is not enabled*/
668 if(0 != pMac->scan.scanResultCfgAgingTime )
669 {
670 csrScanStartResultCfgAgingTimer(pMac);
671 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700672 //Store the AC weights in TL for later use
673 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700674 status = csrInitChannelList( pMac );
675 if ( ! HAL_STATUS_SUCCESS( status ) )
676 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800677 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700678 status );
679 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 return (status);
681}
Jeff Johnson295189b2012-06-20 16:38:30 -0700682void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
683{
684 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700685 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
686 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
687}
Jeff Johnson295189b2012-06-20 16:38:30 -0700688void csrSetGlobalCfgs( tpAniSirGlobal pMac )
689{
Jeff Johnsone7245742012-09-05 17:12:55 -0700690
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
692 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
693 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
694 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
695 NULL, eANI_BOOLEAN_FALSE);
696 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700697 /* 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
698 * Once session is established we will use the session related params stored in PE session for CB mode
699 */
700 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700701 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
702
703 //Update the operating mode to configured value during initialization,
704 //So that client can advertise full capabilities in Probe request frame.
705 csrSetDefaultDot11Mode( pMac );
706}
707
Jeff Johnson295189b2012-06-20 16:38:30 -0700708eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
709{
710 eHalStatus status = eHAL_STATUS_SUCCESS;
711 tANI_U32 i;
712 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 do
714 {
715 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
716 {
717 pSession = CSR_GET_SESSION( pMac, i );
718 pSession->roamingTimerInfo.pMac = pMac;
719 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
720 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
722 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530723 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
724 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700725 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530726 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700727 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800728 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 break;
730 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530731 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
732 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
733 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800735 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700736 return eHAL_STATUS_FAILURE;
737 }
738 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 return (status);
740}
741
Jeff Johnson295189b2012-06-20 16:38:30 -0700742eHalStatus csrRoamClose(tpAniSirGlobal pMac)
743{
744 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
746 {
747 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
748 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530749 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
750 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
751 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
752 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700753 return (eHAL_STATUS_SUCCESS);
754}
755
Jeff Johnson295189b2012-06-20 16:38:30 -0700756eHalStatus csrRoamStart(tpAniSirGlobal pMac)
757{
758 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 return (eHAL_STATUS_SUCCESS);
760}
761
Jeff Johnson295189b2012-06-20 16:38:30 -0700762void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
763{
764 csrRoamStopRoamingTimer(pMac, sessionId);
765 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
766 csrRoamDeregStatisticsReq(pMac);
767}
Jeff Johnson295189b2012-06-20 16:38:30 -0700768eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
769{
770 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800771 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 {
773 status = eHAL_STATUS_SUCCESS;
774 *pState = pMac->roam.roamSession[sessionId].connectState;
775 }
776 return (status);
777}
778
Jeff Johnson295189b2012-06-20 16:38:30 -0700779eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
780{
781 eHalStatus status = eHAL_STATUS_FAILURE;
782 tANI_U32 size = 0;
783 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700784
785 if(!pSession)
786 {
787 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
788 return eHAL_STATUS_FAILURE;
789 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700790
791 if(pProfile)
792 {
793 if(pSession->pConnectBssDesc)
794 {
795 do
796 {
797 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
798 if(size)
799 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530800 pProfile->pBssDesc = vos_mem_malloc(size);
801 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700802 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530803 vos_mem_copy(pProfile->pBssDesc,
804 pSession->pConnectBssDesc, size);
805 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 }
807 else
808 break;
809 }
810 else
811 {
812 pProfile->pBssDesc = NULL;
813 }
814 pProfile->AuthType = pSession->connectedProfile.AuthType;
815 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
816 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
817 pProfile->BSSType = pSession->connectedProfile.BSSType;
818 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
819 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530820 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
821 sizeof(tCsrBssid));
822 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
823 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700824#ifdef WLAN_FEATURE_VOWIFI_11R
825 if (pSession->connectedProfile.MDID.mdiePresent)
826 {
827 pProfile->MDID.mdiePresent = 1;
828 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
829 }
830 else
831 {
832 pProfile->MDID.mdiePresent = 0;
833 pProfile->MDID.mobilityDomain = 0;
834 }
835#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800836#ifdef FEATURE_WLAN_ESE
837 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
838 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800840 vos_mem_copy (pProfile->eseCckmInfo.krk,
841 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530842 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800843 pProfile->eseCckmInfo.reassoc_req_num=
844 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
845 pProfile->eseCckmInfo.krk_plumbed =
846 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 }
848#endif
849 }while(0);
850 }
851 }
852
853 return (status);
854}
855
Jeff Johnson295189b2012-06-20 16:38:30 -0700856eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
857{
858 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700859
860 if((csrIsConnStateConnected(pMac, sessionId)) ||
861 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700862 {
863 if(pProfile)
864 {
865 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
866 }
867 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 return (status);
869}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700870
Jeff Johnson295189b2012-06-20 16:38:30 -0700871eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
872{
873 eHalStatus status = eHAL_STATUS_SUCCESS;
874
Kiet Lam64c1b492013-07-12 13:56:44 +0530875 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530877 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700878 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530879 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700880 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530881 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700882 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530883 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
884
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
886 return (status);
887}
888
Jeff Johnson295189b2012-06-20 16:38:30 -0700889static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
890{
891 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700892 if( pConnectedInfo->pbFrames )
893 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530894 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 pConnectedInfo->pbFrames = NULL;
896 }
897 pConnectedInfo->nBeaconLength = 0;
898 pConnectedInfo->nAssocReqLength = 0;
899 pConnectedInfo->nAssocRspLength = 0;
900 pConnectedInfo->staId = 0;
901#ifdef WLAN_FEATURE_VOWIFI_11R
902 pConnectedInfo->nRICRspLength = 0;
903#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800904#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 pConnectedInfo->nTspecIeLength = 0;
906#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 return ( status );
908}
909
Jeff Johnson295189b2012-06-20 16:38:30 -0700910
911
Jeff Johnsone7245742012-09-05 17:12:55 -0700912
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700913void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
914{
915 csrReinitPreauthCmd(pMac, pCommand);
916 csrReleaseCommand( pMac, pCommand );
917}
918
Jeff Johnson295189b2012-06-20 16:38:30 -0700919void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
920{
921 csrReinitRoamCmd(pMac, pCommand);
922 csrReleaseCommand( pMac, pCommand );
923}
924
Jeff Johnson295189b2012-06-20 16:38:30 -0700925void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
926{
927 csrReinitScanCmd(pMac, pCommand);
928 csrReleaseCommand( pMac, pCommand );
929}
930
Jeff Johnson295189b2012-06-20 16:38:30 -0700931void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
932{
933 csrReinitWmStatusChangeCmd(pMac, pCommand);
934 csrReleaseCommand( pMac, pCommand );
935}
936
Jeff Johnson295189b2012-06-20 16:38:30 -0700937void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
938{
Kiet Lam64c1b492013-07-12 13:56:44 +0530939 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700940}
941
Jeff Johnson295189b2012-06-20 16:38:30 -0700942void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
943{
Kiet Lam64c1b492013-07-12 13:56:44 +0530944 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700945}
946
Jeff Johnson295189b2012-06-20 16:38:30 -0700947void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
948{
949 csrReinitSetKeyCmd(pMac, pCommand);
950 csrReleaseCommand( pMac, pCommand );
951}
Jeff Johnson295189b2012-06-20 16:38:30 -0700952void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
953{
954 csrReinitRemoveKeyCmd(pMac, pCommand);
955 csrReleaseCommand( pMac, pCommand );
956}
Jeff Johnson295189b2012-06-20 16:38:30 -0700957void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
958{
959
960 if( eSmeCsrCommandMask & pCommand->command )
961 {
962 switch (pCommand->command)
963 {
964 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800965 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -0800966 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
967 __func__, pCommand->u.scanCmd.reason,
968 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 if (NULL != pCommand->u.scanCmd.callback)
970 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800971 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
973 }
974 csrReleaseCommandScan( pMac, pCommand );
975 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700976 case eSmeCommandRoam:
977 csrReleaseCommandRoam( pMac, pCommand );
978 break;
979
980 case eSmeCommandWmStatusChange:
981 csrReleaseCommandWmStatusChange( pMac, pCommand );
982 break;
983
984 case eSmeCommandSetKey:
985 csrReleaseCommandSetKey( pMac, pCommand );
986 break;
987
988 case eSmeCommandRemoveKey:
989 csrReleaseCommandRemoveKey( pMac, pCommand );
990 break;
991
992 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800993 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700994 csrReleaseCommand( pMac, pCommand );
995 break;
996 }
997 }
998}
999
Jeff Johnson295189b2012-06-20 16:38:30 -07001000void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
1001{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301002 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1003 macTraceGetcsrRoamSubState(NewSubstate),
1004 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001005
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1007 {
1008 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001009 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 pMac->roam.curSubState[sessionId] = NewSubstate;
1011}
1012
Jeff Johnson295189b2012-06-20 16:38:30 -07001013eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1014{
1015 eCsrRoamState PreviousState;
1016
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301017 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1018 macTraceGetcsrRoamState(NewRoamState),
1019 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001020
1021 PreviousState = pMac->roam.curState[sessionId];
1022
1023 if ( NewRoamState != pMac->roam.curState[sessionId] )
1024 {
1025 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1026 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1027 {
1028 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1029 }
1030
1031 pMac->roam.curState[sessionId] = NewRoamState;
1032 }
1033 return( PreviousState );
1034}
1035
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001036void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001037{
1038 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 if(catOffset)
1040 {
1041 pMac->roam.configParam.bCatRssiOffset = catOffset;
1042 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1043 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001044 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 -07001045 }
1046 }
1047}
1048
Jeff Johnson295189b2012-06-20 16:38:30 -07001049static void initConfigParam(tpAniSirGlobal pMac)
1050{
1051 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001052 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301053 pMac->roam.configParam.channelBondingMode24GHz =
1054 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1055 pMac->roam.configParam.channelBondingMode5GHz =
1056 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001057 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1058 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1059 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1060 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1061 pMac->roam.configParam.HeartbeatThresh24 = 40;
1062 pMac->roam.configParam.HeartbeatThresh50 = 40;
1063 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1064 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1065 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001066 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001067 pMac->roam.configParam.RTSThreshold = 2346;
1068 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1069 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1070 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1071 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1072 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1073 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1074 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1075 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1076 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1077 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1078 {
1079 pMac->roam.configParam.BssPreferValue[i] = i;
1080 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001081 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1083 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1084 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1086 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
1087 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1088 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1089 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1090 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001091 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1092 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001093 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001094#ifdef WLAN_AP_STA_CONCURRENCY
1095 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1096 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1097 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1098 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1099 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001100 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1101 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001102#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1104 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1105 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1106 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001107#ifdef WLAN_FEATURE_VOWIFI_11R
1108 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1109#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001110#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1111 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1112 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1113 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1114 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1115 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1116 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1117 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1118 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1119 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1120 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1121 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001122 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001123#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001124#ifdef WLAN_FEATURE_11AC
1125 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1126#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001127
1128 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1129 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001130
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001131 //Remove this code once SLM_Sessionization is supported
1132 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001133 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001134
Jeff Johnsone7245742012-09-05 17:12:55 -07001135}
Jeff Johnson295189b2012-06-20 16:38:30 -07001136eCsrBand csrGetCurrentBand(tHalHandle hHal)
1137{
1138 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1139 return pMac->roam.configParam.bandCapability;
1140}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001141
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001142
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001143#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001144/*
1145 This function flushes the roam scan cache
1146*/
1147eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1148{
1149 eHalStatus status = eHAL_STATUS_SUCCESS;
1150 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1151
1152 /* Free up the memory first (if required) */
1153 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1154 {
1155 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1156 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1157 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1158 }
1159 return status;
1160}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001161#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001162
1163
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001164#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001165/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001166 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001167*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001168eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001169{
1170 eHalStatus status = eHAL_STATUS_SUCCESS;
1171 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1172
1173 /* Free up the memory first (if required) */
1174 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1175 {
1176 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1177 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001178 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001179 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001180 return status;
1181}
1182
1183
1184
1185/*
1186 This function flushes the roam scan cache and creates fresh cache
1187 based on the input channel list
1188*/
1189eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1190 const tANI_U8 *pChannelList,
1191 const tANI_U8 numChannels)
1192{
1193 eHalStatus status = eHAL_STATUS_SUCCESS;
1194 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1195
Srinivas Girigowdade697412013-02-14 16:31:48 -08001196 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1197
1198 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1199 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1200
1201 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1202 {
1203 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1204 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1205 return eHAL_STATUS_RESOURCES;
1206 }
1207
1208 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301209 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1210 pChannelList,
1211 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001212 return status;
1213}
1214
1215/* This function modifies the bgscan channel list set via config ini or
1216 runtime, whenever the band changes.
1217 if the band is auto, then no operation is performed on the channel list
1218 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1219 if the band is 5G, then make sure channel list contains only 5G valid channels
1220*/
1221eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1222 eCsrBand eBand)
1223{
1224 eHalStatus status = eHAL_STATUS_SUCCESS;
1225 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1226 tANI_U8 outNumChannels = 0;
1227 tANI_U8 inNumChannels = 0;
1228 tANI_U8 *inPtr = NULL;
1229 tANI_U8 i = 0;
1230 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1231
1232 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1233
1234 {
1235 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1236 "No update required for channel list "
1237 "either cfg.ini channel list is not set up or "
1238 "auto band (Band %d)", eBand);
1239 return status;
1240 }
1241
1242 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1243 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1244 if (eCSR_BAND_24 == eBand)
1245 {
1246 for (i = 0; i < inNumChannels; i++)
1247 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001248 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001249 {
1250 ChannelList[outNumChannels++] = inPtr[i];
1251 }
1252 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001253 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001254 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001255 }
1256 else if (eCSR_BAND_5G == eBand)
1257 {
1258 for (i = 0; i < inNumChannels; i++)
1259 {
1260 /* Add 5G Non-DFS channel */
1261 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001262 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001263 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1264 {
1265 ChannelList[outNumChannels++] = inPtr[i];
1266 }
1267 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001268 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001269 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001270 }
1271 else if (eCSR_BAND_ALL == eBand)
1272 {
1273 for (i = 0; i < inNumChannels; i++)
1274 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001275 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001276 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1277 {
1278 ChannelList[outNumChannels++] = inPtr[i];
1279 }
1280 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001281 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001282 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001283 }
1284 else
1285 {
1286 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1287 "Invalid band, No operation carried out (Band %d)", eBand);
1288 status = eHAL_STATUS_INVALID_PARAMETER;
1289 }
1290
1291 return status;
1292}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001293#endif
1294
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001295#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001296/* This function modifies the roam scan channel list as per AP neighbor
1297 report; AP neighbor report may be empty or may include only other AP
1298 channels; in any case, we merge the channel list with the learned occupied
1299 channels list.
1300 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1301 if the band is 5G, then make sure channel list contains only 5G valid channels
1302*/
1303eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1304 tANI_U8 *pChannelList,
1305 tANI_U8 numChannels,
1306 const eCsrBand eBand)
1307{
1308 eHalStatus status = eHAL_STATUS_SUCCESS;
1309 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1310 tANI_U8 outNumChannels = 0;
1311 tANI_U8 inNumChannels = numChannels;
1312 tANI_U8 *inPtr = pChannelList;
1313 tANI_U8 i = 0;
1314 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1315 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1316 tANI_U8 mergedOutputNumOfChannels = 0;
1317 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1318
1319 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1320 * report Channels. This increases the chances of the DUT to get a candidate AP while
1321 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1322 if (pMac->scan.occupiedChannels.numChannels)
1323 {
1324 csrNeighborRoamMergeChannelLists(pMac,
1325 &pMac->scan.occupiedChannels.channelList[0],
1326 pMac->scan.occupiedChannels.numChannels,
1327 inPtr,
1328 inNumChannels,
1329 &mergedOutputNumOfChannels);
1330 inNumChannels = mergedOutputNumOfChannels;
1331 }
1332
1333 if (eCSR_BAND_24 == eBand)
1334 {
1335 for (i = 0; i < inNumChannels; i++)
1336 {
1337 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1338 {
1339 ChannelList[outNumChannels++] = inPtr[i];
1340 }
1341 }
1342 }
1343 else if (eCSR_BAND_5G == eBand)
1344 {
1345 for (i = 0; i < inNumChannels; i++)
1346 {
1347 /* Add 5G Non-DFS channel */
1348 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1349 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1350 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1351 {
1352 ChannelList[outNumChannels++] = inPtr[i];
1353 }
1354 }
1355 }
1356 else if (eCSR_BAND_ALL == eBand)
1357 {
1358 for (i = 0; i < inNumChannels; i++)
1359 {
1360 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1361 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1362 {
1363 ChannelList[outNumChannels++] = inPtr[i];
1364 }
1365 }
1366 }
1367 else
1368 {
1369 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1370 "Invalid band, No operation carried out (Band %d)", eBand);
1371 return eHAL_STATUS_INVALID_PARAMETER;
1372 }
1373
1374 /* if roaming within band is enabled, then select only the
1375 in band channels .
1376 This is required only if the band capability is set to ALL,
1377 E.g., if band capability is only 2.4G then all the channels in the
1378 list are already filtered for 2.4G channels, hence ignore this check*/
1379
1380 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1381 {
1382 csrNeighborRoamChannelsFilterByCurrentBand(
1383 pMac,
1384 ChannelList,
1385 outNumChannels,
1386 tmpChannelList,
1387 &outNumChannels);
Kiet Lamf2f201e2013-11-16 21:24:16 +05301388 vos_mem_copy(ChannelList,
1389 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001390 }
1391
1392 /* Prepare final roam scan channel list */
1393 if(outNumChannels)
1394 {
1395 /* Clear the channel list first */
1396 if (NULL != currChannelListInfo->ChannelList)
1397 {
1398 vos_mem_free(currChannelListInfo->ChannelList);
1399 currChannelListInfo->ChannelList = NULL;
1400 currChannelListInfo->numOfChannels = 0;
1401 }
1402
1403 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1404 if (NULL == currChannelListInfo->ChannelList)
1405 {
1406 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1407 "Failed to allocate memory for roam scan channel list");
1408 currChannelListInfo->numOfChannels = 0;
1409 return VOS_STATUS_E_RESOURCES;
1410 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301411 vos_mem_copy(currChannelListInfo->ChannelList,
1412 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001413 }
1414 return status;
1415}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001416#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001417
Jeff Johnson295189b2012-06-20 16:38:30 -07001418eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1419{
1420 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1421 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1423 (eBand == eCSR_BAND_24))
1424 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001425 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001426 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001427 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001428 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 pMac->roam.configParam.uCfgDot11Mode, eBand);
1430 return eHAL_STATUS_INVALID_PARAMETER;
1431 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1433 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1434 (eBand == eCSR_BAND_5G))
1435 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001436 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001437 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001438 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001439 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001440 pMac->roam.configParam.uCfgDot11Mode, eBand);
1441 return eHAL_STATUS_INVALID_PARAMETER;
1442 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001443 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001444 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001445 pMac->roam.configParam.eBand = eBand;
1446 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001447 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001448#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001449 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1450 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001451#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 status = csrInitGetChannels( pMac );
1453 if (eHAL_STATUS_SUCCESS == status)
1454 csrInitChannelList( hHal );
1455 return status;
1456}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001457
1458
Jeff Johnsone7245742012-09-05 17:12:55 -07001459/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1460 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1461 * Ideally we should have kept the ini value and enum value same and representing the same
1462 * cb values as in 11n standard i.e.
1463 * Set to 1 (SCA) if the secondary channel is above the primary channel
1464 * Set to 3 (SCB) if the secondary channel is below the primary channel
1465 * Set to 0 (SCN) if no secondary channel is present
1466 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1467 * 0 - secondary none
1468 * 1 - secondary LOW
1469 * 2 - secondary HIGH
1470 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1471 * The enum values are as follows:
1472 * PHY_SINGLE_CHANNEL_CENTERED = 0
1473 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1474 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1475 */
1476ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1477{
1478
1479 ePhyChanBondState phyCbState;
1480 switch (cbIniValue) {
1481 // secondary none
1482 case 0:
1483 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1484 break;
1485 // secondary LOW
1486 case 1:
1487 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1488 break;
1489 // secondary HIGH
1490 case 2:
1491 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1492 break;
1493#ifdef WLAN_FEATURE_11AC
1494 case 3:
1495 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1496 break;
1497 case 4:
1498 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1499 break;
1500 case 5:
1501 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1502 break;
1503 case 6:
1504 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1505 break;
1506 case 7:
1507 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1508 break;
1509 case 8:
1510 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1511 break;
1512 case 9:
1513 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1514 break;
1515#endif
1516 default:
1517 // If an invalid value is passed, disable CHANNEL BONDING
1518 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1519 break;
1520 }
1521 return phyCbState;
1522}
1523
1524v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1525{
1526
1527 v_U32_t cbIniValue;
1528 switch (phyCbState) {
1529 // secondary none
1530 case PHY_SINGLE_CHANNEL_CENTERED:
1531 cbIniValue = 0;
1532 break;
1533 // secondary LOW
1534 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1535 cbIniValue = 1;
1536 break;
1537 // secondary HIGH
1538 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1539 cbIniValue = 2;
1540 break;
1541#ifdef WLAN_FEATURE_11AC
1542 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1543 cbIniValue = 3;
1544 break;
1545 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1546 cbIniValue = 4;
1547 break;
1548 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1549 cbIniValue = 5;
1550 break;
1551 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1552 cbIniValue = 6;
1553 break;
1554 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1555 cbIniValue = 7;
1556 break;
1557 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1558 cbIniValue = 8;
1559 break;
1560 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1561 cbIniValue = 9;
1562 break;
1563#endif
1564 default:
1565 // return some invalid value
1566 cbIniValue = 10;
1567 break;
1568 }
1569 return cbIniValue;
1570}
Jeff Johnson295189b2012-06-20 16:38:30 -07001571
1572eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1573{
1574 eHalStatus status = eHAL_STATUS_SUCCESS;
1575
1576 if(pParam)
1577 {
1578 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1579 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1580 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1581 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1582 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1583 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1584
1585 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001586 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1587
Jeff Johnsone7245742012-09-05 17:12:55 -07001588 /* channelBondingMode5GHz plays a dual role right now
1589 * 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
1590 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1591 */
1592 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001594 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001595 }
1596 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1597 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1598 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001599 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001600 }
1601 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1603 pMac->roam.configParam.phyMode = pParam->phyMode;
1604 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1605 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1606 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1607 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1608 pMac->roam.configParam.TxRate = pParam->TxRate;
1609 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1610 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1611 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1612 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1613 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001614 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 //if HDD passed down non zero values then only update,
1616 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301617 if (pParam->nInitialDwellTime)
1618 {
1619 pMac->roam.configParam.nInitialDwellTime =
1620 pParam->nInitialDwellTime;
1621 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001622 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 {
1624 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301625 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1626 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001627 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001628 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 {
1630 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301631 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1632 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001634 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 {
1636 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301637 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1638 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001639 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001640 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001641 {
1642 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301643 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1644 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001645 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001646 if (pParam->nActiveMaxChnTimeBtc)
1647 {
1648 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1649 }
1650 if (pParam->nActiveMinChnTimeBtc)
1651 {
1652 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1653 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001654#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001655 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001656 {
1657 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1658 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001659 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001660 {
1661 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1662 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001663 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001664 {
1665 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1666 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001667 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001668 {
1669 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1670 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001671 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001672 {
1673 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1674 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001675 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001676 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001677 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1678 }
1679 if (pParam->nNumP2PChanCombinedConc)
1680 {
1681 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001682 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001683#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001685 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001686 {
1687 //Change the unit from second to microsecond
1688 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001689 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1690 {
1691 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1692 }
1693 else
1694 {
1695 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1696 }
1697 }
1698 else
1699 {
1700 pMac->roam.configParam.impsSleepTime = 0;
1701 }
1702 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001703 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1704 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 //if HDD passed down non zero values for age params, then only update,
1706 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001707 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001708 {
1709 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 if(pParam->scanAgeTimeNCNPS)
1712 {
1713 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 if(pParam->scanAgeTimeNCPS)
1716 {
1717 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1718 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 if(pParam->scanAgeTimeCNPS)
1720 {
1721 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1722 }
1723 if(pParam->scanAgeTimeCPS)
1724 {
1725 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1726 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301727 if (pParam->initialScanSkipDFSCh)
1728 {
1729 pMac->roam.configParam.initialScanSkipDFSCh =
1730 pParam->initialScanSkipDFSCh;
1731 }
1732
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001733 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1735 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1736 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1737 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1738 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1740 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001741 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1742 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1743 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1744 //Assign this before calling CsrInit11dInfo
1745 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001746 if( csrIs11dSupported( pMac ) )
1747 {
1748 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1749 }
1750 else
1751 {
1752 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1753 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001754
1755 /* Initialize the power + channel information if 11h is enabled.
1756 If 11d is enabled this information has already been initialized */
1757 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1758 {
1759 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1760 }
1761
1762
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301763#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301764 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1765 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001766 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001767#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001768#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001769 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001770 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001771 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001772 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001773 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001774 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001775 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001776 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001777 pMac->roam.configParam.nProbes = pParam->nProbes;
1778 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001779#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001780#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1781 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001782 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001783#endif
1784#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001785 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001786 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001787#endif
1788
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001789#ifdef FEATURE_WLAN_ESE
1790 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001791#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001792#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301793 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1794 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001795 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1796 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1797 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1798 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1799 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1800 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1801 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1802 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 {
1804 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001805 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 -07001806 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1807 {
1808 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001810 }
1811#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001812 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1813 pMac->scan.fValidateList = pParam->fValidateList;
1814 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1815 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001816 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001817 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001818 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1819 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1820 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1821 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1822 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1823 * single session
1824 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001825 //Remove this code once SLM_Sessionization is supported
1826 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001827 pMac->roam.configParam.doBMPSWorkaround = 0;
1828
Jeff Johnsone7245742012-09-05 17:12:55 -07001829#ifdef WLAN_FEATURE_11AC
1830 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001831 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001832 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001833 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301834 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1835 if ( pParam->enableTxBF )
1836 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
1837 else
1838 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001839#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001840 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001841
1842 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001843 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001844 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1845 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301846 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05301847 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07001848 }
1849
1850 return status;
1851}
1852
Jeff Johnson295189b2012-06-20 16:38:30 -07001853eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1854{
1855 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 if(pParam)
1857 {
1858 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1859 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1860 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1861 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1862 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1863 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001864 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1865 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1867 pParam->phyMode = pMac->roam.configParam.phyMode;
1868 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1869 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1870 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1871 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1872 pParam->TxRate = pMac->roam.configParam.TxRate;
1873 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1874 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1875 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1876 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1877 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1879 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1880 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1881 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001882 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1883 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1884 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001885#ifdef WLAN_AP_STA_CONCURRENCY
1886 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1887 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1888 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1889 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1890 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001891 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1892 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001893#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001894 //Change the unit from microsecond to second
1895 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1896 pParam->eBand = pMac->roam.configParam.eBand;
1897 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1898 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1899 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1900 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1901 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1902 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1903 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1904 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1905 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1906 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1907 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1908 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1909 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1911 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1912 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1913 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1915 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1916 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1917 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1918 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001919 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001920 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001921 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001922 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001923
1924#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301925 vos_mem_copy(&pParam->neighborRoamConfig,
1926 &pMac->roam.configParam.neighborRoamConfig,
1927 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001928#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001929#ifdef WLAN_FEATURE_11AC
1930 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001931 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001932 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001933 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301934 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1935 if ( pParam->enableTxBF )
1936 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
1937 else
1938 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001939#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001940#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301941 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1942 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001943#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001944#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001945 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1946 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1947 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1948 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1949 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001950 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001951 pParam->nProbes = pMac->roam.configParam.nProbes;
1952 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001953#endif
1954#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1955 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1956 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1957#endif
1958#ifdef FEATURE_WLAN_LFR
1959 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1960#endif
1961
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001962#ifdef FEATURE_WLAN_ESE
1963 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001964#endif
1965#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301966 vos_mem_copy(&pParam->neighborRoamConfig,
1967 &pMac->roam.configParam.neighborRoamConfig,
1968 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001969 {
1970 int i;
1971 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1972 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1973 {
1974 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1975 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001976 }
1977#endif
1978
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001979 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001980
krunal soni5afa96c2013-09-06 22:19:02 -07001981 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001982 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07001983
krunal sonie9002db2013-11-25 14:24:17 -08001984 pParam->isCoalesingInIBSSAllowed =
1985 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301986 pParam->allowDFSChannelRoam =
1987 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05301988 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 csrSetChannels(pMac, pParam);
1990
1991 status = eHAL_STATUS_SUCCESS;
1992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001993 return (status);
1994}
1995
Jeff Johnson295189b2012-06-20 16:38:30 -07001996eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1997{
1998 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1999 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2000 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2001 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 do
2003 {
2004 if(eCSR_BAND_24 == eBand)
2005 {
2006 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2007 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2008 }
2009 if(eCSR_BAND_5G == eBand)
2010 {
2011 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2012 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2013 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2014 )
2015 {
2016 break;
2017 }
2018 }
2019 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2020 {
2021 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2022 }
2023 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2024 {
2025 newPhyMode = eCSR_DOT11_MODE_AUTO;
2026 }
2027 else
2028 {
2029 //Check for dual band and higher capability first
2030 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2031 {
2032 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2033 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2034 }
2035 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2036 {
2037 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2038 if(eCSR_BAND_24 == eBand) break;
2039 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2040 eBand = eCSR_BAND_5G;
2041 }
2042 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2043 {
2044 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2045 if(eCSR_BAND_5G == eBand) break;
2046 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2047 eBand = eCSR_BAND_24;
2048 }
2049 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2050 {
2051 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2052 if(eCSR_BAND_5G == eBand) break;
2053 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2054 eBand = eCSR_BAND_24;
2055 }
2056 else if(eCSR_DOT11_MODE_11n & phyMode)
2057 {
2058 newPhyMode = eCSR_DOT11_MODE_11n;
2059 }
2060 else if(eCSR_DOT11_MODE_abg & phyMode)
2061 {
2062 newPhyMode = eCSR_DOT11_MODE_abg;
2063 }
2064 else if(eCSR_DOT11_MODE_11a & phyMode)
2065 {
2066 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2067 {
2068 if(eCSR_BAND_ALL == eBand)
2069 {
2070 newPhyMode = eCSR_DOT11_MODE_abg;
2071 }
2072 else
2073 {
2074 //bad setting
2075 break;
2076 }
2077 }
2078 else
2079 {
2080 newPhyMode = eCSR_DOT11_MODE_11a;
2081 eBand = eCSR_BAND_5G;
2082 }
2083 }
2084 else if(eCSR_DOT11_MODE_11g & phyMode)
2085 {
2086 newPhyMode = eCSR_DOT11_MODE_11g;
2087 eBand = eCSR_BAND_24;
2088 }
2089 else if(eCSR_DOT11_MODE_11b & phyMode)
2090 {
2091 newPhyMode = eCSR_DOT11_MODE_11b;
2092 eBand = eCSR_BAND_24;
2093 }
2094 else
2095 {
2096 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002097 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002098 newPhyMode = eCSR_DOT11_MODE_AUTO;
2099 }
2100 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 //Done validating
2102 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 //Now we need to check whether a restart is needed.
2104 if(eBand != pMac->roam.configParam.eBand)
2105 {
2106 fRestartNeeded = eANI_BOOLEAN_TRUE;
2107 break;
2108 }
2109 if(newPhyMode != pMac->roam.configParam.phyMode)
2110 {
2111 fRestartNeeded = eANI_BOOLEAN_TRUE;
2112 break;
2113 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002114 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002115 if(HAL_STATUS_SUCCESS(status))
2116 {
2117 pMac->roam.configParam.eBand = eBand;
2118 pMac->roam.configParam.phyMode = newPhyMode;
2119 if(pfRestartNeeded)
2120 {
2121 *pfRestartNeeded = fRestartNeeded;
2122 }
2123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002124 return (status);
2125}
2126
Jeff Johnson295189b2012-06-20 16:38:30 -07002127void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2128{
2129 tANI_U8 Index;
2130 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002131 // for dual band NICs, don't need to trim the channel list....
2132 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2133 {
2134 // 2.4 GHz band operation requires the channel list to be trimmed to
2135 // the 2.4 GHz channels only...
2136 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2137 {
2138 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2139 Index++ )
2140 {
2141 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2142 {
2143 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2144 cChannels++;
2145 }
2146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2148 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2149 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2150 // only if we need to.
2151 //
2152 // The amount of memory to clear is the number of channesl that we trimmed
2153 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2154
2155 if ( pChannelList->numChannels > cChannels )
2156 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302157 vos_mem_set(&pChannelList->channelList[ cChannels ],
2158 sizeof( pChannelList->channelList[ 0 ] ) *
2159 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002160 }
2161
2162 pChannelList->numChannels = cChannels;
2163 }
2164 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2165 {
2166 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2167 {
2168 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2169 {
2170 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2171 cChannels++;
2172 }
2173 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2175 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2176 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2177 // only if we need to.
2178 //
2179 // The amount of memory to clear is the number of channesl that we trimmed
2180 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2181 if ( pChannelList->numChannels > cChannels )
2182 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302183 vos_mem_set(&pChannelList->channelList[ cChannels ],
2184 sizeof( pChannelList->channelList[ 0 ] ) *
2185 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 }
2187
2188 pChannelList->numChannels = cChannels;
2189 }
2190 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002191}
Jeff Johnson295189b2012-06-20 16:38:30 -07002192#define INFRA_AP_DEFAULT_CHANNEL 6
2193eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2194{
2195 tANI_U8 index= 0;
2196 eHalStatus status = eHAL_STATUS_FAILURE;
2197 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2198 {
2199 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2200 status = eHAL_STATUS_SUCCESS;
2201 break;
2202 }
2203 }
2204 return status;
2205}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002206
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002207
Jeff Johnson295189b2012-06-20 16:38:30 -07002208eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2209{
2210 eHalStatus status = eHAL_STATUS_SUCCESS;
2211 tANI_U8 num20MHzChannelsFound = 0;
2212 VOS_STATUS vosStatus;
2213 tANI_U8 Index = 0;
2214 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002215
Jeff Johnson295189b2012-06-20 16:38:30 -07002216
2217 //TODO: this interface changed to include the 40MHz channel list
2218 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2219 // Read the scan channel list (including the power limit) from EEPROM
2220 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2221 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2222 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2223 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002224 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002225 status = eHAL_STATUS_FAILURE;
2226 }
2227 else
2228 {
2229 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2230 {
2231 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2232 }
2233 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2234 // Move the channel list to the global data
2235 // structure -- this will be used as the scan list
2236 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2237 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002239 }
2240 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2241 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2242 {
2243 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2244 }
2245 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2246 {
2247 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2248 }
2249 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 return (status);
2252}
2253
Jeff Johnson295189b2012-06-20 16:38:30 -07002254eHalStatus csrInitChannelList( tHalHandle hHal )
2255{
2256 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2257 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002258 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2259 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002260 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2261 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002263 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002264
2265 return (status);
2266}
Jeff Johnson295189b2012-06-20 16:38:30 -07002267eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2268 tCsrUpdateConfigParam *pUpdateConfigParam)
2269{
2270 eHalStatus status = eHAL_STATUS_FAILURE;
2271 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2273 status = CsrInit11dInfo(pMac, ps11dinfo);
2274 return status;
2275}
2276
Jeff Johnson295189b2012-06-20 16:38:30 -07002277static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2278{
2279 eHalStatus status = eHAL_STATUS_FAILURE;
2280 tANI_U8 index;
2281 tANI_U32 count=0;
2282 tSirMacChanInfo *pChanInfo;
2283 tSirMacChanInfo *pChanInfoStart;
2284 tANI_BOOLEAN applyConfig = TRUE;
2285
Mihir Shetebc866f62014-02-13 16:08:53 +05302286 pMac->scan.currentCountryRSSI = -128;
2287
Jeff Johnson295189b2012-06-20 16:38:30 -07002288 if(!ps11dinfo)
2289 {
2290 return (status);
2291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2293 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302294 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2295 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2296 ps11dinfo->Channels.channelList,
2297 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 }
2299 else
2300 {
2301 //No change
2302 return (eHAL_STATUS_SUCCESS);
2303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302305
2306 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2307 WNI_CFG_COUNTRY_CODE_LEN);
2308
2309
Jeff Johnson295189b2012-06-20 16:38:30 -07002310 //Tush: at csropen get this initialized with default, during csr reset if this
2311 // already set with some value no need initilaize with default again
2312 if(0 == pMac->scan.countryCodeCurrent[0])
2313 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302314 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2315 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302318 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2319 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302321 vos_mem_set(pChanInfo,
2322 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2323 0);
2324
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002326 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2327 {
2328 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2329 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2330 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2331 pChanInfo++;
2332 count++;
2333 }
2334 if(count)
2335 {
2336 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2337 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302338 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002339 }
2340 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2341 if( HAL_STATUS_SUCCESS(status) )
2342 {
2343 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2344 {
2345 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2346 {
2347 applyConfig = FALSE;
2348 }
2349 }
2350
2351 if(TRUE == applyConfig)
2352 {
2353 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002354 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002355 }
2356
2357 }
2358 return (status);
2359}
2360/* Initialize the Channel + Power List in the local cache and in the CFG */
2361eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2362{
2363 tANI_U8 index;
2364 tANI_U32 count=0;
2365 tSirMacChanInfo *pChanInfo;
2366 tSirMacChanInfo *pChanInfoStart;
2367
2368 if(!ps11dinfo || !pMac)
2369 {
2370 return eHAL_STATUS_FAILURE;
2371 }
2372
Kiet Lam64c1b492013-07-12 13:56:44 +05302373 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2374 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002375 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302376 vos_mem_set(pChanInfo,
2377 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2378 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002379 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002380
2381 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2382 {
2383 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2384 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2385 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2386 pChanInfo++;
2387 count++;
2388 }
2389 if(count)
2390 {
2391 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2392 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302393 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002394 }
2395
Jeff Johnsone7245742012-09-05 17:12:55 -07002396 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002397}
2398
2399//pCommand may be NULL
2400//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2401void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2402{
2403 tListElem *pEntry, *pNextEntry;
2404 tSmeCmd *pDupCommand;
2405 tDblLinkList localList;
2406
2407 vos_mem_zero(&localList, sizeof(tDblLinkList));
2408 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2409 {
2410 smsLog(pMac, LOGE, FL(" failed to open list"));
2411 return;
2412 }
2413 csrLLLock( &pMac->sme.smeCmdPendingList );
2414 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2415 while( pEntry )
2416 {
2417 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2418 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 // Remove the previous command if..
2420 // - the new roam command is for the same RoamReason...
2421 // - the new roam command is a NewProfileList.
2422 // - the new roam command is a Forced Dissoc
2423 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2424 if (
2425 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2426 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002427 /* This peermac check is requried for Softap/GO scenarios
2428 * For STA scenario below OR check will suffice as pCommand will
2429 * always be NULL for STA scenarios
2430 */
2431 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002432 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2433 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2434 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2435 ||
2436 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002437 ( (sessionId == pDupCommand->sessionId) &&
2438 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 ((eCsrForcedDisassoc == eRoamReason) ||
2440 (eCsrHddIssued == eRoamReason))
2441 )
2442 )
2443 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002444 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002445 // Remove the 'stale' roam command from the pending list...
2446 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2447 {
2448 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2449 }
2450 }
2451 pEntry = pNextEntry;
2452 }
2453 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2454
2455 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2456 {
2457 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2458 //Tell caller that the command is cancelled
2459 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2460 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2461 csrReleaseCommandRoam(pMac, pDupCommand);
2462 }
2463 csrLLClose(&localList);
2464}
Jeff Johnson295189b2012-06-20 16:38:30 -07002465eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2466 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2467{
2468 eHalStatus status = eHAL_STATUS_SUCCESS;
2469#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2470 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2471#endif
2472 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2474 {
2475 pSession = CSR_GET_SESSION( pMac, sessionId );
2476 }
2477 else
2478 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002479 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 VOS_ASSERT(0);
2481 return eHAL_STATUS_FAILURE;
2482 }
krunal soni587bf012014-02-04 12:35:11 -08002483
2484 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2485 {
2486 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2487 return eHAL_STATUS_FAILURE;
2488 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002489
krunal soni587bf012014-02-04 12:35:11 -08002490 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2491
krunal soni7f7d2c92014-02-06 15:08:43 -08002492 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002493 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002494 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002495 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002496 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2497 /*
2498 * Decrement bRefAssocStartCnt for FT reassoc failure.
2499 * Reason: For FT reassoc failures, we first call
2500 * csrRoamCallCallback before notifying a failed roam
2501 * completion through csrRoamComplete. The latter in
2502 * turn calls csrRoamProcessResults which tries to
2503 * once again call csrRoamCallCallback if bRefAssocStartCnt
2504 * is non-zero. Since this is redundant for FT reassoc
2505 * failure, decrement bRefAssocStartCnt.
2506 */
2507 pSession->bRefAssocStartCnt--;
2508 }
2509
Jeff Johnson295189b2012-06-20 16:38:30 -07002510 if(NULL != pSession->callback)
2511 {
2512 if( pRoamInfo )
2513 {
2514 pRoamInfo->sessionId = (tANI_U8)sessionId;
2515 }
2516
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302517 /* avoid holding the global lock when making the roaming callback, original change came
2518 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2519 is possible on other OS ports where the callback may need to take locks to protect
2520 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002521 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2522 that may actually depend on the lock being held */
2523 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2524 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2525 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2526 }
2527 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2528 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2529#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302530 vos_mem_set(&connectionStatus,
2531 sizeof(vos_event_wlan_status_payload_type), 0);
2532
krunal soni7f7d2c92014-02-06 15:08:43 -08002533 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002534 {
2535 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2536 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2537 if(NULL != pRoamInfo->pBssDesc)
2538 {
2539 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2540 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002542 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2543 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2544 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302545 vos_mem_copy(connectionStatus.ssid,
2546 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2547
Jeff Johnson295189b2012-06-20 16:38:30 -07002548 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2549 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002551 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2552 {
2553 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2554 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2555 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 if(eCSR_ROAM_RESULT_FORCED == u2)
2558 {
2559 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2560 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2561 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2562 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002563 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2564 {
2565 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2566 connectionStatus.reason = eCSR_REASON_DISASSOC;
2567 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2568 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002569 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2570 {
2571 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2572 connectionStatus.reason = eCSR_REASON_DEAUTH;
2573 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002575#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2576
2577 return (status);
2578}
Jeff Johnson295189b2012-06-20 16:38:30 -07002579// Returns whether handoff is currently in progress or not
2580tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2581{
2582#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2583 return csrNeighborRoamIsHandoffInProgress(pMac);
2584#else
2585 return eANI_BOOLEAN_FALSE;
2586#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002587}
Jeff Johnson295189b2012-06-20 16:38:30 -07002588eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2589 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2590{
2591 eHalStatus status = eHAL_STATUS_SUCCESS;
2592 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2593 tANI_U16 reasonCode;
2594 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002595
2596 if(!pSession)
2597 {
2598 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2599 return eHAL_STATUS_FAILURE;
2600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002601
2602 //Restore AC weight in case we change it
2603 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2604 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002605 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 -07002606 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2607 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2608 }
2609
2610 if ( fMICFailure )
2611 {
2612 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2613 }
2614 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2615 {
2616 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002617 }
2618 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 {
2620 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002622#ifdef WLAN_FEATURE_VOWIFI_11R
2623 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2624 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2625 {
2626 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302627 vos_mem_copy(&bssId,
2628 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2629 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002630 }
2631 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002632#endif
2633 if(pSession->pConnectBssDesc)
2634 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302635 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002637
Jeff Johnson295189b2012-06-20 16:38:30 -07002638
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302639 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2640 " subState = %s reason=%d"),
2641 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2642 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002643
Jeff Johnson295189b2012-06-20 16:38:30 -07002644 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2645
2646 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2647
2648 if(HAL_STATUS_SUCCESS(status))
2649 {
2650 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002651#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2652 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2653 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2654 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002655 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002656 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2657 }
2658#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002659 }
2660 else
2661 {
2662 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2663 }
2664
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 return (status);
2666}
Jeff Johnson295189b2012-06-20 16:38:30 -07002667
Jeff Johnson295189b2012-06-20 16:38:30 -07002668/* ---------------------------------------------------------------------------
2669 \fn csrRoamIssueDisassociateStaCmd
2670 \brief csr function that HDD calls to disassociate a associated station
2671 \param sessionId - session Id for Soft AP
2672 \param pPeerMacAddr - MAC of associated station to delete
2673 \param reason - reason code, be one of the tSirMacReasonCodes
2674 \return eHalStatus
2675 ---------------------------------------------------------------------------*/
2676eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2677 tANI_U32 sessionId,
2678 tANI_U8 *pPeerMacAddr,
2679 tANI_U32 reason)
2680{
2681 eHalStatus status = eHAL_STATUS_SUCCESS;
2682 tSmeCmd *pCommand;
2683
2684 do
2685 {
2686 pCommand = csrGetCommandBuffer( pMac );
2687 if ( !pCommand )
2688 {
2689 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2690 status = eHAL_STATUS_RESOURCES;
2691 break;
2692 }
2693 pCommand->command = eSmeCommandRoam;
2694 pCommand->sessionId = (tANI_U8)sessionId;
2695 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2696 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2697 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2698 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2699 if( !HAL_STATUS_SUCCESS( status ) )
2700 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002701 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002702 csrReleaseCommandRoam( pMac, pCommand );
2703 }
2704 }while(0);
2705
2706 return status;
2707}
2708
2709
Jeff Johnson295189b2012-06-20 16:38:30 -07002710/* ---------------------------------------------------------------------------
2711 \fn csrRoamIssueDeauthSta
2712 \brief csr function that HDD calls to delete a associated station
2713 \param sessionId - session Id for Soft AP
2714 \param pPeerMacAddr - MAC of associated station to delete
2715 \param reason - reason code, be one of the tSirMacReasonCodes
2716 \return eHalStatus
2717 ---------------------------------------------------------------------------*/
2718eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2719 tANI_U32 sessionId,
2720 tANI_U8 *pPeerMacAddr,
2721 tANI_U32 reason)
2722{
2723 eHalStatus status = eHAL_STATUS_SUCCESS;
2724 tSmeCmd *pCommand;
2725
2726 do
2727 {
2728 pCommand = csrGetCommandBuffer( pMac );
2729 if ( !pCommand )
2730 {
2731 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2732 status = eHAL_STATUS_RESOURCES;
2733 break;
2734 }
2735 pCommand->command = eSmeCommandRoam;
2736 pCommand->sessionId = (tANI_U8)sessionId;
2737 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2738 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2739 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2740 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2741 if( !HAL_STATUS_SUCCESS( status ) )
2742 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002743 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 csrReleaseCommandRoam( pMac, pCommand );
2745 }
2746 }while(0);
2747
2748 return status;
2749}
Jeff Johnson295189b2012-06-20 16:38:30 -07002750eHalStatus
2751csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2752 tANI_BOOLEAN bEnable )
2753{
2754 eHalStatus status = eHAL_STATUS_FAILURE;
2755 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2756 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002757 if (!pSession)
2758 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002759 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 return (status);
2761 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 if (pSession->pConnectBssDesc)
2763 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302764 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 }
2766 else
2767 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002768 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 return (status);
2770 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002771 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2772 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002773 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2774 return (status);
2775}
Jeff Johnson295189b2012-06-20 16:38:30 -07002776eHalStatus
2777csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2778 VOS_MODULE_ID modId, void *pUsrContext,
2779 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2780{
2781 eHalStatus status = eHAL_STATUS_SUCCESS;
2782 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2783 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002784 if (!pSession)
2785 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002786 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002787 return (status);
2788 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 if(pSession->pConnectBssDesc)
2790 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302791 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002792 }
2793 else
2794 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002795 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 return (status);
2797 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002798 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2799 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2801 return (status);
2802}
Jeff Johnson295189b2012-06-20 16:38:30 -07002803eHalStatus
2804csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2805 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2806{
2807 eHalStatus status = eHAL_STATUS_SUCCESS;
2808 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2809 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2810
2811 if (!pSession)
2812 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002813 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 return (status);
2815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002816 if(pSession->pConnectBssDesc)
2817 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302818 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 }
2820 else
2821 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002822 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002823 return (status);
2824 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002825 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2826 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002827
2828 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2829
2830 return (status);
2831}
Jeff Johnson295189b2012-06-20 16:38:30 -07002832eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2833{
2834 eHalStatus status = eHAL_STATUS_SUCCESS;
2835 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2836 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002837
2838 if (!pSession)
2839 {
2840 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2841 return eHAL_STATUS_FAILURE;
2842 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002843
2844 if(pSession->pConnectBssDesc)
2845 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302846 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002848 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2849 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002850 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2851
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302852 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05302853 if(HAL_STATUS_SUCCESS(status))
2854 {
2855 csrRoamLinkDown(pMac, sessionId);
2856 }
2857 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002858 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302859 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2860 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002861 }
2862
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 return (status);
2864}
2865
Jeff Johnson295189b2012-06-20 16:38:30 -07002866eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2867{
2868 eHalStatus status = eHAL_STATUS_SUCCESS;
2869 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2870 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002871
2872 if(!pSession)
2873 {
2874 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2875 return eHAL_STATUS_FAILURE;
2876 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002877
2878 // If no BSS description was found in this connection (happens with start IBSS), then
2879 // nix the BSS description that we keep around for the connected BSS) and get out...
2880 if(NULL == pBssDesc)
2881 {
2882 csrFreeConnectBssDesc(pMac, sessionId);
2883 }
2884 else
2885 {
2886 size = pBssDesc->length + sizeof( pBssDesc->length );
2887 if(NULL != pSession->pConnectBssDesc)
2888 {
2889 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2890 {
2891 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2892 csrFreeConnectBssDesc(pMac, sessionId);
2893 }
2894 }
2895 if(NULL == pSession->pConnectBssDesc)
2896 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302897 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002898 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302899 if (NULL == pSession->pConnectBssDesc)
2900 status = eHAL_STATUS_FAILURE;
2901 else
2902 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 return (status);
2905}
2906
Jeff Johnson295189b2012-06-20 16:38:30 -07002907eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2908 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2909 tDot11fBeaconIEs *pIes)
2910{
2911 eHalStatus status = eHAL_STATUS_SUCCESS;
2912 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002913 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302914 if (pIes == NULL)
2915 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002916
Jeff Johnson295189b2012-06-20 16:38:30 -07002917 do
2918 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302919 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2920 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 //get qos
2922 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2923 //get SSID
2924 if(pIes->SSID.present)
2925 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302926 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2928 }
2929 else
2930 pBssConfig->SSID.length = 0;
2931 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2932 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002933 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002934 //Return failed if profile doesn't have an SSID either.
2935 if(pProfile->SSIDs.numOfSSIDs == 0)
2936 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002937 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002938 status = eHAL_STATUS_FAILURE;
2939 break;
2940 }
2941 }
2942 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2943 {
2944 pBssConfig->eBand = eCSR_BAND_5G;
2945 }
2946 else
2947 {
2948 pBssConfig->eBand = eCSR_BAND_24;
2949 }
2950 //phymode
2951 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2952 {
2953 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2954 }
2955 else
2956 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002957 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 //force it
2959 if(eCSR_BAND_24 == pBssConfig->eBand)
2960 {
2961 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2962 }
2963 else
2964 {
2965 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2966 }
2967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 //Qos
2969 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2970 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2971 {
2972 //Joining BSS is not 11n capable and WMM is disabled on client.
2973 //Disable QoS and WMM
2974 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2975 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302976
2977 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302978 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302979 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2980 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2981 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2982 {
2983 //Joining BSS is 11n capable and WMM is disabled on AP.
2984 //Assume all HT AP's are QOS AP's and enable WMM
2985 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2986 }
2987
Jeff Johnson295189b2012-06-20 16:38:30 -07002988 //auth type
2989 switch( pProfile->negotiatedAuthType )
2990 {
2991 default:
2992 case eCSR_AUTH_TYPE_WPA:
2993 case eCSR_AUTH_TYPE_WPA_PSK:
2994 case eCSR_AUTH_TYPE_WPA_NONE:
2995 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2996 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2997 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 case eCSR_AUTH_TYPE_SHARED_KEY:
2999 pBssConfig->authType = eSIR_SHARED_KEY;
3000 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003001 case eCSR_AUTH_TYPE_AUTOSWITCH:
3002 pBssConfig->authType = eSIR_AUTO_SWITCH;
3003 break;
3004 }
3005 //short slot time
3006 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3007 {
3008 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3009 }
3010 else
3011 {
3012 pBssConfig->uShortSlotTime = 0;
3013 }
3014 if(pBssConfig->BssCap.ibss)
3015 {
3016 //We don't support 11h on IBSS
3017 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3018 }
3019 else
3020 {
3021 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3022 }
3023 //power constraint
3024 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3025 //heartbeat
3026 if ( CSR_IS_11A_BSS( pBssDesc ) )
3027 {
3028 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3029 }
3030 else
3031 {
3032 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3033 }
3034 //Join timeout
3035 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07003036 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 if ( pBssDesc->beaconInterval )
3038 {
3039 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07003040 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 }
3042 else
3043 {
3044 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3045 }
3046 //validate CB
3047 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sandeep Puligilla60342762014-01-30 21:05:37 +05303048
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 return (status);
3051}
3052
Jeff Johnson295189b2012-06-20 16:38:30 -07003053static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3054 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3055{
3056 eHalStatus status = eHAL_STATUS_SUCCESS;
3057 tANI_U8 operationChannel = 0;
3058 tANI_U8 qAPisEnabled = FALSE;
3059 //SSID
3060 pBssConfig->SSID.length = 0;
3061 if(pProfile->SSIDs.numOfSSIDs)
3062 {
3063 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303064 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3065 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 }
3067 else
3068 {
3069 //SSID must present
3070 return eHAL_STATUS_FAILURE;
3071 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003072 //Settomg up the capabilities
3073 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3074 {
3075 pBssConfig->BssCap.ibss = 1;
3076 }
3077 else
3078 {
3079 pBssConfig->BssCap.ess = 1;
3080 }
3081 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3082 {
3083 pBssConfig->BssCap.privacy = 1;
3084 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 pBssConfig->eBand = pMac->roam.configParam.eBand;
3086 //phymode
3087 if(pProfile->ChannelInfo.ChannelList)
3088 {
3089 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3090 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003091 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3092 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 //QOS
3094 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003095 if ( pBssConfig->BssCap.ess == 1 )
3096 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003097 /*For Softap case enable WMM*/
3098 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3099 qAPisEnabled = TRUE;
3100 }
3101 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3103 qAPisEnabled = TRUE;
3104 } else {
3105 qAPisEnabled = FALSE;
3106 }
3107 } else {
3108 qAPisEnabled = TRUE;
3109 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3111 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3112 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3113 )
3114 {
3115 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3116 } else {
3117 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3118 }
3119
3120 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003121 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003122 {
3123 default:
3124 case eCSR_AUTH_TYPE_WPA:
3125 case eCSR_AUTH_TYPE_WPA_PSK:
3126 case eCSR_AUTH_TYPE_WPA_NONE:
3127 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3128 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3129 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 case eCSR_AUTH_TYPE_SHARED_KEY:
3131 pBssConfig->authType = eSIR_SHARED_KEY;
3132 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 case eCSR_AUTH_TYPE_AUTOSWITCH:
3134 pBssConfig->authType = eSIR_AUTO_SWITCH;
3135 break;
3136 }
3137 //short slot time
3138 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3139 {
3140 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3141 }
3142 else
3143 {
3144 pBssConfig->uShortSlotTime = 0;
3145 }
3146 //power constraint. We don't support 11h on IBSS
3147 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3148 pBssConfig->uPowerLimit = 0;
3149 //heartbeat
3150 if ( eCSR_BAND_5G == pBssConfig->eBand )
3151 {
3152 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3153 }
3154 else
3155 {
3156 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3157 }
3158 //Join timeout
3159 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003160
Jeff Johnson295189b2012-06-20 16:38:30 -07003161 return (status);
3162}
Jeff Johnson295189b2012-06-20 16:38:30 -07003163static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3164{
3165 eHalStatus status = eHAL_STATUS_FAILURE;
3166 tDot11fBeaconIEs *pIes = NULL;
3167
3168 do
3169 {
3170 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3171 {
3172 //err msg
3173 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003174 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 break;
3176 }
3177 //check if the AP is QAP & it supports APSD
3178 if( CSR_IS_QOS_BSS(pIes) )
3179 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303180 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003181 }
3182 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303183
3184 if (NULL != pIes)
3185 {
3186 vos_mem_free(pIes);
3187 }
3188
Jeff Johnson295189b2012-06-20 16:38:30 -07003189 return status;
3190}
3191
Jeff Johnson295189b2012-06-20 16:38:30 -07003192void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3193{
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3195 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3196 // See !!Note: below in this function...
3197 tANI_U32 PrivacyEnabled = 0;
3198 tANI_U32 RsnEnabled = 0;
3199 tANI_U32 WepDefaultKeyId = 0;
3200 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3201 tANI_U32 Key0Length = 0;
3202 tANI_U32 Key1Length = 0;
3203 tANI_U32 Key2Length = 0;
3204 tANI_U32 Key3Length = 0;
3205
3206 // Reserve for the biggest key
3207 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3208 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3209 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3210 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3211
3212 switch ( pProfile->negotiatedUCEncryptionType )
3213 {
3214 case eCSR_ENCRYPT_TYPE_NONE:
3215
3216 // for NO encryption, turn off Privacy and Rsn.
3217 PrivacyEnabled = 0;
3218 RsnEnabled = 0;
3219
3220 // WEP key length and Wep Default Key ID don't matter in this case....
3221
3222 // clear out the WEP keys that may be hanging around.
3223 Key0Length = 0;
3224 Key1Length = 0;
3225 Key2Length = 0;
3226 Key3Length = 0;
3227
3228 break;
3229
3230 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303231 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003232
3233 // Privacy is ON. NO RSN for Wep40 static key.
3234 PrivacyEnabled = 1;
3235 RsnEnabled = 0;
3236
3237 // Set the Wep default key ID.
3238 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 // Wep key size if 5 bytes (40 bits).
3240 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3241
3242 // set encryption keys in the CFG database or clear those that are not present in this profile.
3243 if ( pProfile->Keys.KeyLength[0] )
3244 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303245 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3246 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3248 }
3249 else
3250 {
3251 Key0Length = 0;
3252 }
3253
3254 if ( pProfile->Keys.KeyLength[1] )
3255 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303256 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3257 WNI_CFG_WEP_KEY_LENGTH_5);
3258 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 }
3260 else
3261 {
3262 Key1Length = 0;
3263 }
3264
3265 if ( pProfile->Keys.KeyLength[2] )
3266 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303267 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3268 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3270 }
3271 else
3272 {
3273 Key2Length = 0;
3274 }
3275
3276 if ( pProfile->Keys.KeyLength[3] )
3277 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303278 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3279 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3281 }
3282 else
3283 {
3284 Key3Length = 0;
3285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 break;
3287
3288 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303289 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003290
3291 // Privacy is ON. NO RSN for Wep40 static key.
3292 PrivacyEnabled = 1;
3293 RsnEnabled = 0;
3294
3295 // Set the Wep default key ID.
3296 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3297
3298 // Wep key size if 13 bytes (104 bits).
3299 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3300
3301 // set encryption keys in the CFG database or clear those that are not present in this profile.
3302 if ( pProfile->Keys.KeyLength[0] )
3303 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303304 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3305 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3307 }
3308 else
3309 {
3310 Key0Length = 0;
3311 }
3312
3313 if ( pProfile->Keys.KeyLength[1] )
3314 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303315 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3316 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003317 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3318 }
3319 else
3320 {
3321 Key1Length = 0;
3322 }
3323
3324 if ( pProfile->Keys.KeyLength[2] )
3325 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303326 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3327 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3329 }
3330 else
3331 {
3332 Key2Length = 0;
3333 }
3334
3335 if ( pProfile->Keys.KeyLength[3] )
3336 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303337 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3338 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3340 }
3341 else
3342 {
3343 Key3Length = 0;
3344 }
3345
3346 break;
3347
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 case eCSR_ENCRYPT_TYPE_TKIP:
3349 case eCSR_ENCRYPT_TYPE_AES:
3350#ifdef FEATURE_WLAN_WAPI
3351 case eCSR_ENCRYPT_TYPE_WPI:
3352#endif /* FEATURE_WLAN_WAPI */
3353 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3354 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3355 PrivacyEnabled = (0 != fPrivacy);
3356
3357 // turn on RSN enabled for WPA associations
3358 RsnEnabled = 1;
3359
3360 // WEP key length and Wep Default Key ID don't matter in this case....
3361
3362 // clear out the static WEP keys that may be hanging around.
3363 Key0Length = 0;
3364 Key1Length = 0;
3365 Key2Length = 0;
3366 Key3Length = 0;
3367
3368 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003369 default:
3370 PrivacyEnabled = 0;
3371 RsnEnabled = 0;
3372 break;
3373 }
3374
3375 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3376 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3377 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3378 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3379 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3380 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3381 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3382 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3383}
3384
Jeff Johnson295189b2012-06-20 16:38:30 -07003385static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3386{
3387 tANI_U32 len = 0;
3388 if(pSSID->length <= WNI_CFG_SSID_LEN)
3389 {
3390 len = pSSID->length;
3391 }
3392 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3393}
3394
Jeff Johnson295189b2012-06-20 16:38:30 -07003395eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3396{
3397 eHalStatus status = eHAL_STATUS_SUCCESS;
3398 tANI_U32 QoSEnabled;
3399 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 // set the CFG enable/disable variables based on the qosType being configured...
3401 switch( qosType )
3402 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003403 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3404 QoSEnabled = FALSE;
3405 WmeEnabled = TRUE;
3406 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003407 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3408 QoSEnabled = FALSE;
3409 WmeEnabled = TRUE;
3410 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3412 QoSEnabled = FALSE;
3413 WmeEnabled = TRUE;
3414 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003415 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3416 QoSEnabled = TRUE;
3417 WmeEnabled = FALSE;
3418 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 case eCSR_MEDIUM_ACCESS_11e_HCF:
3420 QoSEnabled = TRUE;
3421 WmeEnabled = FALSE;
3422 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 default:
3424 case eCSR_MEDIUM_ACCESS_DCF:
3425 QoSEnabled = FALSE;
3426 WmeEnabled = FALSE;
3427 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 }
3429 //save the WMM setting for later use
3430 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303431 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003432 return (status);
3433}
Jeff Johnson295189b2012-06-20 16:38:30 -07003434static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3435 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3436{
3437 eHalStatus status = eHAL_STATUS_FAILURE;
3438 int i;
3439 eCsrCfgDot11Mode cfgDot11Mode;
3440 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303441 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3442 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003444
3445 if( NULL != pIes )
3446 {
3447 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003448 // Originally, we thought that for 11a networks, the 11a rates are always
3449 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3450 // appear in the Operational Rate set. Consequently, in either case, we
3451 // would blindly put the rates we support into our Operational Rate set
3452 // (including the basic rates, which we have already verified are
3453 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003454 // However, it turns out that this is not always the case. Some AP's
3455 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3456 // too. Now, we're a little more careful:
3457 pDstRate = pOpRateSet->rate;
3458 if(pIes->SuppRates.present)
3459 {
3460 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3461 {
3462 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3463 {
3464 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003465 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 }
3467 }
3468 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003469 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3470 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3471 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3472 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3473 {
3474 // If there are Extended Rates in the beacon, we will reflect those
3475 // extended rates that we support in out Extended Operational Rate
3476 // set:
3477 pDstRate = pExRateSet->rate;
3478 if(pIes->ExtSuppRates.present)
3479 {
3480 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3481 {
3482 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3483 {
3484 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3485 pExRateSet->numRates++;
3486 }
3487 }
3488 }
3489 }
3490 }//Parsing BSSDesc
3491 else
3492 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003493 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003494 }
3495 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3496 return status;
3497}
3498
3499static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3500 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3501{
3502 int i;
3503 tANI_U8 *pDstRate;
3504 eCsrCfgDot11Mode cfgDot11Mode;
3505 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3506 tANI_U32 OperationalRatesLength = 0;
3507 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3508 tANI_U32 ExtendedOperationalRatesLength = 0;
3509 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3510 tANI_U32 ProprietaryOperationalRatesLength = 0;
3511 tANI_U32 PropRatesEnable = 0;
3512 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3513 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003514 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 if( NULL != pIes )
3516 {
3517 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003518 // Originally, we thought that for 11a networks, the 11a rates are always
3519 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3520 // appear in the Operational Rate set. Consequently, in either case, we
3521 // would blindly put the rates we support into our Operational Rate set
3522 // (including the basic rates, which we have already verified are
3523 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003524 // However, it turns out that this is not always the case. Some AP's
3525 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3526 // too. Now, we're a little more careful:
3527 pDstRate = OperationalRates;
3528 if(pIes->SuppRates.present)
3529 {
3530 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3531 {
3532 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3533 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3534 {
3535 *pDstRate++ = pIes->SuppRates.rates[ i ];
3536 OperationalRatesLength++;
3537 }
3538 }
3539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003540 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3541 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3542 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3543 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3544 {
3545 // If there are Extended Rates in the beacon, we will reflect those
3546 // extended rates that we support in out Extended Operational Rate
3547 // set:
3548 pDstRate = ExtendedOperationalRates;
3549 if(pIes->ExtSuppRates.present)
3550 {
3551 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3552 {
3553 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3554 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3555 {
3556 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3557 ExtendedOperationalRatesLength++;
3558 }
3559 }
3560 }
3561 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 // Enable proprietary MAC features if peer node is Airgo node and STA
3563 // user wants to use them
3564 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3565 {
3566 PropRatesEnable = 1;
3567 }
3568 else
3569 {
3570 PropRatesEnable = 0;
3571 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003572 // For ANI network companions, we need to populate the proprietary rate
3573 // set with any proprietary rates we found in the beacon, only if user
3574 // allows them...
3575 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3576 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3577 {
3578 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3579 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3580 {
3581 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3582 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303583 vos_mem_copy(ProprietaryOperationalRates,
3584 pIes->Airgo.PropSuppRates.rates,
3585 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 }
3587 else {
3588 // No proprietary modes...
3589 ProprietaryOperationalRatesLength = 0;
3590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003591 /* Get MCS Rate */
3592 pDstRate = MCSRateIdxSet;
3593 if ( pIes->HTCaps.present )
3594 {
3595 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3596 {
3597 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3598 {
3599 MCSRateLength++;
3600 *pDstRate++ = i;
3601 }
3602 }
3603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 // Set the operational rate set CFG variables...
3605 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3606 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3607 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3608 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3609 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3610 ProprietaryOperationalRates,
3611 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3612 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3613 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3614 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3615 }//Parsing BSSDesc
3616 else
3617 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003618 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003619 }
3620}
3621
Jeff Johnson295189b2012-06-20 16:38:30 -07003622static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3623 tCsrRoamProfile *pProfile )
3624{
3625 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3626 { 8,
3627 { SIR_MAC_RATE_6,
3628 SIR_MAC_RATE_9,
3629 SIR_MAC_RATE_12,
3630 SIR_MAC_RATE_18,
3631 SIR_MAC_RATE_24,
3632 SIR_MAC_RATE_36,
3633 SIR_MAC_RATE_48,
3634 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003635 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3636 { 4,
3637 { SIR_MAC_RATE_1,
3638 SIR_MAC_RATE_2,
3639 SIR_MAC_RATE_5_5,
3640 SIR_MAC_RATE_11 } } };
3641
3642
3643 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3644 { SIR_MAC_RATE_72,
3645 SIR_MAC_RATE_96,
3646 SIR_MAC_RATE_108 } };
3647 eCsrCfgDot11Mode cfgDot11Mode;
3648 eCsrBand eBand;
3649 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3650 tANI_U32 OperationalRatesLength = 0;
3651 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3652 tANI_U32 ExtendedOperationalRatesLength = 0;
3653 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3654 tANI_U32 ProprietaryOperationalRatesLength = 0;
3655 tANI_U32 PropRatesEnable = 0;
3656 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003657 if(pProfile->ChannelInfo.ChannelList)
3658 {
3659 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3660 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003661 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003662 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3663 // networks, the 11b rates appear in the Operational Rate set. In either case,
3664 // we can blindly put the rates we support into our Operational Rate set
3665 // (including the basic rates, which we have already verified are supported
3666 // earlier in the roaming decision).
3667 if ( eCSR_BAND_5G == eBand )
3668 {
3669 // 11a rates into the Operational Rate Set.
3670 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3671 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303672 vos_mem_copy(OperationalRates,
3673 DefaultSupportedRates11a.supportedRateSet.rate,
3674 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003675
3676 // Nothing in the Extended rate set.
3677 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003678 // populate proprietary rates if user allows them
3679 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3680 {
3681 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3682 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303683 vos_mem_copy(ProprietaryOperationalRates,
3684 DefaultSupportedPropRates.propRate,
3685 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 }
3687 else
3688 {
3689 // No proprietary modes
3690 ProprietaryOperationalRatesLength = 0;
3691 }
3692 }
3693 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3694 {
3695 // 11b rates into the Operational Rate Set.
3696 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3697 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303698 vos_mem_copy(OperationalRates,
3699 DefaultSupportedRates11b.supportedRateSet.rate,
3700 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 // Nothing in the Extended rate set.
3702 ExtendedOperationalRatesLength = 0;
3703 // No proprietary modes
3704 ProprietaryOperationalRatesLength = 0;
3705 }
3706 else
3707 {
3708 // 11G
3709
3710 // 11b rates into the Operational Rate Set.
3711 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3712 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303713 vos_mem_copy(OperationalRates,
3714 DefaultSupportedRates11b.supportedRateSet.rate,
3715 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003716
3717 // 11a rates go in the Extended rate set.
3718 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3719 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303720 vos_mem_copy(ExtendedOperationalRates,
3721 DefaultSupportedRates11a.supportedRateSet.rate,
3722 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003723
3724 // populate proprietary rates if user allows them
3725 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3726 {
3727 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3728 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303729 vos_mem_copy(ProprietaryOperationalRates,
3730 DefaultSupportedPropRates.propRate,
3731 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 }
3733 else
3734 {
3735 // No proprietary modes
3736 ProprietaryOperationalRatesLength = 0;
3737 }
3738 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003739 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3740 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3741 {
3742 PropRatesEnable = 1;
3743 }
3744 else
3745 {
3746 PropRatesEnable = 0;
3747 }
3748
3749 // Set the operational rate set CFG variables...
3750 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3751 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3752 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3753 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3754 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3755 ProprietaryOperationalRates,
3756 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3757 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003758}
Jeff Johnson295189b2012-06-20 16:38:30 -07003759void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3760{
3761 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003762
Jeff Johnson295189b2012-06-20 16:38:30 -07003763 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3764 tANI_U32 sessionId;
3765 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003766 if(NULL == pEntry)
3767 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003768 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 return;
3770 }
3771 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3772 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05303773 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
3774 " current state : %d sub state : %d "),
3775 result, pMac->roam.curState[sessionId],
3776 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003777 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3778 {
3779 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3780 }
3781}
3782
Jeff Johnson295189b2012-06-20 16:38:30 -07003783//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3784tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3785{
3786 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3787 {
3788 return (WNI_CFG_PHY_MODE_11B);
3789 }
3790 else
3791 {
3792 if(eCSR_BAND_24 == band)
3793 return (WNI_CFG_PHY_MODE_11G);
3794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003795 return (WNI_CFG_PHY_MODE_11A);
3796}
Jeff Johnson295189b2012-06-20 16:38:30 -07003797
Jeff Johnsone7245742012-09-05 17:12:55 -07003798
3799#ifdef WLAN_FEATURE_11AC
3800ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3801{
3802 switch ( aniCBMode )
3803 {
3804 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3805 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3806 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3807 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3808 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3809 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3810 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3811 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3812 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003813 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003814 return PHY_SINGLE_CHANNEL_CENTERED;
3815 }
3816}
3817#endif
3818
Jeff Johnson295189b2012-06-20 16:38:30 -07003819//pIes may be NULL
3820eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3821 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303822 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003823{
3824 eHalStatus status = eHAL_STATUS_SUCCESS;
3825 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3826 tANI_U8 channel = 0;
3827 //Make sure we have the domain info for the BSS we try to connect to.
3828 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303829 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003830 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05303831 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 {
3833 //Make sure the 11d info from this BSSDesc can be applied
3834 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303835 if (VOS_TRUE == resetCountry)
3836 {
3837 csrApplyCountryInformation(pMac, FALSE);
3838 }
3839 else
3840 {
3841 csrApplyCountryInformation(pMac, TRUE);
3842 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 }
Kiran4a17ebe2013-01-31 10:43:43 -08003844 if ((csrIs11dSupported (pMac)) && pIes)
3845 {
3846 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003847 {
Kiran4a17ebe2013-01-31 10:43:43 -08003848 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003849 }
3850 else
3851 {
3852 //Let's also update the below to make sure we don't update CC while
3853 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303854 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003855 pBssDesc->bssId, sizeof(tSirMacAddr));
3856 }
Kiran4a17ebe2013-01-31 10:43:43 -08003857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003859 //Qos
3860 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3861 //SSID
3862 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3863 //fragment threshold
3864 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3865 //RTS threshold
3866 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3867
3868 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 //Auth type
3870 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3871 //encryption type
3872 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3873 //short slot time
3874 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 //11d
3876 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3877 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3878 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003879 /*//11h
3880 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3881 */
3882 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3883 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003884
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003885 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 {
3887 channel = pProfile->operationChannel;
3888 }
3889 else
3890 {
3891 if(pBssDesc)
3892 {
3893 channel = pBssDesc->channelId;
3894 }
3895 }
3896 if(0 != channel)
3897 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05303898 if(CSR_IS_CHANNEL_24GHZ(channel) &&
3899 !pMac->roam.configParam.channelBondingMode24GHz &&
3900 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
3901 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05303903 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
3904 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
3905 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 }
3907 else
3908 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003909 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003910 }
3911 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003912#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003913 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3914 // in function csrConvertCBIniValueToPhyCBState()
3915 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3916 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003917 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003918 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003919 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003920 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05303921 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003922 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003923 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003924 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003925 }
3926 else
3927#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3929 //Rate
3930 //Fixed Rate
3931 if(pBssDesc)
3932 {
3933 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3934 }
3935 else
3936 {
3937 csrSetCfgRateSetFromProfile(pMac, pProfile);
3938 }
3939 //Make this the last CFG to set. The callback will trigger a join_req
3940 //Join time out
3941 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3942
3943 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 return (status);
3945}
3946
Jeff Johnson295189b2012-06-20 16:38:30 -07003947eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3948 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3949{
3950 eHalStatus status;
3951 tBssConfigParam *pBssConfig;
3952 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003953
3954 if(!pSession)
3955 {
3956 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3957 return eHAL_STATUS_FAILURE;
3958 }
3959
Kiet Lam64c1b492013-07-12 13:56:44 +05303960 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
3961 if ( NULL == pBssConfig )
3962 status = eHAL_STATUS_FAILURE;
3963 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003964 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303965 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3967 if(HAL_STATUS_SUCCESS(status))
3968 {
3969 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003970 /* This will allow to pass cbMode during join req */
3971 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 //For IBSS, we need to prepare some more information
3973 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 )
3976 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003977 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 }
3979 // If we are in an IBSS, then stop the IBSS...
3980 ////Not worry about WDS connection for now
3981 if ( csrIsConnStateIbss( pMac, sessionId ) )
3982 {
3983 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3984 }
3985 else
3986 {
3987 // if we are in an Infrastructure association....
3988 if ( csrIsConnStateInfra( pMac, sessionId ) )
3989 {
3990 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3991 // across SSIDs (roaming to a new SSID)... //
3992 //Not worry about WDS connection for now
3993 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303994 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003995 {
3996 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303997 status = csrRoamIssueDisassociate( pMac, sessionId,
3998 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003999 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304000 else
4001 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4003 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304004 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004005 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304006 // Set parameters for this Bss.
4007 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4008 pBssDesc, pBssConfig,
4009 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004010 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304011 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004012 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304013 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 {
4015 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4016 // Nothing to stop.
4017 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004018 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304019 )
4020 {
4021 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4022 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4023 // Set parameters for this Bss.
4024 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4025 pBssDesc, pBssConfig,
4026 pIes, is11rRoamingFlag);
4027 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 }
4029 }
4030 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304031 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 return (status);
4034}
4035
Jeff Johnson295189b2012-06-20 16:38:30 -07004036eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4037 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4038{
4039 eCsrJoinState eRoamState = eCsrContinueRoaming;
4040 eHalStatus status;
4041 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4042 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4043 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004044
4045 if(!pSession)
4046 {
4047 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4048 return (eCsrStopRoaming);
4049 }
4050
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 if( CSR_IS_WDS_STA( pProfile ) )
4052 {
4053 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4054 if( !HAL_STATUS_SUCCESS( status ) )
4055 {
4056 eRoamState = eCsrStopRoaming;
4057 }
4058 }
4059 else
4060 {
4061 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4062 {
4063 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4064 return (eCsrStopRoaming);
4065 }
4066 if ( csrIsInfraBssDesc( pBssDesc ) )
4067 {
4068 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4069 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4070 // have changed and handle the changes (without disturbing the current association).
4071
4072 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4073 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4074 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4075 )
4076 {
4077 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4078 // with Authenticating first. To force this, stop the current association (Disassociate) and
4079 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4080 // a new Association.
4081 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4082 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004083 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4085 {
4086 eRoamState = eCsrReassocToSelfNoCapChange;
4087 }
4088 else
4089 {
4090 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304092 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4094 if(HAL_STATUS_SUCCESS(status))
4095 {
4096 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004097 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304099 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4100 pBssDesc, &bssConfig,
4101 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 if(!HAL_STATUS_SUCCESS(status))
4103 {
4104 eRoamState = eCsrStopRoaming;
4105 }
4106 }
4107 else
4108 {
4109 eRoamState = eCsrStopRoaming;
4110 }
4111 }//same profile
4112 }
4113 else
4114 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304115 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4117 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304118 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4119 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304123 }
4124 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 {
4126 // 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 +05304127 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 // work much better.
4129 //
4130 //
4131 // stop the existing network before attempting to join the new network...
4132 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4133 {
4134 eRoamState = eCsrStopRoaming;
4135 }
4136 }
4137 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304138 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 {
4140 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4141 {
4142 eRoamState = eCsrStopRoaming;
4143 }
4144 }
4145 if( pIesLocal && !pScanResult->pvIes )
4146 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304147 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004148 }
4149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 return( eRoamState );
4151}
4152
Jeff Johnson295189b2012-06-20 16:38:30 -07004153eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4154 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4155{
4156 eHalStatus status = eHAL_STATUS_SUCCESS;
4157 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304158 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 roamInfo.pBssDesc = pBssDesc;
4160 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4161 return (status);
4162}
Jeff Johnson295189b2012-06-20 16:38:30 -07004163//In case no matching BSS is found, use whatever default we can find
4164static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4165{
4166 //Need to get all negotiated types in place first
4167 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004168 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 {
4170 default:
4171 case eCSR_AUTH_TYPE_WPA:
4172 case eCSR_AUTH_TYPE_WPA_PSK:
4173 case eCSR_AUTH_TYPE_WPA_NONE:
4174 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4175 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4176 break;
4177
4178 case eCSR_AUTH_TYPE_SHARED_KEY:
4179 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4180 break;
4181
4182 case eCSR_AUTH_TYPE_AUTOSWITCH:
4183 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4184 break;
4185 }
4186 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4187 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4188 //In this case, the multicast encryption needs to follow the uncast ones.
4189 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4190 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4191}
4192
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004193
4194static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4195{
4196 switch(pCommand->u.roamCmd.roamReason)
4197 {
4198 case eCsrLostLink1:
4199 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4200 break;
4201 case eCsrLostLink2:
4202 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4203 break;
4204 case eCsrLostLink3:
4205 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4206 break;
4207 default:
4208 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4209 pCommand->u.roamCmd.roamReason);
4210 break;
4211 }
4212}
4213
Jeff Johnson295189b2012-06-20 16:38:30 -07004214static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4215{
4216 eHalStatus status;
4217 tCsrScanResult *pScanResult = NULL;
4218 eCsrJoinState eRoamState = eCsrStopRoaming;
4219 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4220 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4221 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4222#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4223 v_U8_t acm_mask = 0;
4224#endif
4225 tANI_U32 sessionId = pCommand->sessionId;
4226 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4227 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4228 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004229
4230 if(!pSession)
4231 {
4232 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4233 return (eCsrStopRoaming);
4234 }
4235
Jeff Johnson295189b2012-06-20 16:38:30 -07004236 do
4237 {
4238 // Check for Cardbus eject condition, before trying to Roam to any BSS
4239 //***if( !balIsCardPresent(pAdapter) ) break;
4240
Kiet Lam64c1b492013-07-12 13:56:44 +05304241 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304242 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 if(NULL != pBSSList)
4244 {
4245 // When handling AP's capability change, continue to associate to
4246 // same BSS and make sure pRoamBssEntry is not Null.
4247 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4248 {
4249 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4250 {
4251 //Try the first BSS
4252 pCommand->u.roamCmd.pLastRoamBss = NULL;
4253 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4254 }
4255 else
4256 {
4257 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4258 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4259 {
4260 //Done with all the BSSs
4261 //In this case, will tell HDD the completion
4262 break;
4263 }
4264 else
4265 {
4266 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304267 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004268 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4269 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4270 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4271 pRoamInfo = &roamInfo;
4272 }
4273 }
4274 while(pCommand->u.roamCmd.pRoamBssEntry)
4275 {
4276 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004277 /*If concurrency enabled take the concurrent connected channel first. */
4278 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304279 if (vos_concurrent_open_sessions_running() &&
4280 !csrIsValidMcConcurrentSession(pMac, sessionId,
4281 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004282 {
4283 concurrentChannel =
4284 csrGetConcurrentOperationChannel(pMac);
4285 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004286 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 if ((concurrentChannel) &&
4288 (concurrentChannel ==
4289 pScanResult->Result.BssDescriptor.channelId))
4290 {
4291 //make this 0 because we do not want the
4292 //below check to pass as we don't want to
4293 //connect on other channel
4294 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4295 FL("Concurrent channel match =%d"),
4296 concurrentChannel);
4297 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 }
4299 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004300
4301 if (!concurrentChannel)
4302 {
4303
4304 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4305 sessionId, &pScanResult->Result.BssDescriptor,
4306 pCommand->u.roamCmd.roamId)))
4307 {
4308 //Ok to roam this
4309 break;
4310 }
4311 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004312 else
4313 {
4314 eRoamState = eCsrStopRoamingDueToConcurrency;
4315 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4317 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4318 {
4319 //Done with all the BSSs
4320 fDone = eANI_BOOLEAN_TRUE;
4321 break;
4322 }
4323 }
4324 if(fDone)
4325 {
4326 break;
4327 }
4328 }
4329 }
4330 //We have something to roam, tell HDD when it is infra.
4331 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4332 //For WDS, the indication is eCSR_ROAM_WDS_IND
4333 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4334 {
4335 if(pRoamInfo)
4336 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004337 if(pSession->bRefAssocStartCnt)
4338 {
4339 pSession->bRefAssocStartCnt--;
4340 //Complete the last association attemp because a new one is about to be tried
4341 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4342 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004344 }
4345 }
4346 /* If the roaming has stopped, not to continue the roaming command*/
4347 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4348 {
4349 //No need to complete roaming here as it already completes
4350 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4351 pCommand->u.roamCmd.roamReason);
4352 eRoamState = eCsrStopRoaming;
4353 csrSetAbortRoamingCommand(pMac, pCommand);
4354 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004355 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304356 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 if(pScanResult)
4358 {
4359 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004360 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4361 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004362 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004363 fDone = eANI_BOOLEAN_TRUE;
4364 eRoamState = eCsrStopRoaming;
4365 break;
4366 }
4367 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4368 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4369 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4370 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4371 CSR_IS_QOS_BSS(pIesLocal) &&
4372 CSR_IS_UAPSD_BSS(pIesLocal) )
4373 {
4374#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4376 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004377#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004378 }
4379 else
4380 {
4381 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4382 }
4383 if( pIesLocal && !pScanResult->Result.pvIes)
4384 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304385 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 }
4387 }
4388 else
4389 {
4390 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4391 }
4392 roamInfo.pProfile = pProfile;
4393 pSession->bRefAssocStartCnt++;
4394 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4395 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4396 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004397 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4398 {
4399 // If this is a start IBSS profile, then we need to start the IBSS.
4400 if ( CSR_IS_START_IBSS(pProfile) )
4401 {
4402 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 // Attempt to start this IBSS...
4404 csrRoamAssignDefaultParam( pMac, pCommand );
4405 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4406 if(HAL_STATUS_SUCCESS(status))
4407 {
4408 if ( fSameIbss )
4409 {
4410 eRoamState = eCsrStartIbssSameIbss;
4411 }
4412 else
4413 {
4414 eRoamState = eCsrContinueRoaming;
4415 }
4416 }
4417 else
4418 {
4419 //it somehow fail need to stop
4420 eRoamState = eCsrStopRoaming;
4421 }
4422 break;
4423 }
4424 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004425 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 )
4427 {
4428 // Attempt to start this WDS...
4429 csrRoamAssignDefaultParam( pMac, pCommand );
4430 /* For AP WDS, we dont have any BSSDescription */
4431 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4432 if(HAL_STATUS_SUCCESS(status))
4433 {
4434 eRoamState = eCsrContinueRoaming;
4435 }
4436 else
4437 {
4438 //it somehow fail need to stop
4439 eRoamState = eCsrStopRoaming;
4440 }
4441 }
4442 else
4443 {
4444 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004445 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 eRoamState = eCsrStopRoaming;
4447 break;
4448 }
4449 }
4450 else //We have BSS
4451 {
4452 //Need to assign these value because they are used in csrIsSameProfile
4453 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004454 /* The OSEN IE doesn't provide the cipher suite.
4455 * Therefore set to constant value of AES */
4456 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4457 {
4458 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4459 eCSR_ENCRYPT_TYPE_AES;
4460 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4461 eCSR_ENCRYPT_TYPE_AES;
4462 }
4463 else
4464 {
4465 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4466 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4467 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4468 pScanResult->mcEncryptionType;
4469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4471 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4472 {
4473 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4474 {
4475 eRoamState = eCsrStartIbssSameIbss;
4476 break;
4477 }
4478 }
4479 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4480 {
4481 //trying to connect to the one already connected
4482 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4483 eRoamState = eCsrReassocToSelfNoCapChange;
4484 break;
4485 }
4486 // Attempt to Join this Bss...
4487 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4488 break;
4489 }
4490
4491 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4493 {
4494 //Need to indicate association_completion if association_start has been done
4495 if(pSession->bRefAssocStartCnt > 0)
4496 {
4497 pSession->bRefAssocStartCnt--;
4498 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004499 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4501 eCSR_ROAM_ASSOCIATION_COMPLETION,
4502 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4503 }
4504 }
4505
4506 return( eRoamState );
4507}
4508
Jeff Johnson295189b2012-06-20 16:38:30 -07004509static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4510{
4511 eHalStatus status = eHAL_STATUS_SUCCESS;
4512 eCsrJoinState RoamState;
4513 tANI_U32 sessionId = pCommand->sessionId;
4514
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 //***if( hddIsRadioStateOn( pAdapter ) )
4516 {
4517 // Attept to join a Bss...
4518 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004519
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004521 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 {
4523 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 // and if connected in Infrastructure mode...
4525 if ( csrIsConnStateInfra(pMac, sessionId) )
4526 {
4527 //... then we need to issue a disassociation
4528 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4529 if(!HAL_STATUS_SUCCESS(status))
4530 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004531 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 //roam command is completed by caller in the failed case
4533 fComplete = eANI_BOOLEAN_TRUE;
4534 }
4535 }
4536 else if( csrIsConnStateIbss(pMac, sessionId) )
4537 {
4538 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4539 if(!HAL_STATUS_SUCCESS(status))
4540 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004541 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 //roam command is completed by caller in the failed case
4543 fComplete = eANI_BOOLEAN_TRUE;
4544 }
4545 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004546 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4547 {
4548 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4549 if(!HAL_STATUS_SUCCESS(status))
4550 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004551 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 //roam command is completed by caller in the failed case
4553 fComplete = eANI_BOOLEAN_TRUE;
4554 }
4555 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004556 else
4557 {
4558 fComplete = eANI_BOOLEAN_TRUE;
4559 }
4560 if(fComplete)
4561 {
4562 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004563 if(eCsrStopRoamingDueToConcurrency == RoamState)
4564 {
4565 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4566 }
4567 else
4568 {
4569 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4570 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 }
4572 }
4573 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4574 {
4575 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4576 }
4577 else if ( eCsrStartIbssSameIbss == RoamState )
4578 {
4579 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4580 }
4581 }//hddIsRadioStateOn
4582
4583 return status;
4584}
Jeff Johnson295189b2012-06-20 16:38:30 -07004585eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4586{
4587 tANI_U32 sessionId;
4588 tCsrRoamSession *pSession;
4589 tCsrScanResult *pScanResult = NULL;
4590 tSirBssDescription *pBssDesc = NULL;
4591 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 sessionId = pCommand->sessionId;
4593 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004594
4595 if(!pSession)
4596 {
4597 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4598 return eHAL_STATUS_FAILURE;
4599 }
4600
Jeff Johnson295189b2012-06-20 16:38:30 -07004601 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4602 {
4603 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004604 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4606 return eHAL_STATUS_FAILURE;
4607 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 if (pCommand->u.roamCmd.pRoamBssEntry)
4609 {
4610 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4611 pBssDesc = &pScanResult->Result.BssDescriptor;
4612 }
4613 else
4614 {
4615 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004616 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4618 return eHAL_STATUS_FAILURE;
4619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004620 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4621 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4622 return status;
4623}
4624
Jeff Johnson295189b2012-06-20 16:38:30 -07004625eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4626{
4627 eHalStatus status = eHAL_STATUS_SUCCESS;
4628 tCsrRoamInfo roamInfo;
4629 tANI_U32 sessionId = pCommand->sessionId;
4630 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004631
4632 if(!pSession)
4633 {
4634 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4635 return eHAL_STATUS_FAILURE;
4636 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05304637
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 switch ( pCommand->u.roamCmd.roamReason )
4639 {
4640 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004641 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004642 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 case eCsrSmeIssuedDisassocForHandoff:
4645 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4646#if 0 // TODO : Confirm this change
4647 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4648#else
4649 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4650#endif
4651
4652 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004655 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004657 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004658 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004659 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004660 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004661 case eCsrHddIssuedReassocToSameAP:
4662 case eCsrSmeIssuedReassocToSameAP:
4663 {
4664 tDot11fBeaconIEs *pIes = NULL;
4665
Jeff Johnson295189b2012-06-20 16:38:30 -07004666 if( pSession->pConnectBssDesc )
4667 {
4668 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4669 if(!HAL_STATUS_SUCCESS(status) )
4670 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004671 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004672 }
4673 else
4674 {
4675 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4676 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4677 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004678 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4679 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4680 pSession->bRefAssocStartCnt++;
4681 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4682 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4683
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004684 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004685 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4686 &pCommand->u.roamCmd.roamProfile );
4687 if(!HAL_STATUS_SUCCESS(status))
4688 {
4689 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004690 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004691 }
4692
Kiet Lam64c1b492013-07-12 13:56:44 +05304693 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 pIes = NULL;
4695 }
4696 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05304697 else
4698 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004699 break;
4700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004701 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004702 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004703 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4704 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4705 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004706 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004707 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4709 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004710
Jeff Johnson295189b2012-06-20 16:38:30 -07004711 case eCsrStopBss:
4712 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4713 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4714 break;
4715
4716 case eCsrForcedDisassocSta:
4717 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4718 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4719 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4720 pCommand->u.roamCmd.reason);
4721 break;
4722
4723 case eCsrForcedDeauthSta:
4724 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4725 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4726 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4727 pCommand->u.roamCmd.reason);
4728 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004729
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004730 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004731 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004732 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4733 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004734 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004735
4736 default:
4737 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4738
4739 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4740 {
4741 //Remember the roaming profile
4742 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304743 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4744 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004745 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304746 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004747 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4748 }
4749 }
4750
4751 //At this point, original uapsd_mask is saved in pCurRoamProfile
4752 //uapsd_mask in the pCommand may change from this point on.
4753
4754 // Attempt to roam with the new scan results (if we need to..)
4755 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004756 if(!HAL_STATUS_SUCCESS(status))
4757 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004758 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004759 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 break;
4761 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 return (status);
4763}
4764
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004765void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4766{
4767 pCommand->u.roamCmd.pLastRoamBss = NULL;
4768 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4769 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304770 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004771}
4772
Jeff Johnson295189b2012-06-20 16:38:30 -07004773void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4774{
4775 if(pCommand->u.roamCmd.fReleaseBssList)
4776 {
4777 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4778 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4779 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4780 }
4781 if(pCommand->u.roamCmd.fReleaseProfile)
4782 {
4783 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4784 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4785 }
4786 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4787 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304788 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004789}
4790
Jeff Johnson295189b2012-06-20 16:38:30 -07004791void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4792{
Kiet Lam64c1b492013-07-12 13:56:44 +05304793 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004794}
Jeff Johnson295189b2012-06-20 16:38:30 -07004795void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4796{
4797 tListElem *pEntry;
4798 tSmeCmd *pCommand;
4799 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004800 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004801 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4802 if ( pEntry )
4803 {
4804 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 // If the head of the queue is Active and it is a ROAM command, remove
4806 // and put this on the Free queue.
4807 if ( eSmeCommandRoam == pCommand->command )
4808 {
4809 //we need to process the result first before removing it from active list because state changes
4810 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4811 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4812 if( fReleaseCommand )
4813 {
4814 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4815 {
4816 csrReleaseCommandRoam( pMac, pCommand );
4817 }
4818 else
4819 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004820 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004821 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004822 }
4823 }
4824 else
4825 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004826 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004827 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 }
4829 }
4830 else
4831 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004832 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004833 }
4834 }
4835 else
4836 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004837 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004838 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 if( fReleaseCommand )
4840 {
4841 smeProcessPendingQueue( pMac );
4842 }
4843}
4844
Jeff Johnson295189b2012-06-20 16:38:30 -07004845void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4846{
4847 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004848 if(!pSession)
4849 {
4850 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4851 return;
4852 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304853 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4854 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 pSession->NumPmkidCandidate = 0;
4856}
Jeff Johnson295189b2012-06-20 16:38:30 -07004857#ifdef FEATURE_WLAN_WAPI
4858void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4859{
4860 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004861 if(!pSession)
4862 {
4863 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4864 return;
4865 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304866 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4867 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 pSession->NumBkidCandidate = 0;
4869}
4870#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004871extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4872
Jeff Johnson295189b2012-06-20 16:38:30 -07004873static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4874 tSirBssDescription *pSirBssDesc,
4875 tDot11fBeaconIEs *pIes)
4876{
4877 eHalStatus status = eHAL_STATUS_SUCCESS;
4878 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4879 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004880
4881 if(!pSession)
4882 {
4883 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4884 return eHAL_STATUS_FAILURE;
4885 }
4886
Jeff Johnson295189b2012-06-20 16:38:30 -07004887 if((eCSR_AUTH_TYPE_WPA == authType) ||
4888 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4889 (eCSR_AUTH_TYPE_RSN == authType) ||
4890 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4891#if defined WLAN_FEATURE_VOWIFI_11R
4892 ||
4893 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4894 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4895#endif /* FEATURE_WLAN_WAPI */
4896#ifdef FEATURE_WLAN_WAPI
4897 ||
4898 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4899 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4900#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004901#ifdef WLAN_FEATURE_11W
4902 ||
4903 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4904#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004905 )
4906 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004909 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004910 }
4911 if( pIesLocal )
4912 {
4913 tANI_U32 nIeLen;
4914 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 if((eCSR_AUTH_TYPE_RSN == authType) ||
4916#if defined WLAN_FEATURE_VOWIFI_11R
4917 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4918 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4919#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004920#if defined WLAN_FEATURE_11W
4921 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4922#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004923 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4924 {
4925 if(pIesLocal->RSN.present)
4926 {
4927 //Calculate the actual length
4928 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4929 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4930 + 2 //akm_suite_count
4931 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4932 + 2; //reserved
4933 if( pIesLocal->RSN.pmkid_count )
4934 {
4935 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4936 }
4937 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304938 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4939 if (NULL == pSession->pWpaRsnRspIE)
4940 status = eHAL_STATUS_FAILURE;
4941 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004942 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304943 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004944 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4945 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4946 //copy upto akm_suites
4947 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304948 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4949 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004950 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304951 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4952 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004953 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304954 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4955 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004956 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 if( pIesLocal->RSN.pwise_cipher_suite_count )
4958 {
4959 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304960 vos_mem_copy(pIeBuf,
4961 pIesLocal->RSN.pwise_cipher_suites,
4962 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4964 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304965 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004966 pIeBuf += 2;
4967 if( pIesLocal->RSN.akm_suite_count )
4968 {
4969 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304970 vos_mem_copy(pIeBuf,
4971 pIesLocal->RSN.akm_suites,
4972 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004973 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4974 }
4975 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05304976 vos_mem_copy(pIeBuf,
4977 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
4978 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004979 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4980 }
4981 }
4982 }
4983 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4984 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4985 {
4986 if(pIesLocal->WPA.present)
4987 {
4988 //Calculate the actual length
4989 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4990 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4991 + 2 //auth_suite_count
4992 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4993 // The WPA capabilities follows the Auth Suite (two octects)--
4994 // this field is optional, and we always "send" zero, so just
4995 // remove it. This is consistent with our assumptions in the
4996 // frames compiler; c.f. bug 15234:
4997 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304998
4999 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5000 if ( NULL == pSession->pWpaRsnRspIE )
5001 status = eHAL_STATUS_FAILURE;
5002 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 {
5004 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5005 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5006 pIeBuf = pSession->pWpaRsnRspIE + 2;
5007 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305008 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005009 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305010 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5011 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005012 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305013 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5014 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005015 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5016 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5017 }
5018 }
5019 }
5020#ifdef FEATURE_WLAN_WAPI
5021 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5022 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5023 {
5024 if(pIesLocal->WAPI.present)
5025 {
5026 //Calculate the actual length
5027 nIeLen = 4 //version + akm_suite_count
5028 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5029 + 2 //pwise_cipher_suite_count
5030 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5031 + 6; //gp_cipher_suite + preauth + reserved
5032 if( pIesLocal->WAPI.bkid_count )
5033 {
5034 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5035 }
5036
5037 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305038 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5039 if ( NULL == pSession->pWapiRspIE )
5040 status = eHAL_STATUS_FAILURE;
5041 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 {
5043 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5044 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5045 pIeBuf = pSession->pWapiRspIE + 2;
5046 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305047 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 pIeBuf += 4;
5049 if( pIesLocal->WAPI.akm_suite_count )
5050 {
5051 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305052 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5053 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005054 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305055 }
5056 vos_mem_copy(pIeBuf,
5057 &pIesLocal->WAPI.unicast_cipher_suite_count,
5058 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005059 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005060 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5061 {
5062 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305063 vos_mem_copy( pIeBuf,
5064 pIesLocal->WAPI.unicast_cipher_suites,
5065 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005066 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5067 }
lukez3c809222013-05-03 10:23:02 -07005068 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305069 vos_mem_copy(pIeBuf,
5070 pIesLocal->WAPI.multicast_cipher_suite,
5071 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005072 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305073 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305074 vos_mem_copy(pIeBuf,
5075 pIesLocal->WAPI.multicast_cipher_suite + 4,
5076 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005077 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305078 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305079 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5080
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005081 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005082 if( pIesLocal->WAPI.bkid_count )
5083 {
5084 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305085 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5086 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005087 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5088 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305089 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005090 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005091 }
5092 }
5093#endif /* FEATURE_WLAN_WAPI */
5094 if( !pIes )
5095 {
5096 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305097 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005098 }
5099 }
5100 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005101 return (status);
5102}
5103
Jeff Johnson295189b2012-06-20 16:38:30 -07005104static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5105{
5106 v_U8_t bACWeights[WLANTL_MAX_AC];
5107 v_U8_t paramBk, paramBe, paramVi, paramVo;
5108 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005109 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5110 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5111 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5112 //This doesn't address the case where the lower AC needs a real higher weight
5113 if( pIEs->WMMParams.present )
5114 {
5115 //no change to the lowest ones
5116 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5117 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5118 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5119 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5120 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5121 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5122 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5123 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5124 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5125 {
5126 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5127 fWeightChange = VOS_TRUE;
5128 }
5129 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5130 {
5131 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5132 fWeightChange = VOS_TRUE;
5133 }
5134 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5135 {
5136 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5137 fWeightChange = VOS_TRUE;
5138 }
5139 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5140 {
5141 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5142 fWeightChange = VOS_TRUE;
5143 }
5144 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5145 {
5146 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5147 fWeightChange = VOS_TRUE;
5148 }
5149 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5150 {
5151 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5152 fWeightChange = VOS_TRUE;
5153 }
5154 if(fWeightChange)
5155 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005156 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005157 bACWeights[2], bACWeights[3]);
5158 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5159 }
5160 }
5161}
Jeff Johnson295189b2012-06-20 16:38:30 -07005162#ifdef WLAN_FEATURE_VOWIFI_11R
5163//Returns whether the current association is a 11r assoc or not
5164tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5165{
5166#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5167 return csrNeighborRoamIs11rAssoc(pMac);
5168#else
5169 return eANI_BOOLEAN_FALSE;
5170#endif
5171}
5172#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005173#ifdef FEATURE_WLAN_ESE
5174//Returns whether the current association is a ESE assoc or not
5175tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005176{
5177#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005178 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005179#else
5180 return eANI_BOOLEAN_FALSE;
5181#endif
5182}
5183#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005184#ifdef FEATURE_WLAN_LFR
5185//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305186tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005187{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305188 tCsrRoamSession *pSession = NULL;
5189
5190 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5191 {
5192 pSession = CSR_GET_SESSION( pMac, sessionId );
5193 if (NULL != pSession->pCurRoamProfile)
5194 {
5195 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5196 {
5197 return eANI_BOOLEAN_FALSE;
5198 }
5199 }
5200 }
5201
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005202#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5203 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5204 {
5205 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5206 }
5207 else
5208#endif
5209 {
5210 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005211 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005212 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005213}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005214
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005215#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005216/* ---------------------------------------------------------------------------
5217
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005218 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005219
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005220 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005221
5222 \param pMac - The handle returned by macOpen.
5223
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005224 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005225
5226---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005227tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005228{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005229 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005230}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005231#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005232
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005233#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5234//Returns whether "FW based BG scan" is currently enabled...or not
5235tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5236{
5237 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5238}
5239#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005240#endif
5241
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005242#if defined(FEATURE_WLAN_ESE)
5243tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005244{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005245 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005246}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005247#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005248
Jeff Johnson295189b2012-06-20 16:38:30 -07005249//Return true means the command can be release, else not
5250static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5251 eCsrRoamCompleteResult Result, void *Context )
5252{
5253 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5254 tSirBssDescription *pSirBssDesc = NULL;
5255 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5256 tCsrScanResult *pScanResult = NULL;
5257 tCsrRoamInfo roamInfo;
5258 sme_QosAssocInfo assocInfo;
5259 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5260 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5261 tDot11fBeaconIEs *pIes = NULL;
5262 tANI_U32 sessionId = pCommand->sessionId;
5263 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5264 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5265 eRoamCmdStatus roamStatus;
5266 eCsrRoamResult roamResult;
5267 eHalStatus status;
5268 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005270
Jeff Johnson32d95a32012-09-10 13:15:23 -07005271 if(!pSession)
5272 {
5273 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5274 return eANI_BOOLEAN_FALSE;
5275 }
5276
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005277 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 switch( Result )
5279 {
5280 case eCsrJoinSuccess:
5281 // reset the IDLE timer
5282 // !!
5283 // !! fall through to the next CASE statement here is intentional !!
5284 // !!
5285 case eCsrReassocSuccess:
5286 if(eCsrReassocSuccess == Result)
5287 {
5288 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5289 }
5290 else
5291 {
5292 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5293 }
5294 // Success Join Response from LIM. Tell NDIS we are connected and save the
5295 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005296 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305297 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005298 //always free the memory here
5299 if(pSession->pWpaRsnRspIE)
5300 {
5301 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305302 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005303 pSession->pWpaRsnRspIE = NULL;
5304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005305#ifdef FEATURE_WLAN_WAPI
5306 if(pSession->pWapiRspIE)
5307 {
5308 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305309 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005310 pSession->pWapiRspIE = NULL;
5311 }
5312#endif /* FEATURE_WLAN_WAPI */
5313#ifdef FEATURE_WLAN_BTAMP_UT_RF
5314 //Reset counter so no join retry is needed.
5315 pSession->maxRetryCount = 0;
5316 csrRoamStopJoinRetryTimer(pMac, sessionId);
5317#endif
5318 /* This creates problem since we have not saved the connected profile.
5319 So moving this after saving the profile
5320 */
5321 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305322
5323 /* Reset remainInPowerActiveTillDHCP as it might have been set
5324 * by last failed secured connection.
5325 * It should be set only for secured connection.
5326 */
5327 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005328 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5329 {
5330 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5331 }
5332 else
5333 {
5334 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5335 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005336 //Use the last connected bssdesc for reassoc-ing to the same AP.
5337 //NOTE: What to do when reassoc to a different AP???
5338 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5339 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5340 {
5341 pSirBssDesc = pSession->pConnectBssDesc;
5342 if(pSirBssDesc)
5343 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305344 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5345 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005346 }
5347 }
5348 else
5349 {
5350
5351 if(pCommand->u.roamCmd.pRoamBssEntry)
5352 {
5353 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5354 if(pScanResult != NULL)
5355 {
5356 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5357 //this can be NULL
5358 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305359 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5360 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005361 }
5362 }
5363 }
5364 if( pSirBssDesc )
5365 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005367 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5368 //Save WPA/RSN IE
5369 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005370#ifdef FEATURE_WLAN_ESE
5371 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005372#endif
5373
5374 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5375 // substate change.
5376 // Moving even save profile above so that below mentioned conditon is also met.
5377 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5378 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005379 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5380 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5381 // will be dropped for the security context may not be set properly.
5382 //
5383 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5384 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5385 //
5386 // this reordering was done on titan_prod_usb branch and is being replicated here.
5387 //
5388
5389 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5390 !pProfile->bWPSAssociation)
5391 {
5392 // Issue the set Context request to LIM to establish the Unicast STA context
5393 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5394 pProfile->negotiatedUCEncryptionType,
5395 pSirBssDesc, &(pSirBssDesc->bssId),
5396 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5397 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005398 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5400 }
5401 // Issue the set Context request to LIM to establish the Broadcast STA context
5402 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5403 pSirBssDesc, &BroadcastMac,
5404 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5405 }
5406 else
5407 {
5408 //Need to wait for supplicant authtication
5409 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005410 //Set the subestate to WaitForKey in case authentiation is needed
5411 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5412
Jeff Johnson295189b2012-06-20 16:38:30 -07005413 if(pProfile->bWPSAssociation)
5414 {
5415 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5416 }
5417 else
5418 {
5419 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5420 }
5421
5422 //Save sessionId in case of timeout
5423 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5424 //This time should be long enough for the rest of the process plus setting key
5425 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5426 {
5427 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005428 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005429 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5430 }
5431 }
5432
5433 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5434 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 if(Context)
5436 {
5437 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5438 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5440 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5441#ifdef WLAN_FEATURE_VOWIFI_11R
5442 len += pJoinRsp->parsedRicRspLen;
5443#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005444#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005445 len += pJoinRsp->tspecIeLen;
5446#endif
5447 if(len)
5448 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305449 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5450 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305452 vos_mem_copy(pSession->connectedInfo.pbFrames,
5453 pJoinRsp->frames, len);
5454 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5455 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5456 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005457#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305458 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005459#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005460#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305461 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005462#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305463 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5464 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5465 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5466 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 }
5468 }
5469 if(pCommand->u.roamCmd.fReassoc)
5470 {
5471 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5472 }
5473 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5474 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5475 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5476 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305477 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 }
5479 else
5480 {
5481 if(pCommand->u.roamCmd.fReassoc)
5482 {
5483 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5484 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5485 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5486 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5487 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5488 }
5489 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305490 /* Update the staId from the previous connected profile info
5491 as the reassociation is triggred at SME/HDD */
5492 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5493 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5494 {
5495 roamInfo.staId = pSession->connectedInfo.staId;
5496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005497#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5498 // Indicate SME-QOS with reassoc success event, only after
5499 // copying the frames
5500 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5501#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 roamInfo.pBssDesc = pSirBssDesc;
5503 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5504 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5505#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5506 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5507#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5508 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5510 //It may be better to let QoS do this????
5511 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5512 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005513 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5515 pmcStartUapsd( pMac, NULL, NULL );
5516 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305517 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5519 if( pSession->bRefAssocStartCnt > 0 )
5520 {
5521 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005522 //Remove this code once SLM_Sessionization is supported
5523 //BMPS_WORKAROUND_NOT_NEEDED
5524 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005525 {
5526 pMac->roam.configParam.doBMPSWorkaround = 1;
5527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005528 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5529 }
5530
5531 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 // reset the PMKID candidate list
5533 csrResetPMKIDCandidateList( pMac, sessionId );
5534 //Update TL's AC weight base on the current EDCA parameters
5535 //These parameters may change in the course of the connection, that sictuation
5536 //is not taken care here. This change is mainly to address a WIFI WMM test where
5537 //BE has a equal or higher TX priority than VI.
5538 //We only do this for infra link
5539 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5540 {
5541 csrCheckAndUpdateACWeight(pMac, pIes);
5542 }
5543#ifdef FEATURE_WLAN_WAPI
5544 // reset the BKID candidate list
5545 csrResetBKIDCandidateList( pMac, sessionId );
5546#endif /* FEATURE_WLAN_WAPI */
5547 }
5548 else
5549 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005550 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 csrScanCancelIdleScan(pMac);
5553 //Not to signal link up because keys are yet to be set.
5554 //The linkup function will overwrite the sub-state that we need to keep at this point.
5555 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5556 {
5557 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5558 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005559 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5560 //enough to let security and DHCP handshake succeed before entry into BMPS
5561 if (pmcShouldBmpsTimerRun(pMac))
5562 {
Abhishek Singh65d939e2014-04-25 13:33:07 +05305563 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5564 * until keys are set before going into BMPS.
5565 */
5566 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5567 {
5568 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5569 smsLog(pMac, LOG1, FL("Set remainInPowerActiveTillDHCP "
5570 "to make sure we wait until keys are set before"
5571 " going to BMPS"));
5572 }
5573
Jeff Johnson295189b2012-06-20 16:38:30 -07005574 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5575 != eHAL_STATUS_SUCCESS)
5576 {
5577 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5578 }
5579 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5580 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005581 break;
5582
Jeff Johnson295189b2012-06-20 16:38:30 -07005583 case eCsrStartBssSuccess:
5584 // on the StartBss Response, LIM is returning the Bss Description that we
5585 // are beaconing. Add this Bss Description to our scan results and
5586 // chain the Profile to this Bss Description. On a Start BSS, there was no
5587 // detected Bss description (no partner) so we issued the Start Bss to
5588 // start the Ibss without any Bss description. Lim was kind enough to return
5589 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005590 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005591 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005592 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305593 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005594 if( CSR_IS_IBSS( pProfile ) )
5595 {
5596 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5597 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005598 else if (CSR_IS_INFRA_AP(pProfile))
5599 {
5600 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005602 else
5603 {
5604 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5605 }
5606 if( !CSR_IS_WDS_STA( pProfile ) )
5607 {
5608 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005609 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5611 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305612 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005613 roamInfo.pBssDesc = pSirBssDesc;
5614 //We need to associate_complete it first, becasue Associate_start already indicated.
5615 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5616 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5617 break;
5618 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005619 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005621 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 }
5623 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5624 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5625 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5626 if(pSirBssDesc)
5627 {
5628 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305629 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5630 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005631 }
5632 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305633 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005634#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5635 {
5636 vos_log_ibss_pkt_type *pIbssLog;
5637 tANI_U32 bi;
5638
5639 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5640 if(pIbssLog)
5641 {
5642 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5643 {
5644 //We start the IBSS (didn't find any matched IBSS out there)
5645 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5646 }
5647 else
5648 {
5649 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5650 }
5651 if(pSirBssDesc)
5652 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305653 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5655 }
5656 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5657 {
5658 //***U8 is not enough for beacon interval
5659 pIbssLog->beaconInterval = (v_U8_t)bi;
5660 }
5661 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5662 }
5663 }
5664#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5665 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5666 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5668 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5670 csrRoamIssueSetContextReq( pMac, sessionId,
5671 pProfile->negotiatedMCEncryptionType,
5672 pSirBssDesc, &BroadcastMac,
5673 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5674 }
5675 }
5676 else
5677 {
5678 //Keep the state to eCSR_ROAMING_STATE_JOINING
5679 //Need to send join_req.
5680 if(pCommand->u.roamCmd.pRoamBssEntry)
5681 {
5682 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5683 {
5684 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5685 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5686 // Set the roaming substate to 'join attempt'...
5687 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005688 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 }
5690 }
5691 else
5692 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005693 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 VOS_ASSERT( 0 );
5695 }
5696 }
5697 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5698 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5699 //trigger the connection start indication in Vista
5700 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5701 {
5702 roamStatus = eCSR_ROAM_IBSS_IND;
5703 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5704 if( CSR_IS_WDS( pProfile ) )
5705 {
5706 roamStatus = eCSR_ROAM_WDS_IND;
5707 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 if( CSR_IS_INFRA_AP( pProfile ) )
5710 {
5711 roamStatus = eCSR_ROAM_INFRA_IND;
5712 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005714
5715 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5716 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5717 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305718 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5720 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005721 //We start the IBSS (didn't find any matched IBSS out there)
5722 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305724 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5725 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005726 //Remove this code once SLM_Sessionization is supported
5727 //BMPS_WORKAROUND_NOT_NEEDED
5728 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005729 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005730 {
5731 pMac->roam.configParam.doBMPSWorkaround = 1;
5732 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005733
Jeff Johnson295189b2012-06-20 16:38:30 -07005734 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5735 }
5736
5737 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005738
5739 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005740 {
5741 //need to send stop BSS because we fail to send join_req
5742 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5743 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5744 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5745 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005746 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005747 case eCsrStartBssFailure:
5748#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5749 {
5750 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005751 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5752 if(pIbssLog)
5753 {
5754 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5755 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5756 }
5757 }
5758#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 roamStatus = eCSR_ROAM_IBSS_IND;
5760 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5761 if( CSR_IS_WDS( pProfile ) )
5762 {
5763 roamStatus = eCSR_ROAM_WDS_IND;
5764 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5765 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 if( CSR_IS_INFRA_AP( pProfile ) )
5767 {
5768 roamStatus = eCSR_ROAM_INFRA_IND;
5769 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 if(Context)
5772 {
5773 pSirBssDesc = (tSirBssDescription *)Context;
5774 }
5775 else
5776 {
5777 pSirBssDesc = NULL;
5778 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305779 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 roamInfo.pBssDesc = pSirBssDesc;
5781 //We need to associate_complete it first, becasue Associate_start already indicated.
5782 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5783 csrSetDefaultDot11Mode( pMac );
5784 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 case eCsrSilentlyStopRoaming:
5786 // We are here because we try to start the same IBSS
5787 //No message to PE
5788 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005789 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005790 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5791 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305792 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005793 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5794 if( roamInfo.pBssDesc )
5795 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305796 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5797 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005798 }
5799 //Since there is no change in the current state, simply pass back no result otherwise
5800 //HDD may be mistakenly mark to disconnected state.
5801 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5802 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005803 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 case eCsrSilentlyStopRoamingSaveState:
5805 //We are here because we try to connect to the same AP
5806 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005807 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305808 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005809
5810 //to aviod resetting the substate to NONE
5811 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5812 //No need to change substate to wai_for_key because there is no state change
5813 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5814 if( roamInfo.pBssDesc )
5815 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305816 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5817 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5820 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5821 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5822 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5823 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5824 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5825 roamInfo.staId = pSession->connectedInfo.staId;
5826 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005827 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005828 pSession->bRefAssocStartCnt--;
5829 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5830 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5831 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5832 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005833 case eCsrReassocFailure:
5834#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5835 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5836#endif
5837 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005838 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 csrFreeConnectBssDesc(pMac, sessionId);
5840 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5841 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305842 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005843 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5844 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5845 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5846 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5847 eCSR_ROAM_WDS_IND,
5848 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5849 //Need to issue stop_bss
5850 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005851 case eCsrJoinFailure:
5852 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005853 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005854 default:
5855 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005856 smsLog(pMac, LOGW, FL("receives no association indication"));
5857 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005858 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5860 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5861 {
5862 //do not free for the other profiles as we need to send down stop BSS later
5863 csrFreeConnectBssDesc(pMac, sessionId);
5864 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5865 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5866 csrSetDefaultDot11Mode( pMac );
5867 }
5868
5869 switch( pCommand->u.roamCmd.roamReason )
5870 {
5871 // If this transition is because of an 802.11 OID, then we transition
5872 // back to INIT state so we sit waiting for more OIDs to be issued and
5873 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005874 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005875 case eCsrSmeIssuedAssocToSimilarAP:
5876 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005877 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305879 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005880 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5881 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5882 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305883 vos_mem_copy(&roamInfo.bssid,
5884 &pSession->joinFailStatusCode.bssId,
5885 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005886
Jeff Johnson295189b2012-06-20 16:38:30 -07005887 /* Defeaturize this later if needed */
5888#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5889 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5890 if (csrRoamIsHandoffInProgress(pMac))
5891 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005892 /* Should indicate neighbor roam algorithm about the connect failure here */
5893 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5894 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005895#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005896 if(pSession->bRefAssocStartCnt > 0)
5897 {
5898 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005899 if(eCsrJoinFailureDueToConcurrency == Result)
5900 {
5901 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5902 eCSR_ROAM_ASSOCIATION_COMPLETION,
5903 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5904 }
5905 else
5906 {
5907 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 eCSR_ROAM_ASSOCIATION_COMPLETION,
5909 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005910 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005911 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005912 else
5913 {
5914 /* bRefAssocStartCnt is not incremented when
5915 * eRoamState == eCsrStopRoamingDueToConcurrency
5916 * in csrRoamJoinNextBss API. so handle this in
5917 * else case by sending assoc failure
5918 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005919 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005920 pCommand->u.scanCmd.roamId,
5921 eCSR_ROAM_ASSOCIATION_FAILURE,
5922 eCSR_ROAM_RESULT_FAILURE);
5923 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005924 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005925#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05305926 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5928#endif
5929 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5930 csrScanStartIdleScan(pMac);
5931#ifdef FEATURE_WLAN_BTAMP_UT_RF
5932 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5933 //BT activity and not able to recevie WLAN traffic. Retry the join
5934 if( CSR_IS_WDS_STA(pProfile) )
5935 {
5936 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5937 }
5938#endif
5939 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 case eCsrHddIssuedReassocToSameAP:
5941 case eCsrSmeIssuedReassocToSameAP:
5942 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5943
5944 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5945#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5946 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5947#endif
5948 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5949 csrScanStartIdleScan(pMac);
5950 break;
5951 case eCsrForcedDisassoc:
5952 case eCsrForcedDeauth:
5953 case eCsrSmeIssuedIbssJoinFailure:
5954 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5955
5956 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5957 {
5958 // Notify HDD that IBSS join failed
5959 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5960 }
5961 else
5962 {
5963 csrRoamCallCallback(pMac, sessionId, NULL,
5964 pCommand->u.roamCmd.roamId,
5965 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5966 }
5967#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5968 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5969#endif
5970 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08005971 /*
5972 *DelSta not done FW still in conneced state so dont
5973 *issue IMPS req
5974 */
5975 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
5976 {
5977 smsLog(pMac, LOGW, FL("FW still in connected state "));
5978 break;
5979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 csrScanStartIdleScan(pMac);
5981 break;
5982 case eCsrForcedIbssLeave:
5983 csrRoamCallCallback(pMac, sessionId, NULL,
5984 pCommand->u.roamCmd.roamId,
5985 eCSR_ROAM_IBSS_LEAVE,
5986 eCSR_ROAM_RESULT_IBSS_STOP);
5987 break;
5988 case eCsrForcedDisassocMICFailure:
5989 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5990
5991 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5992#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5993 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5994#endif
5995 csrScanStartIdleScan(pMac);
5996 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 case eCsrStopBss:
5998 csrRoamCallCallback(pMac, sessionId, NULL,
5999 pCommand->u.roamCmd.roamId,
6000 eCSR_ROAM_INFRA_IND,
6001 eCSR_ROAM_RESULT_INFRA_STOPPED);
6002 break;
6003 case eCsrForcedDisassocSta:
6004 case eCsrForcedDeauthSta:
6005 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
6006 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
6007 {
6008 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006009
6010 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6011 {
6012 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05306013 vos_mem_copy(roamInfo.peerMac,
6014 pCommand->u.roamCmd.peerMac,
6015 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07006016 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6017 roamInfo.statusCode = eSIR_SME_SUCCESS;
6018 status = csrRoamCallCallback(pMac, sessionId,
6019 &roamInfo, pCommand->u.roamCmd.roamId,
6020 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
6021 }
6022 }
6023 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 case eCsrLostLink1:
6025 // if lost link roam1 failed, then issue lost link Scan2 ...
6026 csrScanRequestLostLink2(pMac, sessionId);
6027 break;
6028 case eCsrLostLink2:
6029 // if lost link roam2 failed, then issue lost link scan3 ...
6030 csrScanRequestLostLink3(pMac, sessionId);
6031 break;
6032 case eCsrLostLink3:
6033 default:
6034 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6035
6036 //We are done with one round of lostlink roaming here
6037 csrScanHandleFailedLostlink3(pMac, sessionId);
6038 break;
6039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 break;
6041 }
6042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006043 return ( fReleaseCommand );
6044}
6045
Jeff Johnson295189b2012-06-20 16:38:30 -07006046eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6047{
6048 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006049 return (status);
6050}
6051
Jeff Johnson295189b2012-06-20 16:38:30 -07006052eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6053{
6054 eHalStatus status = eHAL_STATUS_SUCCESS;
6055 tANI_U32 size = 0;
6056
6057 do
6058 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306059 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006060 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6061 {
6062 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306063 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6064 if ( NULL == pDstProfile->BSSIDs.bssid )
6065 status = eHAL_STATUS_FAILURE;
6066 else
6067 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006068 if(!HAL_STATUS_SUCCESS(status))
6069 {
6070 break;
6071 }
6072 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306073 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6074 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006075 }
6076 if(pSrcProfile->SSIDs.numOfSSIDs)
6077 {
6078 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306079 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6080 if ( NULL == pDstProfile->SSIDs.SSIDList )
6081 status = eHAL_STATUS_FAILURE;
6082 else
6083 status = eHAL_STATUS_SUCCESS;
6084 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006085 {
6086 break;
6087 }
6088 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306089 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6090 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 }
6092 if(pSrcProfile->nWPAReqIELength)
6093 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306094 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6095 if ( NULL == pDstProfile->pWPAReqIE )
6096 status = eHAL_STATUS_FAILURE;
6097 else
6098 status = eHAL_STATUS_SUCCESS;
6099
6100 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006101 {
6102 break;
6103 }
6104 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306105 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6106 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 }
6108 if(pSrcProfile->nRSNReqIELength)
6109 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306110 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6111 if ( NULL == pDstProfile->pRSNReqIE )
6112 status = eHAL_STATUS_FAILURE;
6113 else
6114 status = eHAL_STATUS_SUCCESS;
6115
6116 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 {
6118 break;
6119 }
6120 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306121 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6122 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006123 }
6124#ifdef FEATURE_WLAN_WAPI
6125 if(pSrcProfile->nWAPIReqIELength)
6126 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306127 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6128 if ( NULL == pDstProfile->pWAPIReqIE )
6129 status = eHAL_STATUS_FAILURE;
6130 else
6131 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006132 if(!HAL_STATUS_SUCCESS(status))
6133 {
6134 break;
6135 }
6136 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306137 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6138 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006139 }
6140#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006141 if(pSrcProfile->nAddIEScanLength)
6142 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306143 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6144 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306146 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306147 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306148 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6149 }
6150 else
6151 {
6152 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6153 FL(" AddIEScanLength is not valid %u"),
6154 pSrcProfile->nAddIEScanLength);
6155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 if(pSrcProfile->nAddIEAssocLength)
6158 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306159 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6160 if ( NULL == pDstProfile->pAddIEAssoc )
6161 status = eHAL_STATUS_FAILURE;
6162 else
6163 status = eHAL_STATUS_SUCCESS;
6164
Jeff Johnson295189b2012-06-20 16:38:30 -07006165 if(!HAL_STATUS_SUCCESS(status))
6166 {
6167 break;
6168 }
6169 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306170 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6171 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006172 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 if(pSrcProfile->ChannelInfo.ChannelList)
6174 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306175 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6176 pSrcProfile->ChannelInfo.numOfChannels);
6177 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6178 status = eHAL_STATUS_FAILURE;
6179 else
6180 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 if(!HAL_STATUS_SUCCESS(status))
6182 {
6183 break;
6184 }
6185 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306186 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6187 pSrcProfile->ChannelInfo.ChannelList,
6188 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 pDstProfile->AuthType = pSrcProfile->AuthType;
6191 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6192 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6193 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6194 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6195 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006196#ifdef WLAN_FEATURE_11W
6197 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6198 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6199 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6200#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 pDstProfile->BSSType = pSrcProfile->BSSType;
6202 pDstProfile->phyMode = pSrcProfile->phyMode;
6203 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6204
6205#ifdef FEATURE_WLAN_WAPI
6206 if(csrIsProfileWapi(pSrcProfile))
6207 {
6208 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6209 {
6210 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6211 }
6212 }
6213#endif /* FEATURE_WLAN_WAPI */
6214 pDstProfile->CBMode = pSrcProfile->CBMode;
6215 /*Save the WPS info*/
6216 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006217 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006218 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006219 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 pDstProfile->privacy = pSrcProfile->privacy;
6221 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6222 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6223 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6224 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6225 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6226 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6227 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6228 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6229 pDstProfile->wps_state = pSrcProfile->wps_state;
6230 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306231 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6232 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006233#ifdef WLAN_FEATURE_VOWIFI_11R
6234 if (pSrcProfile->MDID.mdiePresent)
6235 {
6236 pDstProfile->MDID.mdiePresent = 1;
6237 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6238 }
6239#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 }while(0);
6241
6242 if(!HAL_STATUS_SUCCESS(status))
6243 {
6244 csrReleaseProfile(pMac, pDstProfile);
6245 pDstProfile = NULL;
6246 }
6247
6248 return (status);
6249}
Jeff Johnson295189b2012-06-20 16:38:30 -07006250eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6251{
6252 eHalStatus status = eHAL_STATUS_SUCCESS;
6253 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6254 do
6255 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306256 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 if(pSrcProfile->bssid)
6258 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306259 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6260 if ( NULL == pDstProfile->BSSIDs.bssid )
6261 status = eHAL_STATUS_FAILURE;
6262 else
6263 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 if(!HAL_STATUS_SUCCESS(status))
6265 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306266 smsLog( pMac, LOGE,
6267 FL("failed to allocate memory for BSSID"
6268 "%02x:%02x:%02x:%02x:%02x:%02x"),
6269 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6270 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 break;
6272 }
6273 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306274 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6275 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006276 }
6277 if(pSrcProfile->SSID.ssId)
6278 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306279 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6280 if ( NULL == pDstProfile->SSIDs.SSIDList )
6281 status = eHAL_STATUS_FAILURE;
6282 else
6283 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006284 if(!HAL_STATUS_SUCCESS(status))
6285 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306286 smsLog( pMac, LOGE,
6287 FL("failed to allocate memory for SSIDList"
6288 "%02x:%02x:%02x:%02x:%02x:%02x"),
6289 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6290 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 break;
6292 }
6293 pDstProfile->SSIDs.numOfSSIDs = 1;
6294 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6295 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306296 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6297 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006298 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006299 if(pSrcProfile->nAddIEAssocLength)
6300 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306301 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6302 if ( NULL == pDstProfile->pAddIEAssoc)
6303 status = eHAL_STATUS_FAILURE;
6304 else
6305 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006306 if(!HAL_STATUS_SUCCESS(status))
6307 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006308 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006309 break;
6310 }
6311 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306312 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6313 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006314 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306315 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6316 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6317 status = eHAL_STATUS_FAILURE;
6318 else
6319 status = eHAL_STATUS_SUCCESS;
6320
Jeff Johnson295189b2012-06-20 16:38:30 -07006321 if(!HAL_STATUS_SUCCESS(status))
6322 {
6323 break;
6324 }
6325 pDstProfile->ChannelInfo.numOfChannels = 1;
6326 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006327 pDstProfile->AuthType.numEntries = 1;
6328 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6329 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6330 pDstProfile->EncryptionType.numEntries = 1;
6331 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6332 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6333 pDstProfile->mcEncryptionType.numEntries = 1;
6334 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6335 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6336 pDstProfile->BSSType = pSrcProfile->BSSType;
6337 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306338 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6339 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006340#ifdef WLAN_FEATURE_VOWIFI_11R
6341 if (pSrcProfile->MDID.mdiePresent)
6342 {
6343 pDstProfile->MDID.mdiePresent = 1;
6344 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6345 }
6346#endif
6347
6348 }while(0);
6349
6350 if(!HAL_STATUS_SUCCESS(status))
6351 {
6352 csrReleaseProfile(pMac, pDstProfile);
6353 pDstProfile = NULL;
6354 }
6355
6356 return (status);
6357}
6358
Jeff Johnson295189b2012-06-20 16:38:30 -07006359eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6360 tScanResultHandle hBSSList,
6361 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6362 tANI_BOOLEAN fClearScan)
6363{
6364 eHalStatus status = eHAL_STATUS_SUCCESS;
6365 tSmeCmd *pCommand;
6366
6367 pCommand = csrGetCommandBuffer(pMac);
6368 if(NULL == pCommand)
6369 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006370 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 status = eHAL_STATUS_RESOURCES;
6372 }
6373 else
6374 {
6375 if( fClearScan )
6376 {
6377 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306378 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006379 }
6380 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6381 if(NULL == pProfile)
6382 {
6383 //We can roam now
6384 //Since pProfile is NULL, we need to build our own profile, set everything to default
6385 //We can only support open and no encryption
6386 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6387 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6388 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6389 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6390 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6391 }
6392 else
6393 {
6394 //make a copy of the profile
6395 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6396 if(HAL_STATUS_SUCCESS(status))
6397 {
6398 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6399 }
6400 }
6401 pCommand->command = eSmeCommandRoam;
6402 pCommand->sessionId = (tANI_U8)sessionId;
6403 pCommand->u.roamCmd.hBSSList = hBSSList;
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 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6408 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006409 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6410 FL("CSR PERSONA=%d"),
6411 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006412 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6413 if( !HAL_STATUS_SUCCESS( status ) )
6414 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006415 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006416 csrReleaseCommandRoam( pMac, pCommand );
6417 }
6418 }
6419
6420 return (status);
6421}
Jeff Johnson295189b2012-06-20 16:38:30 -07006422eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6423 tCsrRoamModifyProfileFields *pMmodProfileFields,
6424 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6425{
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") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006433 status = eHAL_STATUS_RESOURCES;
6434 }
6435 else
6436 {
6437 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306438 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006439 if(pProfile)
6440 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 //This is likely trying to reassoc to different profile
6442 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6443 //make a copy of the profile
6444 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6445 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006446 }
6447 else
6448 {
6449 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6450 //how to update WPA/WPA2 info in roamProfile??
6451 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006452 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006453 if(HAL_STATUS_SUCCESS(status))
6454 {
6455 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6456 }
6457 pCommand->command = eSmeCommandRoam;
6458 pCommand->sessionId = (tANI_U8)sessionId;
6459 pCommand->u.roamCmd.roamId = roamId;
6460 pCommand->u.roamCmd.roamReason = reason;
6461 //We need to free the BssList when the command is done
6462 //For reassoc there is no BSS list, so the boolean set to false
6463 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6464 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6465 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006466 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6467 if( !HAL_STATUS_SUCCESS( status ) )
6468 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006469 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006470 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6471 csrReleaseCommandRoam( pMac, pCommand );
6472 }
6473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006474 return (status);
6475}
6476
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006477eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6478 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306479// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006480{
6481 eHalStatus status = eHAL_STATUS_SUCCESS;
6482 tSmeCmd *pCommand;
6483
6484 pCommand = csrGetCommandBuffer(pMac);
6485 if(NULL == pCommand)
6486 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006487 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006488 status = eHAL_STATUS_RESOURCES;
6489 }
6490 else
6491 {
6492 if(pBssDescription)
6493 {
6494 //copy over the parameters we need later
6495 pCommand->command = eSmeCommandRoam;
6496 pCommand->sessionId = (tANI_U8)sessionId;
6497 pCommand->u.roamCmd.roamReason = reason;
6498 //this is the important parameter
6499 //in this case we are using this field for the "next" BSS
6500 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6501 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6502 if( !HAL_STATUS_SUCCESS( status ) )
6503 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006504 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006505 csrReleaseCommandPreauth( pMac, pCommand );
6506 }
6507 }
6508 else
6509 {
6510 //Return failure
6511 status = eHAL_STATUS_RESOURCES;
6512 }
6513 }
6514 return (status);
6515}
6516
6517eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6518{
6519 tListElem *pEntry;
6520 tSmeCmd *pCommand;
6521 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6522 if ( pEntry )
6523 {
6524 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6525 if ( (eSmeCommandRoam == pCommand->command) &&
6526 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6527 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006528 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006529 pCommand->command, pCommand->u.roamCmd.roamReason);
6530 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6531 csrReleaseCommandPreauth( pMac, pCommand );
6532 }
6533 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006534 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006535 pCommand->command, pCommand->u.roamCmd.roamReason);
6536 }
6537 }
6538 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006539 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006540 }
6541 smeProcessPendingQueue( pMac );
6542 return eHAL_STATUS_SUCCESS;
6543}
6544
Jeff Johnson295189b2012-06-20 16:38:30 -07006545eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6546 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6547{
6548 eHalStatus status = eHAL_STATUS_FAILURE;
6549 tScanResultHandle hBSSList;
6550 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006551 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6552 if(HAL_STATUS_SUCCESS(status))
6553 {
6554 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6555 if(pRoamId)
6556 {
6557 *pRoamId = roamId;
6558 }
6559 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6560 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6561 if(!HAL_STATUS_SUCCESS(status))
6562 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006563 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006564 csrScanResultPurge(pMac, hBSSList);
6565 }
6566 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006567 return (status);
6568}
6569
Jeff Johnson295189b2012-06-20 16:38:30 -07006570eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6571 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6572{
6573 eHalStatus status = eHAL_STATUS_SUCCESS;
6574 tScanResultHandle hBSSList;
6575 tCsrScanResultFilter *pScanFilter;
6576 tANI_U32 roamId = 0;
6577 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6578 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006579 if (NULL == pProfile)
6580 {
6581 smsLog(pMac, LOGP, FL("No profile specified"));
6582 return eHAL_STATUS_FAILURE;
6583 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306584 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6585 "encryType = %d"),
6586 lim_BssTypetoString(pProfile->BSSType),
6587 pProfile->BSSType,
6588 pProfile->AuthType.authType[0],
6589 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006590 if( CSR_IS_WDS( pProfile ) &&
6591 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6592 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006593 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006594 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006595 return status;
6596 }
6597 csrRoamCancelRoaming(pMac, sessionId);
6598 csrScanRemoveFreshScanCommand(pMac, sessionId);
6599 csrScanCancelIdleScan(pMac);
6600 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306601 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306602
6603 if (!vos_concurrent_open_sessions_running() &&
6604 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306606 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07006607 csrScanDisable(pMac);
6608 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306609
Jeff Johnson295189b2012-06-20 16:38:30 -07006610 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6611 //Check whether ssid changes
6612 if(csrIsConnStateConnected(pMac, sessionId))
6613 {
6614 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6615 {
6616 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6617 }
6618 }
6619#ifdef FEATURE_WLAN_BTAMP_UT_RF
6620 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6621#endif
6622 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6623 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006624 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006625 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6626 if(pRoamId)
6627 {
6628 roamId = *pRoamId;
6629 }
6630 if(!HAL_STATUS_SUCCESS(status))
6631 {
6632 fCallCallback = eANI_BOOLEAN_TRUE;
6633 }
6634 }
6635 else
6636 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306637 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6638 if ( NULL == pScanFilter )
6639 status = eHAL_STATUS_FAILURE;
6640 else
6641 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 if(HAL_STATUS_SUCCESS(status))
6643 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306644 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 //Try to connect to any BSS
6646 if(NULL == pProfile)
6647 {
6648 //No encryption
6649 pScanFilter->EncryptionType.numEntries = 1;
6650 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6651 }//we don't have a profile
6652 else
6653 {
6654 //Here is the profile we need to connect to
6655 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6656 }//We have a profile
6657 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6658 if(pRoamId)
6659 {
6660 *pRoamId = roamId;
6661 }
6662
6663 if(HAL_STATUS_SUCCESS(status))
6664 {
6665 /*Save the WPS info*/
6666 if(NULL != pProfile)
6667 {
6668 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006669 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006670 }
6671 else
6672 {
6673 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006674 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 do
6677 {
6678 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006680 )
6681 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006682 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006683 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6684 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6685 if(!HAL_STATUS_SUCCESS(status))
6686 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006687 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006688 fCallCallback = eANI_BOOLEAN_TRUE;
6689 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006690 else
6691 {
6692 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6693 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006694 break;
6695 }
6696 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006697 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006698 if(HAL_STATUS_SUCCESS(status))
6699 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006700 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6701 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6702 if(!HAL_STATUS_SUCCESS(status))
6703 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006704 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 csrScanResultPurge(pMac, hBSSList);
6706 fCallCallback = eANI_BOOLEAN_TRUE;
6707 }
6708 }//Have scan result
6709 else if(NULL != pProfile)
6710 {
6711 //Check whether it is for start ibss
6712 if(CSR_IS_START_IBSS(pProfile))
6713 {
6714 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6715 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6716 if(!HAL_STATUS_SUCCESS(status))
6717 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006718 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006719 fCallCallback = eANI_BOOLEAN_TRUE;
6720 }
6721 }
6722 else
6723 {
6724 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006725 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 if(!HAL_STATUS_SUCCESS(status))
6727 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006728 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006729 fCallCallback = eANI_BOOLEAN_TRUE;
6730 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006731 else
6732 {
6733 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006735 }
6736 }
6737 else
6738 {
6739 fCallCallback = eANI_BOOLEAN_TRUE;
6740 }
6741 } while (0);
6742 if(NULL != pProfile)
6743 {
6744 //we need to free memory for filter if profile exists
6745 csrFreeScanFilter(pMac, pScanFilter);
6746 }
6747 }//Got the scan filter from profile
6748
Kiet Lam64c1b492013-07-12 13:56:44 +05306749 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006750 }//allocated memory for pScanFilter
6751 }//No Bsslist coming in
6752 //tell the caller if we fail to trigger a join request
6753 if( fCallCallback )
6754 {
6755 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6756 }
6757
6758 return (status);
6759}
Jeff Johnson295189b2012-06-20 16:38:30 -07006760eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6761 tCsrRoamModifyProfileFields modProfileFields,
6762 tANI_U32 *pRoamId)
6763{
6764 eHalStatus status = eHAL_STATUS_SUCCESS;
6765 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6766 tANI_U32 roamId = 0;
6767 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006768 if (NULL == pProfile)
6769 {
6770 smsLog(pMac, LOGP, FL("No profile specified"));
6771 return eHAL_STATUS_FAILURE;
6772 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306773 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6774 "encryType = %d"),
6775 lim_BssTypetoString(pProfile->BSSType),
6776 pProfile->BSSType,
6777 pProfile->AuthType.authType[0],
6778 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 csrRoamCancelRoaming(pMac, sessionId);
6780 csrScanRemoveFreshScanCommand(pMac, sessionId);
6781 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306782 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006783 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006784 if(csrIsConnStateConnected(pMac, sessionId))
6785 {
6786 if(pProfile)
6787 {
6788 if(pProfile->SSIDs.numOfSSIDs &&
6789 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6790 {
6791 fCallCallback = eANI_BOOLEAN_FALSE;
6792 }
6793 else
6794 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006795 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006796 }
6797 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306798 else if (!vos_mem_compare(&modProfileFields,
6799 &pSession->connectedProfile.modifyProfileFields,
6800 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006801 {
6802 fCallCallback = eANI_BOOLEAN_FALSE;
6803 }
6804 else
6805 {
6806 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006807 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006808 }
6809 }
6810 else
6811 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006812 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006813 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006814 if(!fCallCallback)
6815 {
6816 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6817 if(pRoamId)
6818 {
6819 *pRoamId = roamId;
6820 }
6821
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6823 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006824 }
6825 else
6826 {
6827 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6828 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6829 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006830 return status;
6831}
Jeff Johnson295189b2012-06-20 16:38:30 -07006832eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6833{
6834 eHalStatus status = eHAL_STATUS_FAILURE;
6835 tScanResultHandle hBSSList = NULL;
6836 tCsrScanResultFilter *pScanFilter = NULL;
6837 tANI_U32 roamId;
6838 tCsrRoamProfile *pProfile = NULL;
6839 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006840
6841 if(!pSession)
6842 {
6843 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6844 return eHAL_STATUS_FAILURE;
6845 }
6846
Jeff Johnson295189b2012-06-20 16:38:30 -07006847 do
6848 {
6849 if(pSession->pCurRoamProfile)
6850 {
6851 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306852 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006853 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306854 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6855 if ( NULL == pProfile )
6856 status = eHAL_STATUS_FAILURE;
6857 else
6858 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006859 if(!HAL_STATUS_SUCCESS(status))
6860 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306861 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006862 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306863 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006864 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306865 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6866 if ( NULL == pScanFilter )
6867 status = eHAL_STATUS_FAILURE;
6868 else
6869 status = eHAL_STATUS_SUCCESS;
6870
Jeff Johnson295189b2012-06-20 16:38:30 -07006871 if(!HAL_STATUS_SUCCESS(status))
6872 {
6873 break;
6874 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306875 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006876 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6877 if(!HAL_STATUS_SUCCESS(status))
6878 {
6879 break;
6880 }
6881 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6882 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6883 if(HAL_STATUS_SUCCESS(status))
6884 {
6885 //we want to put the last connected BSS to the very beginning, if possible
6886 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6887 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6888 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6889 if(!HAL_STATUS_SUCCESS(status))
6890 {
6891 csrScanResultPurge(pMac, hBSSList);
6892 break;
6893 }
6894 }
6895 else
6896 {
6897 //Do a scan on this profile
6898 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006899 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006900 if(!HAL_STATUS_SUCCESS(status))
6901 {
6902 break;
6903 }
6904 }
6905 }//We have a profile
6906 else
6907 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006908 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006909 break;
6910 }
6911 }while(0);
6912 if(pScanFilter)
6913 {
6914 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306915 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006916 }
6917 if(NULL != pProfile)
6918 {
6919 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306920 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006921 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006922 return (status);
6923}
Jeff Johnson295189b2012-06-20 16:38:30 -07006924eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6925{
6926 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006927 if(csrIsConnStateConnected(pMac, sessionId))
6928 {
6929 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6930 if(HAL_STATUS_SUCCESS(status))
6931 {
6932 status = csrRoamJoinLastProfile(pMac, sessionId);
6933 }
6934 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 return (status);
6936}
6937
Jeff Johnson295189b2012-06-20 16:38:30 -07006938eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6939{
6940 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006941 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006942 csrRoamCancelRoaming(pMac, sessionId);
6943 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6944 if(csrIsConnStateDisconnected(pMac, sessionId))
6945 {
6946 status = csrRoamJoinLastProfile(pMac, sessionId);
6947 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006948 return (status);
6949}
6950
Jeff Johnson295189b2012-06-20 16:38:30 -07006951eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6952{
6953 eHalStatus status = eHAL_STATUS_SUCCESS;
6954 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6955 eCsrRoamSubState NewSubstate;
6956 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05306957
6958 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6959 {
6960 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
6961 " eCSR_ROAM_SUBSTATE_NONE"));
6962 csrRoamStopWaitForKeyTimer( pMac );
6963 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6964 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006965 // change state to 'Roaming'...
6966 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6967
6968 if ( csrIsConnStateIbss( pMac, sessionId ) )
6969 {
6970 // If we are in an IBSS, then stop the IBSS...
6971 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6972 fComplete = (!HAL_STATUS_SUCCESS(status));
6973 }
6974 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6975 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006976 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 -07006977 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6978 //Restore AC weight in case we change it
6979 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6980 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6981 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6982 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6983 {
6984 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6985 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05306986 else
6987 {
6988 // If we are in neighbor preauth done state then on receiving
6989 // disassoc or deauth we dont roam instead we just disassoc
6990 // from current ap and then go to disconnected state
6991 // This happens for ESE and 11r FT connections ONLY.
6992#ifdef WLAN_FEATURE_VOWIFI_11R
6993 if (csrRoamIs11rAssoc(pMac) &&
6994 (csrNeighborRoamStatePreauthDone(pMac)))
6995 {
6996 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6997 }
6998#endif
6999#ifdef FEATURE_WLAN_ESE
7000 if (csrRoamIsESEAssoc(pMac) &&
7001 (csrNeighborRoamStatePreauthDone(pMac)))
7002 {
7003 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7004 }
7005#endif
7006#ifdef FEATURE_WLAN_LFR
7007 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7008 (csrNeighborRoamStatePreauthDone(pMac)))
7009 {
7010 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7011 }
7012#endif
7013 }
7014
Jeff Johnson295189b2012-06-20 16:38:30 -07007015 if( fDisassoc )
7016 {
7017 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05307018#ifdef DEBUG_ROAM_DELAY
7019 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7020#endif /* DEBUG_ROAM_DELAY */
Jeff Johnson295189b2012-06-20 16:38:30 -07007021 }
7022 else
7023 {
7024 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7025 }
7026 fComplete = (!HAL_STATUS_SUCCESS(status));
7027 }
7028 else if ( csrIsConnStateWds( pMac, sessionId ) )
7029 {
7030 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7031 {
7032 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7033 fComplete = (!HAL_STATUS_SUCCESS(status));
7034 }
7035 //This has to be WDS station
7036 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7037 {
7038
7039 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7040 if( fDisassoc )
7041 {
7042 status = csrRoamIssueDisassociate( pMac, sessionId,
7043 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7044 fComplete = (!HAL_STATUS_SUCCESS(status));
7045 }
7046 }
7047 } else {
7048 // we got a dis-assoc request while not connected to any peer
7049 // just complete the command
7050 fComplete = eANI_BOOLEAN_TRUE;
7051 status = eHAL_STATUS_FAILURE;
7052 }
7053 if(fComplete)
7054 {
7055 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7056 }
7057
7058 if(HAL_STATUS_SUCCESS(status))
7059 {
7060 if ( csrIsConnStateInfra( pMac, sessionId ) )
7061 {
7062 //Set the state to disconnect here
7063 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7064 }
7065 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007066 else
7067 {
7068 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7069 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007070 return (status);
7071}
7072
Jeff Johnson295189b2012-06-20 16:38:30 -07007073/* This is been removed from latest code base */
7074/*
7075static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7076{
7077 eHalStatus status;
7078 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007079 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7080 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007081 return ( status );
7082}
7083*/
7084
Jeff Johnson295189b2012-06-20 16:38:30 -07007085eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7086{
7087 eHalStatus status = eHAL_STATUS_SUCCESS;
7088 tSmeCmd *pCommand;
7089 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007090 do
7091 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08007092 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 pCommand = csrGetCommandBuffer( pMac );
7094 if ( !pCommand )
7095 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007096 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007097 status = eHAL_STATUS_RESOURCES;
7098 break;
7099 }
7100 //Change the substate in case it is wait-for-key
7101 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7102 {
7103 csrRoamStopWaitForKeyTimer( pMac );
7104 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7105 }
7106 pCommand->command = eSmeCommandRoam;
7107 pCommand->sessionId = (tANI_U8)sessionId;
7108 switch ( reason )
7109 {
7110 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7111 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7112 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007113 case eCSR_DISCONNECT_REASON_DEAUTH:
7114 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7115 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007116 case eCSR_DISCONNECT_REASON_HANDOFF:
7117 fHighPriority = eANI_BOOLEAN_TRUE;
7118 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7119 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007120 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7121 case eCSR_DISCONNECT_REASON_DISASSOC:
7122 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7123 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007124 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7125 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7126 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007127 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7128 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7129 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007130 default:
7131 break;
7132 }
7133 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7134 if( !HAL_STATUS_SUCCESS( status ) )
7135 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007136 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007137 csrReleaseCommandRoam( pMac, pCommand );
7138 }
7139 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007140 return( status );
7141}
7142
Jeff Johnson295189b2012-06-20 16:38:30 -07007143eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7144{
7145 eHalStatus status = eHAL_STATUS_SUCCESS;
7146 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007147 pCommand = csrGetCommandBuffer( pMac );
7148 if ( NULL != pCommand )
7149 {
7150 //Change the substate in case it is wait-for-key
7151 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7152 {
7153 csrRoamStopWaitForKeyTimer( pMac );
7154 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7155 }
7156 pCommand->command = eSmeCommandRoam;
7157 pCommand->sessionId = (tANI_U8)sessionId;
7158 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7159 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7160 if( !HAL_STATUS_SUCCESS( status ) )
7161 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007162 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007163 csrReleaseCommandRoam( pMac, pCommand );
7164 }
7165 }
7166 else
7167 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007168 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007169 status = eHAL_STATUS_RESOURCES;
7170 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007171 return ( status );
7172}
7173
Jeff Johnson295189b2012-06-20 16:38:30 -07007174eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7175{
7176 eHalStatus status = eHAL_STATUS_SUCCESS;
7177 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007178
7179 if(!pSession)
7180 {
7181 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7182 return eHAL_STATUS_FAILURE;
7183 }
7184
Jeff Johnson295189b2012-06-20 16:38:30 -07007185#ifdef FEATURE_WLAN_BTAMP_UT_RF
7186 //Stop te retry
7187 pSession->maxRetryCount = 0;
7188 csrRoamStopJoinRetryTimer(pMac, sessionId);
7189#endif
7190 //Not to call cancel roaming here
7191 //Only issue disconnect when necessary
7192 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7193 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7194 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7195
7196 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007197 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007198 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7199 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307200 else
7201 {
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307202 csrScanAbortScanForSSID(pMac, sessionId);
7203 status = eHAL_STATUS_CMD_NOT_QUEUED;
7204 smsLog( pMac, LOG1, FL(" Disconnect cmd not queued, Roam command is not present"
7205 " return with status %d"), status);
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307206 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007207 return (status);
7208}
7209
Jeff Johnson295189b2012-06-20 16:38:30 -07007210eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7211{
7212 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007213
7214 if(!pSession)
7215 {
7216 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7217 return eHAL_STATUS_FAILURE;
7218 }
7219
Jeff Johnson295189b2012-06-20 16:38:30 -07007220 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7222
7223 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7224}
7225
Jeff Johnson295189b2012-06-20 16:38:30 -07007226eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7227 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7228{
7229 eHalStatus status = eHAL_STATUS_SUCCESS;
7230 tDot11fBeaconIEs *pIesTemp = pIes;
7231 tANI_U8 index;
7232 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7233 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007234
7235 if(!pSession)
7236 {
7237 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7238 return eHAL_STATUS_FAILURE;
7239 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007240 if(pConnectProfile->pAddIEAssoc)
7241 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307242 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007243 pConnectProfile->pAddIEAssoc = NULL;
7244 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307245 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007246 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7247 pConnectProfile->AuthInfo = pProfile->AuthType;
7248 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7249 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7250 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7251 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7252 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7253 pConnectProfile->BSSType = pProfile->BSSType;
7254 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7255 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007256 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307257 if (!pConnectProfile->beaconInterval)
7258 {
7259 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7260 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307261 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007262 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7263 if(pProfile->nAddIEAssocLength)
7264 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307265 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7266 if ( NULL == pConnectProfile->pAddIEAssoc )
7267 status = eHAL_STATUS_FAILURE;
7268 else
7269 status = eHAL_STATUS_SUCCESS;
7270 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007271 {
7272 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7273 return eHAL_STATUS_FAILURE;
7274 }
7275 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307276 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7277 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007278 }
7279
Jeff Johnson295189b2012-06-20 16:38:30 -07007280 //Save bssid
7281 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7282#ifdef WLAN_FEATURE_VOWIFI_11R
7283 if (pSirBssDesc->mdiePresent)
7284 {
7285 pConnectProfile->MDID.mdiePresent = 1;
7286 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7287 }
7288#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007289 if( NULL == pIesTemp )
7290 {
7291 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7292 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007293#ifdef FEATURE_WLAN_ESE
7294 if ((csrIsProfileESE(pProfile) ||
7295 ((pIesTemp->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +05307296 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007297 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007298 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007299 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007300 }
7301#endif
7302 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007303 if(HAL_STATUS_SUCCESS(status))
7304 {
7305 if(pIesTemp->SSID.present)
7306 {
7307 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307308 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7309 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007310 }
7311
7312 //Save the bss desc
7313 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307314
7315 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007316 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307317 //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 -07007318 pConnectProfile->qap = TRUE;
7319 }
7320 else
7321 {
7322 pConnectProfile->qap = FALSE;
7323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007324 if ( NULL == pIes )
7325 {
7326 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307327 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007328 }
7329 }
7330 //Save Qos connection
7331 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7332
7333 if(!HAL_STATUS_SUCCESS(status))
7334 {
7335 csrFreeConnectBssDesc(pMac, sessionId);
7336 }
7337 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7338 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307339 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7340 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7341 pConnectProfile->SSID.ssId,
7342 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007343 {
7344 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7345 break;
7346 }
7347 pConnectProfile->handoffPermitted = FALSE;
7348 }
7349
7350 return (status);
7351}
7352
Jeff Johnson295189b2012-06-20 16:38:30 -07007353static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7354{
7355 tListElem *pEntry = NULL;
7356 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007357 //The head of the active list is the request we sent
7358 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7359 if(pEntry)
7360 {
7361 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7362 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007363 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7364 {
7365 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7366 {
7367#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7368 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7369#endif
7370 }
7371 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7372 }
7373 else
7374 {
7375 tANI_U32 roamId = 0;
7376 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007377 if(!pSession)
7378 {
7379 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7380 return;
7381 }
7382
Jeff Johnson295189b2012-06-20 16:38:30 -07007383
7384 //The head of the active list is the request we sent
7385 //Try to get back the same profile and roam again
7386 if(pCommand)
7387 {
7388 roamId = pCommand->u.roamCmd.roamId;
7389 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007390 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7391 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007392 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007393#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7394 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7395 if (csrRoamIsHandoffInProgress(pMac))
7396 {
7397 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7398 /* Should indicate neighbor roam algorithm about the connect failure here */
7399 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7400 }
7401#endif
7402 if (pCommand)
7403 {
7404 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7405 {
7406 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7407 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7408 csrRoamReissueRoamCommand(pMac);
7409 }
7410 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7411 {
7412 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7413 }
7414 else
7415 {
7416 csrRoam(pMac, pCommand);
7417 }
7418 }
7419 else
7420 {
7421 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7422 }
7423 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7424}
7425
Jeff Johnson295189b2012-06-20 16:38:30 -07007426eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7427 tDot11fBeaconIEs *pIes,
7428 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7429{
7430 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007431 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7432 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007433
7434 // Set the roaming substate to 'join attempt'...
7435 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007436 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007437 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007438 return (status);
7439}
7440
Jeff Johnson295189b2012-06-20 16:38:30 -07007441static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7442 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7443{
7444 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007445 // Set the roaming substate to 'join attempt'...
7446 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7447
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307448 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7449 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05307450#ifdef DEBUG_ROAM_DELAY
7451 //HACK usign buff len as Auth type
7452 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
7453 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
7454#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007455 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007456 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007457}
7458
Jeff Johnson295189b2012-06-20 16:38:30 -07007459void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7460{
7461 tListElem *pEntry;
7462 tSmeCmd *pCommand;
7463 tCsrRoamInfo roamInfo;
7464 tANI_U32 sessionId;
7465 tCsrRoamSession *pSession;
7466
7467 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7468 if(pEntry)
7469 {
7470 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7471 if ( eSmeCommandRoam == pCommand->command )
7472 {
7473 sessionId = pCommand->sessionId;
7474 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007475
7476 if(!pSession)
7477 {
7478 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7479 return;
7480 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307481 /* While switching between two AP, csr will reissue roam command again
7482 to the nextbss if it was interrupted by the dissconnect req for the
7483 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7484 so reset the bRefAssocStartCnt.
7485 */
7486 if(pSession->bRefAssocStartCnt > 0)
7487 {
7488 pSession->bRefAssocStartCnt--;
7489 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 if( pCommand->u.roamCmd.fStopWds )
7491 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307492 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007493 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7494 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7495 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007496 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7498 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7499 eCSR_ROAM_WDS_IND,
7500 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7502 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7503 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7504 eCSR_ROAM_INFRA_IND,
7505 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7506 }
7507
Jeff Johnson295189b2012-06-20 16:38:30 -07007508
Jeff Johnson295189b2012-06-20 16:38:30 -07007509 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7510 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007511 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007512 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7513 }
7514 }
7515 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7516 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007517 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007518 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7519 }
7520 }
7521 else
7522 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007523 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007524 }
7525 }
7526 else
7527 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007528 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007529 }
7530}
7531
Jeff Johnson295189b2012-06-20 16:38:30 -07007532tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7533{
7534 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7535 tListElem *pEntry;
7536 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007537 //alwasy lock active list before locking pending list
7538 csrLLLock( &pMac->sme.smeCmdActiveList );
7539 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7540 if(pEntry)
7541 {
7542 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7543 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7544 {
7545 fRet = eANI_BOOLEAN_TRUE;
7546 }
7547 }
7548 if(eANI_BOOLEAN_FALSE == fRet)
7549 {
7550 csrLLLock(&pMac->sme.smeCmdPendingList);
7551 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7552 while(pEntry)
7553 {
7554 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7555 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7556 {
7557 fRet = eANI_BOOLEAN_TRUE;
7558 break;
7559 }
7560 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7561 }
7562 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7563 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307564 if (eANI_BOOLEAN_FALSE == fRet)
7565 {
7566 csrLLLock(&pMac->roam.roamCmdPendingList);
7567 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7568 while (pEntry)
7569 {
7570 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7571 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7572 {
7573 fRet = eANI_BOOLEAN_TRUE;
7574 break;
7575 }
7576 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7577 }
7578 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007580 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007581 return (fRet);
7582}
7583
Jeff Johnson295189b2012-06-20 16:38:30 -07007584tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7585{
7586 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7587 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007588 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7589 {
7590 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7591 {
7592 break;
7593 }
7594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007595 return ( fRet );
7596}
7597
Jeff Johnson295189b2012-06-20 16:38:30 -07007598tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7599{
7600 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007601 //alwasy lock active list before locking pending list
7602 csrLLLock( &pMac->sme.smeCmdActiveList );
7603 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7604 if(eANI_BOOLEAN_FALSE == fRet)
7605 {
7606 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7607 }
7608 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007609 return (fRet);
7610}
7611
Jeff Johnson295189b2012-06-20 16:38:30 -07007612tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7613{
7614 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7615 tListElem *pEntry;
7616 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007617 //alwasy lock active list before locking pending list
7618 csrLLLock( &pMac->sme.smeCmdActiveList );
7619 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7620 if( pEntry )
7621 {
7622 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7623 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7624 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7625 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7626 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7627 {
7628 fRet = eANI_BOOLEAN_TRUE;
7629 }
7630 }
7631 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007632 return (fRet);
7633}
Jeff Johnson295189b2012-06-20 16:38:30 -07007634eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7635{
7636 eHalStatus status = eHAL_STATUS_SUCCESS;
7637 tSmeCmd *pCommand = NULL;
7638 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7639 tANI_BOOLEAN fRemoveCmd = FALSE;
7640 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007641 // Delete the old assoc command. All is setup for reassoc to be serialized
7642 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7643 if ( pEntry )
7644 {
7645 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7646 if ( !pCommand )
7647 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007648 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007649 return eHAL_STATUS_RESOURCES;
7650 }
7651 if ( eSmeCommandRoam == pCommand->command )
7652 {
7653 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7654 {
7655 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7656 }
7657 else
7658 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007659 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 }
7661 if (fRemoveCmd == FALSE)
7662 {
7663 // Implies we did not get the serialized assoc command we
7664 // were expecting
7665 pCommand = NULL;
7666 }
7667 }
7668 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007669 if(NULL == pCommand)
7670 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007671 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007672 return eHAL_STATUS_RESOURCES;
7673 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007674 do
7675 {
7676 //Change the substate in case it is wait-for-key
7677 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7678 {
7679 csrRoamStopWaitForKeyTimer( pMac );
7680 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7681 }
7682 pCommand->command = eSmeCommandRoam;
7683 pCommand->sessionId = (tANI_U8)sessionId;
7684 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007685 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7686 if( !HAL_STATUS_SUCCESS( status ) )
7687 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007688 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007689 csrReleaseCommandRoam( pMac, pCommand );
7690 }
7691 } while( 0 );
7692
Jeff Johnson295189b2012-06-20 16:38:30 -07007693 return( status );
7694}
7695static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7696{
7697 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7698 tCsrScanResult *pScanResult = NULL;
7699 tSirBssDescription *pBssDesc = NULL;
7700 tSmeCmd *pCommand = NULL;
7701 tANI_U32 sessionId;
7702 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007703 if(NULL == pEntry)
7704 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307705 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007706 return;
7707 }
7708 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7709 sessionId = pCommand->sessionId;
7710 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007711
7712 if(!pSession)
7713 {
7714 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7715 return;
7716 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307717 smsLog(pMac, LOG1, FL("CFG return value is %d "
7718 " current state is : %d substate is : %d "),
7719 result, pMac->roam.curState[sessionId],
7720 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007721 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7722 {
7723 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007724 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007725 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7726 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007727 /* If the roaming has stopped, not to continue the roaming command*/
7728 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7729 {
7730 //No need to complete roaming here as it already completes
7731 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7732 pCommand->u.roamCmd.roamReason);
7733 csrSetAbortRoamingCommand( pMac, pCommand );
7734 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007736 else
7737 {
7738 if ( CCM_IS_RESULT_SUCCESS(result) )
7739 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307740 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007741 // Successfully set the configuration parameters for the new Bss. Attempt to
7742 // join the roaming Bss.
7743 if(pCommand->u.roamCmd.pRoamBssEntry)
7744 {
7745 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7746 pBssDesc = &pScanResult->Result.BssDescriptor;
7747 }
7748 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7749 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007750 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007751 )
7752 {
7753 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7754 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7755 pBssDesc, pCommand->u.roamCmd.roamId )))
7756 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307757 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007758 //We need to complete the command
7759 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7760 }
7761 }
7762 else
7763 {
7764 if (!pCommand->u.roamCmd.pRoamBssEntry)
7765 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307766 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007767 //We need to complete the command
7768 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7769 return;
7770 }
7771 // If we are roaming TO an Infrastructure BSS...
7772 VOS_ASSERT(pScanResult != NULL);
7773 if ( csrIsInfraBssDesc( pBssDesc ) )
7774 {
7775 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307776 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007777 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7778 {
7779 // ..and currently in an Infrastructure connection....
7780 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7781 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307782 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007783 // ...and the SSIDs are equal, then we Reassoc.
7784 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7785 pIesLocal ) )
7786 // ..and currently in an infrastructure connection
7787 {
7788 // then issue a Reassoc.
7789 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7790 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7791 &pCommand->u.roamCmd.roamProfile );
7792 }
7793 else
7794 {
7795
7796 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7797 // previously associated AP.
7798 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7799 pIesLocal,
7800 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7801 {
7802 //try something else
7803 csrRoam( pMac, pCommand );
7804 }
7805 }
7806 }
7807 else
7808 {
7809 eHalStatus status = eHAL_STATUS_SUCCESS;
7810
7811 /* We need to come with other way to figure out that this is because of HO in BMP
7812 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007813 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07007814 * use join request */
7815#ifdef WLAN_FEATURE_VOWIFI_11R
7816 if (csrRoamIsHandoffInProgress(pMac) &&
7817 csrRoamIs11rAssoc(pMac))
7818 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307819 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007820 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7821 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7822 }
7823 else
7824#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007825#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007826 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007827 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07007828 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307829 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007830 // Now serialize the reassoc command.
7831 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7832 }
7833 else
7834#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007835#ifdef FEATURE_WLAN_LFR
7836 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307837 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007838 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307839 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007840 // Now serialize the reassoc command.
7841 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7842 }
7843 else
7844#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 // else we are not connected and attempting to Join. Issue the
7846 // Join request.
7847 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307848 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07007849 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7850 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7851 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7852 }
7853 if(!HAL_STATUS_SUCCESS(status))
7854 {
7855 //try something else
7856 csrRoam( pMac, pCommand );
7857 }
7858 }
7859 if( !pScanResult->Result.pvIes )
7860 {
7861 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307862 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007863 }
7864 }
7865 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7866 else
7867 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007868 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007869 }
7870 }//else
7871 }//if ( WNI_CFG_SUCCESS == result )
7872 else
7873 {
7874 // In the event the configuration failed, for infra let the roam processor
7875 //attempt to join something else...
7876 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7877 {
7878 csrRoam(pMac, pCommand);
7879 }
7880 else
7881 {
7882 //We need to complete the command
7883 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7884 {
7885 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7886 }
7887 else
7888 {
7889 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7890 }
7891 }
7892 }
7893 }//we have active entry
7894}
7895
Jeff Johnson295189b2012-06-20 16:38:30 -07007896static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7897{
7898 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007899 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007900 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7901 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007902 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007903 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7904 // join the new one...
7905 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007906 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7907 }
7908 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007909 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007910 /***profHandleLostLinkAfterReset(pAdapter);
7911 // In the event the authenticate fails, let the roam processor attempt to join something else...
7912 roamRoam( pAdapter );***/
7913 }
7914}
7915
Jeff Johnson295189b2012-06-20 16:38:30 -07007916static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7917{
7918 eCsrRoamCompleteResult result;
7919 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7920 tCsrRoamInfo roamInfo;
7921 tANI_U32 roamId = 0;
7922
7923 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7924 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007925 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007926 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007927 /* Defeaturize this part later if needed */
7928#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7929 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7930 * we need the response contents while processing the result in csrRoamProcessResults() */
7931 if (csrRoamIsHandoffInProgress(pMac))
7932 {
7933 /* Need to dig more on indicating events to SME QoS module */
7934 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7935 csrRoamComplete( pMac, result, pSmeJoinRsp);
7936 }
7937 else
7938#endif
7939 {
7940 csrRoamComplete( pMac, result, NULL );
7941 }
7942 }
7943 /* Should we handle this similar to handling the join failure? Is it ok
7944 * to call csrRoamComplete() with state as CsrJoinFailure */
7945 else
7946 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007947 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007948 result = eCsrReassocFailure;
7949#ifdef WLAN_FEATURE_VOWIFI_11R
7950 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7951 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7952 {
7953 // Inform HDD to turn off FT flag in HDD
7954 if (pNeighborRoamInfo)
7955 {
7956 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7957 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7958 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007959 /*
7960 * Since the above callback sends a disconnect
7961 * to HDD, we should clean-up our state
7962 * machine as well to be in sync with the upper
7963 * layers. There is no need to send a disassoc
7964 * since: 1) we will never reassoc to the current
7965 * AP in LFR, and 2) there is no need to issue a
7966 * disassoc to the AP with which we were trying
7967 * to reassoc.
7968 */
7969 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7970 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007971 }
7972 }
7973#endif
7974 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7975 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7976 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7977 //The disassoc rsp message will remove the command from active list
7978 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7979 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7980 {
7981 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7982 }
7983 }
7984}
7985
Jeff Johnson295189b2012-06-20 16:38:30 -07007986static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7987{
Jeff Johnson295189b2012-06-20 16:38:30 -07007988#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7989 {
7990 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007991 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7992 if(pIbssLog)
7993 {
7994 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7995 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7996 {
7997 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7998 }
7999 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8000 }
8001 }
8002#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008003 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8004 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8005 {
8006 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8007 }
8008 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8009 {
8010 csrRoamReissueRoamCommand(pMac);
8011 }
8012}
8013
Jeff Johnson295189b2012-06-20 16:38:30 -07008014void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8015{
8016 tSirResultCodes statusCode;
8017#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8018 tScanResultHandle hBSSList;
8019 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8020 eHalStatus status;
8021 tCsrRoamInfo roamInfo;
8022 tCsrScanResultFilter *pScanFilter = NULL;
8023 tANI_U32 roamId = 0;
8024 tCsrRoamProfile *pCurRoamProfile = NULL;
8025 tListElem *pEntry = NULL;
8026 tSmeCmd *pCommand = NULL;
8027#endif
8028 tANI_U32 sessionId;
8029 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07008030
Jeff Johnson295189b2012-06-20 16:38:30 -07008031 tSirSmeDisassocRsp SmeDisassocRsp;
8032
8033 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8034 sessionId = SmeDisassocRsp.sessionId;
8035 statusCode = SmeDisassocRsp.statusCode;
8036
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008037 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008038
8039 if ( csrIsConnStateInfra( pMac, sessionId ) )
8040 {
8041 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008043 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008044
8045 if(!pSession)
8046 {
8047 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8048 return;
8049 }
8050
Jeff Johnson295189b2012-06-20 16:38:30 -07008051 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8052 {
8053 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8054 }
8055 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8056 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8057 {
8058 if ( eSIR_SME_SUCCESS == statusCode )
8059 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008060 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008061 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8062 }
8063 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008065 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8066 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308067 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8068 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008069#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008070 /*
8071 * First ensure if the roam profile is in the scan cache.
8072 * If not, post a reassoc failure and disconnect.
8073 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308074 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8075 if ( NULL == pScanFilter )
8076 status = eHAL_STATUS_FAILURE;
8077 else
8078 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008079 if(HAL_STATUS_SUCCESS(status))
8080 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308081 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008082 status = csrRoamPrepareFilterFromProfile(pMac,
8083 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8084 if(!HAL_STATUS_SUCCESS(status))
8085 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008086 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008087 __func__, status);
8088 goto POST_ROAM_FAILURE;
8089 }
8090 else
8091 {
8092 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8093 if (!HAL_STATUS_SUCCESS(status))
8094 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008095 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008096 __func__, status);
8097 goto POST_ROAM_FAILURE;
8098 }
8099 }
8100 }
8101 else
8102 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008103 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008104 __func__, status);
8105 goto POST_ROAM_FAILURE;
8106 }
8107
8108 /*
8109 * After ensuring that the roam profile is in the scan result list,
8110 * dequeue the command from the active list.
8111 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008112 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8113 if ( pEntry )
8114 {
8115 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008116 /* If the head of the queue is Active and it is a ROAM command, remove
8117 * and put this on the Free queue.
8118 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008119 if ( eSmeCommandRoam == pCommand->command )
8120 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008121
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008122 /*
8123 * we need to process the result first before removing it from active list
8124 * because state changes still happening insides roamQProcessRoamResults so
8125 * no other roam command should be issued.
8126 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8128 if(pCommand->u.roamCmd.fReleaseProfile)
8129 {
8130 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8131 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008133 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008134 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008135 else
8136 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008137 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008138 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008139 }
8140 }
8141 else
8142 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008143 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008144 }
8145 }
8146 else
8147 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008148 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008149 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008150
8151 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008152 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8153
Kiet Lam64c1b492013-07-12 13:56:44 +05308154 vos_mem_copy(roamInfo.bssid,
8155 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8156 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008157
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008158 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8159 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008160
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008161 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308162 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8163 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008164 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308165 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008166 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8167 //make sure to put it at the head of the cmd queue
8168 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8169 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8170 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8171
Jeff Johnson295189b2012-06-20 16:38:30 -07008172 if(!HAL_STATUS_SUCCESS(status))
8173 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008174 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008175 __func__, status);
8176 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008177 }
8178
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008179 /* Notify sub-modules like QoS etc. that handoff happening */
8180 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008181 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308182 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008183 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308184 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008185 return;
8186 }
8187
8188POST_ROAM_FAILURE:
8189 if (pScanFilter)
8190 {
8191 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308192 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008193 }
8194 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308195 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008196
8197 /* Inform the upper layers that the reassoc failed */
8198 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8199 csrRoamCallCallback(pMac, sessionId,
8200 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8201
8202 /*
8203 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8204 * Upon success, we would re-enter this routine after receiving the disassoc
8205 * response and will fall into the reassoc fail sub-state. And, eventually
8206 * call csrRoamComplete which would remove the roam command from SME active
8207 * queue.
8208 */
8209 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8210 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8211 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008212 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008213 __func__, status);
8214 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008215 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008216#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008217
Jeff Johnson295189b2012-06-20 16:38:30 -07008218 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8219 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8220 {
8221 // Disassoc due to Reassoc failure falls into this codepath....
8222 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8223 }
8224 else
8225 {
8226 if ( eSIR_SME_SUCCESS == statusCode )
8227 {
8228 // Successfully disassociated from the 'old' Bss...
8229 //
8230 // We get Disassociate response in three conditions.
8231 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8232 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8233 // Infrastructure network.
8234 // - Third is where we are doing an Infra to Infra roam between networks with different
8235 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8236
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008237 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008238 }
8239 else
8240 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008241 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008242 }
8243 //We are not done yet. Get the data and continue roaming
8244 csrRoamReissueRoamCommand(pMac);
8245 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008246}
8247
Jeff Johnson295189b2012-06-20 16:38:30 -07008248static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8249{
8250 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008251 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008252 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008253 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008254 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008255 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8256 {
8257 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8258 }
8259 else
8260 {
8261 if ( eSIR_SME_SUCCESS == statusCode )
8262 {
8263 // Successfully deauth from the 'old' Bss...
8264 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008265 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008266 }
8267 else
8268 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008269 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008270 }
8271 //We are not done yet. Get the data and continue roaming
8272 csrRoamReissueRoamCommand(pMac);
8273 }
8274}
8275
Jeff Johnson295189b2012-06-20 16:38:30 -07008276static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8277{
8278 eCsrRoamCompleteResult result;
8279
8280 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8281 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008282 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008283 result = eCsrStartBssSuccess;
8284 }
8285 else
8286 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008287 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008288 //Let csrRoamComplete decide what to do
8289 result = eCsrStartBssFailure;
8290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008291 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008292}
8293
Jeff Johnson295189b2012-06-20 16:38:30 -07008294/*
8295 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8296 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8297 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8298 For the messages where sender allocates memory for specific structures, then it can be
8299 cast accordingly.
8300*/
8301void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8302{
8303 tSirSmeRsp *pSmeRsp;
8304 tSmeIbssPeerInd *pIbssPeerInd;
8305 tCsrRoamInfo roamInfo;
8306 // TODO Session Id need to be acquired in this function
8307 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008308 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308309 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8310 pSmeRsp->messageType, pSmeRsp->messageType,
8311 macTraceGetcsrRoamSubState(
8312 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008313 pSmeRsp->messageType = (pSmeRsp->messageType);
8314 pSmeRsp->length = (pSmeRsp->length);
8315 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008316 switch (pSmeRsp->messageType)
8317 {
8318
8319 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8320 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8321 {
8322 //We sent a JOIN_REQ
8323 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8324 }
8325 break;
8326
8327 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8328 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8329 {
8330 //We sent a AUTH_REQ
8331 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8332 }
8333 break;
8334
8335 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8336 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8337 {
8338 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8339 }
8340 break;
8341
8342 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8343 {
8344 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8345 }
8346 break;
8347
8348 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8349 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8350 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8351 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8352 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8353 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8354//HO
8355 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8356 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308357 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8358 macTraceGetcsrRoamSubState(
8359 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008360 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05308361#ifdef DEBUG_ROAM_DELAY
8362 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
8363#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008364 }
8365 break;
8366
8367 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8368 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8369 {
8370 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8371 }
8372 break;
8373
8374 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8375 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8376 {
8377 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8378 }
8379 break;
8380
8381 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8382 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8383 {
8384 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8385 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008386 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008387 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8388 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8389 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008390 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308391 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8392 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008393 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8394 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308395 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8396 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008397 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8398 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8399 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8400 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008401 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308402 smsLog(pMac, LOG1,
8403 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8404 pSmeRsp->messageType, pSmeRsp->messageType,
8405 macTraceGetcsrRoamSubState(
8406 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008407
8408 //If we are connected, check the link status change
8409 if(!csrIsConnStateDisconnected(pMac, sessionId))
8410 {
8411 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8412 }
8413 break;
8414 }
8415}
8416
Jeff Johnson295189b2012-06-20 16:38:30 -07008417void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8418{
8419 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008420 switch (pSirMsg->messageType)
8421 {
8422 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008423 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008424 csrRoamStatsRspProcessor( pMac, pSirMsg );
8425 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008426 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8427 {
8428 tCsrRoamSession *pSession;
8429 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8430 tCsrRoamInfo roamInfo;
8431 tCsrRoamInfo *pRoamInfo = NULL;
8432 tANI_U32 sessionId;
8433 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008434 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308435 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008436 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008437 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8438 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8439 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008440
8441 if(!pSession)
8442 {
8443 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8444 return;
8445 }
8446
Jeff Johnson295189b2012-06-20 16:38:30 -07008447 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8448 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008449 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8450 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8451 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008452 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8453 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308454 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8455 sizeof(tSirMacAddr));
8456 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8457 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008458 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008459 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8460 {
8461 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8462 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8463 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8464 }
8465 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8466 {
8467 vos_sleep( 100 );
8468 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8469 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8470 }
8471
Jeff Johnson295189b2012-06-20 16:38:30 -07008472 }
8473 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008474 default:
8475 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8476 break;
8477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008478}
8479
Jeff Johnson295189b2012-06-20 16:38:30 -07008480eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8481 tSirBssDescription *pBssDescription,
8482 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8483 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8484 tANI_U8 keyId, tANI_U16 keyLength,
8485 tANI_U8 *pKey, tANI_U8 paeRole )
8486{
8487 eHalStatus status = eHAL_STATUS_SUCCESS;
8488 tAniEdType edType;
8489
8490 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8491 {
8492 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8493 }
8494
8495 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8496
8497 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8498 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8499 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8500 addKey )
8501 {
8502 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008503 setKey.encType = EncryptType;
8504 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308505 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008506 setKey.paeRole = paeRole; //0 for supplicant
8507 setKey.keyId = keyId; // Kye index
8508 setKey.keyLength = keyLength;
8509 if( keyLength )
8510 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308511 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008512 }
8513 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008515 return (status);
8516}
8517
Jeff Johnson295189b2012-06-20 16:38:30 -07008518static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8519 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8520{
8521 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8522 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008523#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008524 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008525#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008526
8527 do
8528 {
8529 pCommand = csrGetCommandBuffer(pMac);
8530 if(NULL == pCommand)
8531 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008532 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008533 status = eHAL_STATUS_RESOURCES;
8534 break;
8535 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05308536 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 pCommand->command = eSmeCommandSetKey;
8538 pCommand->sessionId = (tANI_U8)sessionId;
8539 // validate the key length, Adjust if too long...
8540 // for static WEP the keys are not set thru' SetContextReq
8541 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8542 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8543 {
8544 //KeyLength maybe 0 for static WEP
8545 if( pSetKey->keyLength )
8546 {
8547 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8548 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008549 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008550 break;
8551 }
8552
8553 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308554 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8555 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008556 }
8557 }
8558 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8559 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8560 {
8561 //KeyLength maybe 0 for static WEP
8562 if( pSetKey->keyLength )
8563 {
8564 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8565 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008566 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008567 break;
8568 }
8569
8570 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308571 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8572 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008573 }
8574 }
8575 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8576 {
8577 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8578 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008579 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008580 break;
8581 }
8582 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308583 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8584 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008585 }
8586 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8587 {
8588 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8589 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008590 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008591 break;
8592 }
8593 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308594 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8595 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008596 }
8597#ifdef FEATURE_WLAN_WAPI
8598 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8599 {
8600 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8601 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008602 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008603 break;
8604 }
8605 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308606 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8607 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008608 }
8609#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008610#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008611 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8612 {
8613 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8614 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008615 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008616 break;
8617 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008618 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308619 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008620 pSession->eseCckmInfo.reassoc_req_num=1;
8621 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008622 status = eHAL_STATUS_SUCCESS;
8623 break;
8624 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008625#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008626
Jeff Johnson295189b2012-06-20 16:38:30 -07008627#ifdef WLAN_FEATURE_11W
8628 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008629 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008630 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008631 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008632 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008633 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008634 break;
8635 }
8636 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308637 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008638 }
8639#endif
8640 status = eHAL_STATUS_SUCCESS;
8641 pCommand->u.setKeyCmd.roamId = roamId;
8642 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8643 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308644 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8645 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008646 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8647 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308648 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008649 //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
8650
8651 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8652 if( !HAL_STATUS_SUCCESS( status ) )
8653 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008654 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008655 }
8656 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008657 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008658 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008659 if ( ( NULL != pCommand ) &&
8660 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008661#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008662 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008663#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008664 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008665 {
8666 csrReleaseCommandSetKey( pMac, pCommand );
8667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008668 return( status );
8669}
8670
Jeff Johnson295189b2012-06-20 16:38:30 -07008671eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8672 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8673{
8674 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8675 tSmeCmd *pCommand = NULL;
8676 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008677 do
8678 {
8679 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8680 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008681 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008682 status = eHAL_STATUS_CSR_WRONG_STATE;
8683 break;
8684 }
8685 pCommand = csrGetCommandBuffer(pMac);
8686 if(NULL == pCommand)
8687 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008688 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008689 status = eHAL_STATUS_RESOURCES;
8690 break;
8691 }
8692 pCommand->command = eSmeCommandRemoveKey;
8693 pCommand->sessionId = (tANI_U8)sessionId;
8694 pCommand->u.removeKeyCmd.roamId = roamId;
8695 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308696 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8697 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008698 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8699 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8700 {
8701 //in this case, put it to the end of the Q incase there is a set key pending.
8702 fImediate = eANI_BOOLEAN_FALSE;
8703 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008704 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008705 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008706 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008707 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8708 if( !HAL_STATUS_SUCCESS( status ) )
8709 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008710 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008711 break;
8712 }
8713 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008714 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8715 {
8716 csrReleaseCommandRemoveKey( pMac, pCommand );
8717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008718 return (status );
8719}
8720
Jeff Johnson295189b2012-06-20 16:38:30 -07008721eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8722{
8723 eHalStatus status;
8724 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8725 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8726 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8727 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008728#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8729 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8730 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008731 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008732 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308733 vos_mem_set(&setKeyEvent,
8734 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008735 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8736 {
8737 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8738 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8739 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8740 }
8741 else
8742 {
8743 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8744 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8745 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8746 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308747 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008748 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008749 {
8750 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008751 //It has to be static WEP here
8752 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8753 {
8754 setKeyEvent.keyId = (v_U8_t)defKeyId;
8755 }
8756 }
8757 else
8758 {
8759 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8760 }
8761 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8762 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8763 }
8764#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008765 if( csrIsSetKeyAllowed(pMac, sessionId) )
8766 {
8767 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8768 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8769 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8770 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8771 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8772 pCommand->u.setKeyCmd.keyRsc);
8773 }
8774 else
8775 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008776 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008777 //Set this status so the error handling take care of the case.
8778 status = eHAL_STATUS_CSR_WRONG_STATE;
8779 }
8780 if( !HAL_STATUS_SUCCESS(status) )
8781 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008782 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008783 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008784#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008785 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 {
8787 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8788 {
8789 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8790 }
8791 else
8792 {
8793 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8794 }
8795 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8796 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8797 }
8798#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008799 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008800 return ( status );
8801}
8802
Jeff Johnson295189b2012-06-20 16:38:30 -07008803eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8804{
8805 eHalStatus status;
8806 tpSirSmeRemoveKeyReq pMsg = NULL;
8807 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8808 tANI_U8 *p;
8809 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008810#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8811 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8812 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05308813 vos_mem_set(&removeKeyEvent,
8814 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008815 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8816 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8817 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308818 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008819 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8820 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8821 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8822#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008823 if( csrIsSetKeyAllowed(pMac, sessionId) )
8824 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308825 pMsg = vos_mem_malloc(wMsgLen);
8826 if ( NULL == pMsg )
8827 status = eHAL_STATUS_FAILURE;
8828 else
8829 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008830 }
8831 else
8832 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008833 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008834 //Set the error status so error handling kicks in below
8835 status = eHAL_STATUS_CSR_WRONG_STATE;
8836 }
8837 if( HAL_STATUS_SUCCESS( status ) )
8838 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308839 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008840 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8841 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008842 pMsg->sessionId = (tANI_U8)sessionId;
8843 pMsg->transactionId = 0;
8844 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8845 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8846 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308847 vos_mem_copy(p,
8848 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8849 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008850 p += sizeof(tSirMacAddr);
8851 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308852 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008853 p += sizeof(tSirMacAddr);
8854 // edType
8855 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8856 p++;
8857 // weptype
8858 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8859 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8860 {
8861 *p = (tANI_U8)eSIR_WEP_STATIC;
8862 }
8863 else
8864 {
8865 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8866 }
8867 p++;
8868 //keyid
8869 *p = pCommand->u.removeKeyCmd.keyId;
8870 p++;
8871 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008872 status = palSendMBMessage(pMac->hHdd, pMsg);
8873 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008874 if( !HAL_STATUS_SUCCESS( status ) )
8875 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008876 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008877#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8878 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008879 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008880 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8881#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008882 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8883 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008884 return ( status );
8885}
8886
Jeff Johnson295189b2012-06-20 16:38:30 -07008887eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8888{
8889 eHalStatus status;
8890
8891 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8892 {
8893 status = eHAL_STATUS_CSR_WRONG_STATE;
8894 }
8895 else
8896 {
8897 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008899 return ( status );
8900}
8901
Jeff Johnson295189b2012-06-20 16:38:30 -07008902/*
8903 Prepare a filter base on a profile for parsing the scan results.
8904 Upon successful return, caller MUST call csrFreeScanFilter on
8905 pScanFilter when it is done with the filter.
8906*/
8907eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8908 tCsrScanResultFilter *pScanFilter)
8909{
8910 eHalStatus status = eHAL_STATUS_SUCCESS;
8911 tANI_U32 size = 0;
8912 tANI_U8 index = 0;
8913
8914 do
8915 {
8916 if(pProfile->BSSIDs.numOfBSSIDs)
8917 {
8918 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308919 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8920 if ( NULL == pScanFilter->BSSIDs.bssid )
8921 status = eHAL_STATUS_FAILURE;
8922 else
8923 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008924 if(!HAL_STATUS_SUCCESS(status))
8925 {
8926 break;
8927 }
8928 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308929 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 }
8931 if(pProfile->SSIDs.numOfSSIDs)
8932 {
8933 if( !CSR_IS_WDS_STA( pProfile ) )
8934 {
8935 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8936 }
8937 else
8938 {
8939 //For WDS station
8940 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8941 pScanFilter->SSIDs.numOfSSIDs = 1;
8942 }
8943 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308944 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8945 if ( NULL == pScanFilter->SSIDs.SSIDList )
8946 status = eHAL_STATUS_FAILURE;
8947 else
8948 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008949 if(!HAL_STATUS_SUCCESS(status))
8950 {
8951 break;
8952 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308953 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8954 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008955 }
8956 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8957 {
8958 pScanFilter->ChannelInfo.numOfChannels = 0;
8959 pScanFilter->ChannelInfo.ChannelList = NULL;
8960 }
8961 else if(pProfile->ChannelInfo.numOfChannels)
8962 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308963 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8964 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8965 pProfile->ChannelInfo.numOfChannels);
8966 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8967 status = eHAL_STATUS_FAILURE;
8968 else
8969 status = eHAL_STATUS_SUCCESS;
8970
Jeff Johnson295189b2012-06-20 16:38:30 -07008971 pScanFilter->ChannelInfo.numOfChannels = 0;
8972 if(HAL_STATUS_SUCCESS(status))
8973 {
8974 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8975 {
8976 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8977 {
8978 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8979 = pProfile->ChannelInfo.ChannelList[index];
8980 pScanFilter->ChannelInfo.numOfChannels++;
8981 }
8982 else
8983 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008984 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008986 }
8987 }
8988 else
8989 {
8990 break;
8991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008992 }
8993 else
8994 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308995 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008996 status = eHAL_STATUS_FAILURE;
8997 break;
8998 }
8999 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
9000 pScanFilter->authType = pProfile->AuthType;
9001 pScanFilter->EncryptionType = pProfile->EncryptionType;
9002 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9003 pScanFilter->BSSType = pProfile->BSSType;
9004 pScanFilter->phyMode = pProfile->phyMode;
9005#ifdef FEATURE_WLAN_WAPI
9006 //check if user asked for WAPI with 11n or auto mode, in that case modify
9007 //the phymode to 11g
9008 if(csrIsProfileWapi(pProfile))
9009 {
9010 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9011 {
9012 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9013 }
9014 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9015 {
9016 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9017 }
9018 if(!pScanFilter->phyMode)
9019 {
9020 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9021 }
9022 }
9023#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009024 /*Save the WPS info*/
9025 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009026 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009027 if( pProfile->countryCode[0] )
9028 {
9029 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309030 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9031 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009032 }
9033#ifdef WLAN_FEATURE_VOWIFI_11R
9034 if (pProfile->MDID.mdiePresent)
9035 {
9036 pScanFilter->MDID.mdiePresent = 1;
9037 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9038 }
9039#endif
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309040
9041#ifdef WLAN_FEATURE_11W
9042 // Management Frame Protection
9043 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9044 pScanFilter->MFPRequired = pProfile->MFPRequired;
9045 pScanFilter->MFPCapable = pProfile->MFPCapable;
9046#endif
9047
Jeff Johnson295189b2012-06-20 16:38:30 -07009048 }while(0);
9049
9050 if(!HAL_STATUS_SUCCESS(status))
9051 {
9052 csrFreeScanFilter(pMac, pScanFilter);
9053 }
9054
9055 return(status);
9056}
9057
Jeff Johnson295189b2012-06-20 16:38:30 -07009058tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9059 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9060{
9061 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9062 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009063 do
9064 {
9065 // Validate the type is ok...
9066 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9067 pCommand = csrGetCommandBuffer( pMac );
9068 if ( !pCommand )
9069 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009070 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009071 break;
9072 }
9073 //Change the substate in case it is waiting for key
9074 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9075 {
9076 csrRoamStopWaitForKeyTimer( pMac );
9077 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9078 }
9079 pCommand->command = eSmeCommandWmStatusChange;
9080 pCommand->sessionId = (tANI_U8)sessionId;
9081 pCommand->u.wmStatusChangeCmd.Type = Type;
9082 if ( eCsrDisassociated == Type )
9083 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309084 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9085 pSmeRsp,
9086 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009087 }
9088 else
9089 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309090 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9091 pSmeRsp,
9092 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009093 }
9094 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9095 {
9096 fCommandQueued = eANI_BOOLEAN_TRUE;
9097 }
9098 else
9099 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009100 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009101 csrReleaseCommandWmStatusChange( pMac, pCommand );
9102 }
9103
Jeff Johnson295189b2012-06-20 16:38:30 -07009104 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9105 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009106 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009107 return( fCommandQueued );
9108}
9109
Jeff Johnson295189b2012-06-20 16:38:30 -07009110static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9111{
9112 v_S7_t rssi = 0;
9113 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9114 if(pGetRssiReq)
9115 {
9116 if(NULL != pGetRssiReq->pVosContext)
9117 {
9118 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9119 }
9120 else
9121 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009122 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009123 return;
9124 }
9125
9126 if(NULL != pGetRssiReq->rssiCallback)
9127 {
9128 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9129 }
9130 else
9131 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009132 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009133 return;
9134 }
9135 }
9136 else
9137 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009138 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009139 }
9140 return;
9141}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309142
9143static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9144{
9145 tANI_S8 snr = 0;
9146 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9147
9148 if (pGetSnrReq)
9149 {
9150 if (VOS_STATUS_SUCCESS !=
9151 WDA_GetSnr(pGetSnrReq->staId, &snr))
9152 {
9153 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9154 return;
9155 }
9156
9157 if (pGetSnrReq->snrCallback)
9158 {
9159 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9160 pGetSnrReq->pDevContext);
9161 }
9162 else
9163 {
9164 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9165 return;
9166 }
9167 }
9168 else
9169 {
9170 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9171 }
9172 return;
9173}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009174#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009175void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9176{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009177 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9178
Jeff Johnson36d483b2013-04-08 11:08:53 -07009179 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009180 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009181 /* Get roam Rssi request is backed up and passed back to the response,
9182 Extract the request message to fetch callback */
9183 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9184 v_S7_t rssi = pRoamRssiRsp->rssi;
9185
9186 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009187 {
9188 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9189 reqBkp->rssiCallback = NULL;
9190 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009191 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009192 }
9193 else
9194 {
9195 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9196 if (NULL != reqBkp)
9197 {
9198 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009199 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009200 }
9201 }
9202 }
9203 else
9204 {
9205 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9206 }
9207 return;
9208}
9209#endif
9210
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009211
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009212#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009213void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9214{
9215 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9216
9217 if (NULL != pTsmStatsRsp)
9218 {
9219 /* Get roam Rssi request is backed up and passed back to the response,
9220 Extract the request message to fetch callback */
9221 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9222
9223 if (NULL != reqBkp)
9224 {
9225 if (NULL != reqBkp->tsmStatsCallback)
9226 {
9227 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9228 pTsmStatsRsp->staId, reqBkp->pDevContext);
9229 reqBkp->tsmStatsCallback = NULL;
9230 }
9231 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009232 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009233 }
9234 else
9235 {
9236 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9237 if (NULL != reqBkp)
9238 {
9239 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009240 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009241 }
9242 }
9243 }
9244 else
9245 {
9246 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9247 }
9248 return;
9249}
9250
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009251void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009252{
9253 tANI_U32 roamTS2 = 0;
9254 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009255 tpPESession pSessionEntry = NULL;
9256 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009257
9258 if (NULL == pSession)
9259 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009260 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009261 return;
9262 }
9263
9264 roamTS2 = vos_timer_get_system_time();
9265 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009266 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9267 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009268 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009269
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009270 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9271 if (NULL == pSessionEntry)
9272 {
9273 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9274 return;
9275 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009276 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009277 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009278 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009279}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009280#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009281
Jeff Johnsone7245742012-09-05 17:12:55 -07009282static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9283{
9284 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9285 if(pTlRssiInd)
9286 {
9287 if(NULL != pTlRssiInd->tlCallback)
9288 {
9289 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009290 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009291 }
9292 else
9293 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009294 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009295 }
9296 }
9297 else
9298 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009299 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009300 }
9301 return;
9302}
Jeff Johnson295189b2012-06-20 16:38:30 -07009303
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309304eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9305{
9306 tpSirResetAPCapsChange pMsg;
9307 tANI_U16 len;
9308 eHalStatus status = eHAL_STATUS_SUCCESS;
9309
9310 /* Create the message and send to lim */
9311 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309312 pMsg = vos_mem_malloc(len);
9313 if ( NULL == pMsg )
9314 status = eHAL_STATUS_FAILURE;
9315 else
9316 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309317 if (HAL_STATUS_SUCCESS(status))
9318 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309319 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309320 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9321 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309322 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009323 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9324 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309325 status = palSendMBMessage(pMac->hHdd, pMsg);
9326 }
9327 else
9328 {
9329 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9330 }
9331 return status;
9332}
9333
Jeff Johnson295189b2012-06-20 16:38:30 -07009334void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9335{
9336 tSirSmeAssocInd *pAssocInd;
9337 tSirSmeDisassocInd *pDisassocInd;
9338 tSirSmeDeauthInd *pDeauthInd;
9339 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9340 tSirSmeNewBssInfo *pNewBss;
9341 tSmeIbssPeerInd *pIbssPeerInd;
9342 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9343 tSirSmeApNewCaps *pApNewCaps;
9344 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9345 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9346 tCsrRoamInfo *pRoamInfo = NULL;
9347 tCsrRoamInfo roamInfo;
9348 eHalStatus status;
9349 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9350 tCsrRoamSession *pSession = NULL;
9351 tpSirSmeSwitchChannelInd pSwitchChnInd;
9352 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309353 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009354
9355
9356 if (NULL == pSirMsg)
9357 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9358 return;
9359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009360 switch( pSirMsg->messageType )
9361 {
9362 case eWNI_SME_ASSOC_IND:
9363 {
9364 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009365 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009366 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9367 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9368 if( HAL_STATUS_SUCCESS( status ) )
9369 {
9370 pSession = CSR_GET_SESSION(pMac, sessionId);
9371
Jeff Johnson32d95a32012-09-10 13:15:23 -07009372 if(!pSession)
9373 {
9374 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9375 return;
9376 }
9377
Jeff Johnson295189b2012-06-20 16:38:30 -07009378 pRoamInfo = &roamInfo;
9379
9380 // Required for indicating the frames to upper layer
9381 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9382 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9383
9384 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9385 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9386 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9387 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9388
9389 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9390 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9391 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9392
9393 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9394 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309395 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9396 sizeof(tSirMacAddr));
9397 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9398 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009399 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9400 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009401 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009402 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9403 {
9404 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9405 {
9406 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9407 pSession->pConnectBssDesc,
9408 &(pRoamInfo->peerMac),
9409 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9410 pRoamInfo->fAuthRequired = FALSE;
9411 }
9412 else
9413 {
9414 pRoamInfo->fAuthRequired = TRUE;
9415 }
9416 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9417 if (!HAL_STATUS_SUCCESS(status))
9418 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009420 /* Send Association completion message to PE */
9421 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9422
9423 /* send a message to CSR itself just to avoid the EAPOL frames going
9424 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009425 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9426 {
9427 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009429 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9430 {
9431 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9432 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9433 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9434 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009435 }
9436 }
9437 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009438 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009439 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309440 // Check if AP dis-associated us because of MIC failure. If so,
9441 // then we need to take action immediately and not wait till the
9442 // the WmStatusChange requests is pushed and processed
9443 tSmeCmd *pCommand;
9444
9445 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9446 status = csrRoamGetSessionIdFromBSSID( pMac,
9447 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9448 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009449 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309450 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9451 " for session %d "), sessionId);
9452 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9453 MAC_ADDRESS_STR " "
9454 " reason = %d status = %d "),
9455 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9456 pDisassocInd->reasonCode,
9457 pDisassocInd->statusCode);
9458 // If we are in neighbor preauth done state then on receiving
9459 // disassoc or deauth we dont roam instead we just disassoc
9460 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009461 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309462#ifdef WLAN_FEATURE_VOWIFI_11R
9463 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9464 {
9465 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9466 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009467#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009468#ifdef FEATURE_WLAN_ESE
9469 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309470 {
9471 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009473#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009474#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309475 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9476 {
9477 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9478 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009479#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309480 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009481
Agarwal Ashish4f616132013-12-30 23:32:50 +05309482 if (!pSession)
9483 {
9484 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9485 return;
9486 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009487
Agarwal Ashish4f616132013-12-30 23:32:50 +05309488 if ( csrIsConnStateInfra( pMac, sessionId ) )
9489 {
9490 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9491 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009492#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309493 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009494#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309495 csrRoamLinkDown(pMac, sessionId);
9496 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9497 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9498 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309499 pRoamInfo = &roamInfo;
9500 pRoamInfo->statusCode = pDisassocInd->statusCode;
9501 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9502 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009503
Agarwal Ashish4f616132013-12-30 23:32:50 +05309504 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9505 sizeof(tSirMacAddr));
9506 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9507 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009508
Agarwal Ashish4f616132013-12-30 23:32:50 +05309509 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9510 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009511
Agarwal Ashish4f616132013-12-30 23:32:50 +05309512 /*
9513 * STA/P2P client got disassociated so remove any pending deauth
9514 * commands in sme pending list
9515 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309516 pCommand = csrGetCommandBuffer(pMac);
9517 if (NULL == pCommand)
9518 {
9519 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9520 status = eHAL_STATUS_RESOURCES;
9521 return;
9522 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309523 pCommand->command = eSmeCommandRoam;
9524 pCommand->sessionId = (tANI_U8)sessionId;
9525 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9526 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9527 pDisassocInd->peerMacAddr,
9528 sizeof(tSirMacAddr));
9529 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9530 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009531
Agarwal Ashish4f616132013-12-30 23:32:50 +05309532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009533 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309534 else
9535 {
9536 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9537 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9538 }
Kiet Lam82004c62013-11-11 13:24:28 +05309539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009540 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009542 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9544 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9545 if( HAL_STATUS_SUCCESS( status ) )
9546 {
9547 // If we are in neighbor preauth done state then on receiving
9548 // disassoc or deauth we dont roam instead we just disassoc
9549 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009550 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009551#ifdef WLAN_FEATURE_VOWIFI_11R
9552 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9553 {
9554 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9555 }
9556#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009557#ifdef FEATURE_WLAN_ESE
9558 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009559 {
9560 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9561 }
9562#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009563#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309564 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009565 {
9566 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9567 }
9568#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009569 pSession = CSR_GET_SESSION( pMac, sessionId );
9570
Jeff Johnson32d95a32012-09-10 13:15:23 -07009571 if(!pSession)
9572 {
9573 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9574 return;
9575 }
9576
Jeff Johnson295189b2012-06-20 16:38:30 -07009577 if ( csrIsConnStateInfra( pMac, sessionId ) )
9578 {
9579 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9580 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009581#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9582 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9583#endif
9584 csrRoamLinkDown(pMac, sessionId);
9585 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009586 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9587 {
9588
9589 pRoamInfo = &roamInfo;
9590
9591 pRoamInfo->statusCode = pDeauthInd->statusCode;
9592 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9593
9594 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9595
Kiet Lam64c1b492013-07-12 13:56:44 +05309596 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9597 sizeof(tSirMacAddr));
9598 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9599 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009600
9601 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9602 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009603 }
9604 break;
9605
9606 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 -08009607 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009608 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9609 //Update with the new channel id.
9610 //The channel id is hidden in the statusCode.
9611 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9612 if( HAL_STATUS_SUCCESS( status ) )
9613 {
9614 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009615 if(!pSession)
9616 {
9617 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9618 return;
9619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009620 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9621 if(pSession->pConnectBssDesc)
9622 {
9623 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9624 }
9625 }
9626 break;
9627
9628 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009629 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009630 {
9631 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9632 sessionId = pDeauthRsp->sessionId;
9633 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9634 {
9635 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9637 {
9638 pRoamInfo = &roamInfo;
9639 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309640 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9641 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009642 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9643 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9644 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9645 }
9646 }
9647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 break;
9649
9650 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009651 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009652 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009653 {
9654 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9655 sessionId = pDisassocRsp->sessionId;
9656 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9657 {
9658 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009659 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9660 {
9661 pRoamInfo = &roamInfo;
9662 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309663 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9664 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009665 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9666 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9667 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9668 }
9669 }
9670 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009671 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009672 case eWNI_SME_MIC_FAILURE_IND:
9673 {
9674 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9675 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9676 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009677
9678 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9679 if( HAL_STATUS_SUCCESS( status ) )
9680 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309681 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009682 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9683 pRoamInfo = &roamInfo;
9684 if(pMicInd->info.multicast)
9685 {
9686 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9687 }
9688 else
9689 {
9690 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9691 }
9692 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9693 }
9694
Jeff Johnson295189b2012-06-20 16:38:30 -07009695#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9696 {
lukez3c809222013-05-03 10:23:02 -07009697 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009698 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009699 if(!pSession)
9700 {
9701 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9702 return;
9703 }
lukez3c809222013-05-03 10:23:02 -07009704
Kiet Lam64c1b492013-07-12 13:56:44 +05309705 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009706 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9707 secEvent.encryptionModeMulticast =
9708 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9709 secEvent.encryptionModeUnicast =
9710 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9711 secEvent.authMode =
9712 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309713 vos_mem_copy(secEvent.bssid,
9714 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009715 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9716 }
9717#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009718 }
9719 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009720 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9721 {
9722 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9723 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009724 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009725
9726 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9727 if( HAL_STATUS_SUCCESS( status ) )
9728 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309729 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009730 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9731 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9732 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9733 }
9734 }
9735 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009736
Jeff Johnson295189b2012-06-20 16:38:30 -07009737 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9738 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9739 switch( pStatusChangeMsg->statusChangeCode )
9740 {
9741 case eSIR_SME_IBSS_ACTIVE:
9742 sessionId = csrFindIbssSession( pMac );
9743 if( CSR_SESSION_ID_INVALID != sessionId )
9744 {
9745 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009746 if(!pSession)
9747 {
9748 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9749 return;
9750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009751 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9752 if(pSession->pConnectBssDesc)
9753 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309754 vos_mem_copy(&roamInfo.bssid,
9755 pSession->pConnectBssDesc->bssId,
9756 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009757 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9758 pRoamInfo = &roamInfo;
9759 }
9760 else
9761 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009762 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009763 }
9764 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9765 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9766 }
9767 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009768 case eSIR_SME_IBSS_INACTIVE:
9769 sessionId = csrFindIbssSession( pMac );
9770 if( CSR_SESSION_ID_INVALID != sessionId )
9771 {
9772 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009773 if(!pSession)
9774 {
9775 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9776 return;
9777 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009778 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9779 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9780 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9781 }
9782 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009783 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9784 sessionId = csrFindIbssSession( pMac );
9785 if( CSR_SESSION_ID_INVALID != sessionId )
9786 {
9787 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009788 if(!pSession)
9789 {
9790 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9791 return;
9792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009793 // update the connection state information
9794 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009795#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9796 {
9797 vos_log_ibss_pkt_type *pIbssLog;
9798 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009799 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9800 if(pIbssLog)
9801 {
9802 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9803 if(pNewBss)
9804 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309805 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009806 if(pNewBss->ssId.length)
9807 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309808 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9809 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009810 }
9811 pIbssLog->operatingChannel = pNewBss->channelNumber;
9812 }
9813 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9814 {
9815 //***U8 is not enough for beacon interval
9816 pIbssLog->beaconInterval = (v_U8_t)bi;
9817 }
9818 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9819 }
9820 }
9821#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009822 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009823
9824 if ((eCSR_ENCRYPT_TYPE_NONE ==
9825 pSession->connectedProfile.EncryptionType ))
9826 {
9827 csrRoamIssueSetContextReq( pMac, sessionId,
9828 pSession->connectedProfile.EncryptionType,
9829 pSession->pConnectBssDesc,
9830 &Broadcastaddr,
9831 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9832 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009833 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9834 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309835 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9836 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009837 pRoamInfo = &roamInfo;
9838 //This BSSID is th ereal BSSID, let's save it
9839 if(pSession->pConnectBssDesc)
9840 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309841 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9842 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009843 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009844 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009845 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009846 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009847 // detection by LIM that the capabilities of the associated AP have changed.
9848 case eSIR_SME_AP_CAPS_CHANGED:
9849 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009850 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009851 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9852 if( HAL_STATUS_SUCCESS( status ) )
9853 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009854 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9855 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309856 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009857 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9858 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9859 )
9860 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309861 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9862 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009863 }
9864 else
9865 {
9866 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309867 FL("Skipping csrScanForCapabilityChange as "
9868 "CSR is in state %s and sub-state %s"),
9869 macTraceGetcsrRoamState(
9870 pMac->roam.curState[sessionId]),
9871 macTraceGetcsrRoamSubState(
9872 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309873 /* We ignore the caps change event if CSR is not in full connected state.
9874 * Send one event to PE to reset limSentCapsChangeNtf
9875 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9876 * otherwise lim cannot send any CAPS change events to SME */
9877 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009879 }
9880 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309881
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 default:
9883 roamStatus = eCSR_ROAM_FAILED;
9884 result = eCSR_ROAM_RESULT_NONE;
9885 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009886 } // end switch on statusChangeCode
9887 if(eCSR_ROAM_RESULT_NONE != result)
9888 {
9889 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9890 }
9891 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009892 case eWNI_SME_IBSS_NEW_PEER_IND:
9893 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009894#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9895 {
9896 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009897 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9898 if(pIbssLog)
9899 {
9900 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309901 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009902 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9903 }
9904 }
9905#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 sessionId = csrFindIbssSession( pMac );
9907 if( CSR_SESSION_ID_INVALID != sessionId )
9908 {
9909 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009910
9911 if(!pSession)
9912 {
9913 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9914 return;
9915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009916 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9917 if(pSession->pConnectBssDesc)
9918 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309919 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9920 sizeof(tCsrBssid));
9921 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9922 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009923 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9924 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309925 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9926 - sizeof(tSmeIbssPeerInd)));
9927 if ( NULL == roamInfo.pbFrames )
9928 status = eHAL_STATUS_FAILURE;
9929 else
9930 status = eHAL_STATUS_SUCCESS;
9931 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009932 {
9933 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309934 vos_mem_copy(roamInfo.pbFrames,
9935 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9936 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009937 }
9938 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9939 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9940 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309941 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9942 if ( NULL == roamInfo.pBssDesc )
9943 status = eHAL_STATUS_FAILURE;
9944 else
9945 status = eHAL_STATUS_SUCCESS;
9946 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009947 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309948 vos_mem_copy(roamInfo.pBssDesc,
9949 pSession->pConnectBssDesc,
9950 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009951 }
9952 if(HAL_STATUS_SUCCESS(status))
9953 {
9954 pRoamInfo = &roamInfo;
9955 }
9956 else
9957 {
9958 if(roamInfo.pbFrames)
9959 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309960 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009961 }
9962 if(roamInfo.pBssDesc)
9963 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309964 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009965 }
9966 }
9967 }
9968 else
9969 {
9970 pRoamInfo = &roamInfo;
9971 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009972 if ((eCSR_ENCRYPT_TYPE_NONE ==
9973 pSession->connectedProfile.EncryptionType ))
9974 {
9975 csrRoamIssueSetContextReq( pMac, sessionId,
9976 pSession->connectedProfile.EncryptionType,
9977 pSession->pConnectBssDesc,
9978 &(pIbssPeerInd->peerAddr),
9979 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009981 }
9982 else
9983 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009984 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009985 }
9986 //send up the sec type for the new peer
9987 if (pRoamInfo)
9988 {
9989 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9990 }
9991 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9992 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9993 if(pRoamInfo)
9994 {
9995 if(roamInfo.pbFrames)
9996 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309997 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009998 }
9999 if(roamInfo.pBssDesc)
10000 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010001 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010002 }
10003 }
10004 }
10005 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010006 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10007 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10008 sessionId = csrFindIbssSession( pMac );
10009 if( CSR_SESSION_ID_INVALID != sessionId )
10010 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010011#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10012 {
10013 vos_log_ibss_pkt_type *pIbssLog;
10014
10015 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10016 if(pIbssLog)
10017 {
10018 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10019 if(pIbssPeerInd)
10020 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010021 vos_mem_copy(pIbssLog->peerMacAddr,
10022 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010023 }
10024 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10025 }
10026 }
10027#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010028 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010029 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10030 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10031 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010032 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10033 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010034 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10035 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10036 }
10037 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010038 case eWNI_SME_SETCONTEXT_RSP:
10039 {
10040 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10041 tListElem *pEntry;
10042 tSmeCmd *pCommand;
10043
10044 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10045 if ( pEntry )
10046 {
10047 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10048 if ( eSmeCommandSetKey == pCommand->command )
10049 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010050 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010051 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010052
10053 if(!pSession)
10054 {
10055 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10056 return;
10057 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010058
10059#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10060 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10061 {
10062 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010063 vos_mem_set(&setKeyEvent,
10064 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010065 if( pRsp->peerMacAddr[0] & 0x01 )
10066 {
10067 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
10068 }
10069 else
10070 {
10071 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
10072 }
10073 setKeyEvent.encryptionModeMulticast =
10074 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10075 setKeyEvent.encryptionModeUnicast =
10076 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010077 vos_mem_copy(setKeyEvent.bssid,
10078 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010079 setKeyEvent.authMode =
10080 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010081 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010082 {
10083 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10084 }
10085 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10086 }
10087#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10088 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10089 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010090 csrRoamStopWaitForKeyTimer( pMac );
10091
Jeff Johnson295189b2012-06-20 16:38:30 -070010092 //We are done with authentication, whethere succeed or not
10093 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010094 //We do it here because this linkup function is not called after association
10095 //when a key needs to be set.
10096 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10097 {
10098 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10099 }
10100 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010101 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010102 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010103 vos_mem_copy(&roamInfo.peerMac,
10104 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010105 //Make sure we install the GTK before indicating to HDD as authenticated
10106 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010107 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10108 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010109 {
Yathish9f22e662012-12-10 14:21:35 -080010110#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10111 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10112 {
10113 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010114 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010115 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
10116 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
10117 pMsg->seesionId = sessionId;
10118 status = palSendMBMessage(pMac->hHdd, pMsg );
10119 }
10120#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010121 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010122 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
10123 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE )
10124 {
10125 tpSirSmeHT40OBSSScanInd pMsg;
10126 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10127 pMsg->messageType =
10128 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10129 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010130 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10131 vos_mem_copy(pMsg->peerMacAddr,
10132 pSession->connectedProfile.bssid,
10133 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010134 status = palSendMBMessage(pMac->hHdd,
10135 pMsg );
10136 }
10137 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010138 }
10139 else
10140 {
10141 result = eCSR_ROAM_RESULT_NONE;
10142 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010143 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010144 }
10145 else
10146 {
10147 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010148 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10149 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10150 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010151 }
10152 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10153 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010154 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10155 // can go ahead and initiate the TSPEC if any are pending
10156 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010157#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010158 //Send Adjacent AP repot to new AP.
10159 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10160 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010161 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010162 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010163#ifdef FEATURE_WLAN_ESE_UPLOAD
10164 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010165#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010166 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010167#endif
10168 pSession->isPrevApInfoValid = FALSE;
10169 }
10170#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010171 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10172 {
10173 csrReleaseCommandSetKey( pMac, pCommand );
10174 }
10175 }
10176 else
10177 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010178 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010179 }
10180 }
10181 else
10182 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010183 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010184 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010185 smeProcessPendingQueue( pMac );
10186 }
10187 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010188 case eWNI_SME_REMOVEKEY_RSP:
10189 {
10190 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10191 tListElem *pEntry;
10192 tSmeCmd *pCommand;
10193
10194 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10195 if ( pEntry )
10196 {
10197 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10198 if ( eSmeCommandRemoveKey == pCommand->command )
10199 {
10200 sessionId = pCommand->sessionId;
10201 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010202
10203 if(!pSession)
10204 {
10205 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10206 return;
10207 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010208#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10209 {
10210 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010211 vos_mem_set(&removeKeyEvent,
10212 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010213 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10214 removeKeyEvent.encryptionModeMulticast =
10215 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10216 removeKeyEvent.encryptionModeUnicast =
10217 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010218 vos_mem_copy( removeKeyEvent.bssid,
10219 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010220 removeKeyEvent.authMode =
10221 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010222 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010223 {
10224 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10225 }
10226 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10227 }
10228#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010229 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010230 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010231 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10232 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010233 result = eCSR_ROAM_RESULT_NONE;
10234 pRoamInfo = &roamInfo;
10235 }
10236 else
10237 {
10238 result = eCSR_ROAM_RESULT_FAILURE;
10239 }
10240 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10241 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10242 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10243 {
10244 csrReleaseCommandRemoveKey( pMac, pCommand );
10245 }
10246 }
10247 else
10248 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010249 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010250 }
10251 }
10252 else
10253 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010254 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010255 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010256 smeProcessPendingQueue( pMac );
10257 }
10258 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010259 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010260 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 csrRoamStatsRspProcessor( pMac, pSirMsg );
10262 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010263#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010264 case eWNI_SME_GET_ROAM_RSSI_RSP:
10265 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10266 csrRoamRssiRspProcessor( pMac, pSirMsg );
10267 break;
10268#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010269#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010270 case eWNI_SME_GET_TSM_STATS_RSP:
10271 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10272 csrTsmStatsRspProcessor( pMac, pSirMsg );
10273 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010274#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010275 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010276 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010277 csrUpdateRssi( pMac, pSirMsg );
10278 break;
10279
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010280 case eWNI_SME_GET_SNR_REQ:
10281 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10282 csrUpdateSnr(pMac, pSirMsg);
10283 break;
10284
Jeff Johnson295189b2012-06-20 16:38:30 -070010285#ifdef WLAN_FEATURE_VOWIFI_11R
10286 case eWNI_SME_FT_PRE_AUTH_RSP:
10287 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10288 break;
10289#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010290 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10291 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010292 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 -070010293 sessionId = pSmeMaxAssocInd->sessionId;
10294 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010295 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10296 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010297 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10298 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10299 break;
10300
10301 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010302 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010303 btampEstablishLogLinkHdlr( pSirMsg );
10304 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010305 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010306 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010307 csrRoamRssiIndHdlr( pMac, pSirMsg );
10308 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010309#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10310 case eWNI_SME_CANDIDATE_FOUND_IND:
10311 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10312 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10313 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010314 case eWNI_SME_HANDOFF_REQ:
10315 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10316 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10317 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010318#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010319
10320 default:
10321 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010322 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010323}
10324
Jeff Johnson295189b2012-06-20 16:38:30 -070010325void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10326 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10327{
10328 if(pSession)
10329 {
10330 if(pSession->bRefAssocStartCnt)
10331 {
10332 pSession->bRefAssocStartCnt--;
10333 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10334 //Need to call association_completion because there is an assoc_start pending.
10335 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10336 eCSR_ROAM_ASSOCIATION_COMPLETION,
10337 eCSR_ROAM_RESULT_FAILURE);
10338 }
10339 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10340 }
10341 else
10342 {
10343 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10344 }
10345}
10346
10347
10348eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10349{
10350 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010351 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10352 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10353 {
10354 status = csrScanRequestLostLink1( pMac, sessionId );
10355 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010356 return(status);
10357}
10358
Jeff Johnson295189b2012-06-20 16:38:30 -070010359//return a boolean to indicate whether roaming completed or continue.
10360tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10361 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10362{
10363 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10364 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10365 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10366 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010367 if(!pSession)
10368 {
10369 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10370 return eANI_BOOLEAN_FALSE;
10371 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010372 //Check whether time is up
10373 if(pSession->fCancelRoaming || fForce ||
10374 ((curTime - pSession->roamingStartTime) > roamTime) ||
10375 eCsrReassocRoaming == pSession->roamingReason ||
10376 eCsrDynamicRoaming == pSession->roamingReason)
10377 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010378 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010379 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10380 {
10381 //roaming is cancelled, tell HDD to indicate disconnect
10382 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10383 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10384 //to be eSIR_BEACON_MISSED
10385 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10386 {
10387 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10388 }
10389 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10390 {
10391 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10392 }
10393 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10394 {
10395 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10396 }
10397 else
10398 {
10399 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10400 }
10401 }
10402 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10403 pSession->roamingReason = eCsrNotRoaming;
10404 }
10405 else
10406 {
10407 pSession->roamResult = roamResult;
10408 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10409 {
10410 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10411 pSession->roamingReason = eCsrNotRoaming;
10412 }
10413 else
10414 {
10415 fCompleted = eANI_BOOLEAN_FALSE;
10416 }
10417 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010418 return(fCompleted);
10419}
10420
Jeff Johnson295189b2012-06-20 16:38:30 -070010421void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10422{
10423 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010424
10425 if(!pSession)
10426 {
10427 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10428 return;
10429 }
10430
Jeff Johnson295189b2012-06-20 16:38:30 -070010431 if(CSR_IS_ROAMING(pSession))
10432 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010433 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010434 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10435 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10436 {
10437 //No need to do anything in here because the handler takes care of it
10438 }
10439 else
10440 {
10441 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10442 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10443 //Roaming is stopped after here
10444 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10445 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010446 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010447 csrRoamStopRoamingTimer(pMac, sessionId);
10448 }
10449 }
10450}
10451
Jeff Johnson295189b2012-06-20 16:38:30 -070010452void csrRoamRoamingTimerHandler(void *pv)
10453{
10454 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10455 tpAniSirGlobal pMac = pInfo->pMac;
10456 tANI_U32 sessionId = pInfo->sessionId;
10457 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010458
10459 if(!pSession)
10460 {
10461 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10462 return;
10463 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010464
10465 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10466 {
10467 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10468 {
10469 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10470 pSession->roamingReason = eCsrNotRoaming;
10471 }
10472 }
10473}
10474
Jeff Johnson295189b2012-06-20 16:38:30 -070010475eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10476{
10477 eHalStatus status;
10478 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010479
10480 if(!pSession)
10481 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010482 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010483 return eHAL_STATUS_FAILURE;
10484 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010485
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010486 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010487 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010488 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010489
10490 return (status);
10491}
10492
Jeff Johnson295189b2012-06-20 16:38:30 -070010493eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10494{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010495 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010496}
10497
Jeff Johnson295189b2012-06-20 16:38:30 -070010498void csrRoamWaitForKeyTimeOutHandler(void *pv)
10499{
10500 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10501 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010502 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010503 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010504
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010505 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10506 macTraceGetNeighbourRoamState(
10507 pMac->roam.neighborRoamInfo.neighborRoamState),
10508 macTraceGetcsrRoamSubState(
10509 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010510
Jeff Johnson295189b2012-06-20 16:38:30 -070010511 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10512 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010513#ifdef FEATURE_WLAN_LFR
10514 if (csrNeighborRoamIsHandoffInProgress(pMac))
10515 {
10516 /*
10517 * Enable heartbeat timer when hand-off is in progress
10518 * and Key Wait timer expired.
10519 */
10520 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010521 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010522 pMac->roam.configParam.HeartbeatThresh24);
10523 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10524 pMac->roam.configParam.HeartbeatThresh24,
10525 NULL, eANI_BOOLEAN_FALSE);
10526 }
10527#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010528 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010529
Jeff Johnson295189b2012-06-20 16:38:30 -070010530 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010531 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10532 {
10533 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10534 pInfo->sessionId);
10535 }
10536
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010537 if (pSession)
10538 {
10539 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10540 {
10541 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10542 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010543 if( (pSession->connectedProfile.AuthType ==
10544 eCSR_AUTH_TYPE_SHARED_KEY) &&
10545 ( (pSession->connectedProfile.EncryptionType ==
10546 eCSR_ENCRYPT_TYPE_WEP40) ||
10547 (pSession->connectedProfile.EncryptionType ==
10548 eCSR_ENCRYPT_TYPE_WEP104) ))
10549 {
10550 status = sme_AcquireGlobalLock( &pMac->sme );
10551 if ( HAL_STATUS_SUCCESS( status ) )
10552 {
10553 csrRoamDisconnect( pMac, pInfo->sessionId,
10554 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10555 sme_ReleaseGlobalLock( &pMac->sme );
10556 }
10557 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010558 }
10559 else
10560 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010561 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010562 __func__);
10563 }
10564 }
10565 else
10566 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010567 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010568 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010569 }
10570
10571}
10572
Jeff Johnson295189b2012-06-20 16:38:30 -070010573eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10574{
10575 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010576#ifdef FEATURE_WLAN_LFR
10577 if (csrNeighborRoamIsHandoffInProgress(pMac))
10578 {
10579 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010580 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10581 macTraceGetNeighbourRoamState(
10582 pMac->roam.neighborRoamInfo.neighborRoamState),
10583 macTraceGetcsrRoamSubState(
10584 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10585 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010586 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10587 }
10588#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010589 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010590 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010591
10592 return (status);
10593}
10594
Jeff Johnson295189b2012-06-20 16:38:30 -070010595eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10596{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010597 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10598 macTraceGetNeighbourRoamState(
10599 pMac->roam.neighborRoamInfo.neighborRoamState),
10600 macTraceGetcsrRoamSubState(
10601 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010602#ifdef FEATURE_WLAN_LFR
10603 if (csrNeighborRoamIsHandoffInProgress(pMac))
10604 {
10605 /*
10606 * Enable heartbeat timer when hand-off is in progress
10607 * and Key Wait timer got stopped for some reason
10608 */
10609 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010610 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010611 pMac->roam.configParam.HeartbeatThresh24);
10612 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10613 pMac->roam.configParam.HeartbeatThresh24,
10614 NULL, eANI_BOOLEAN_FALSE);
10615 }
10616#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010617 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010618}
10619
Jeff Johnson295189b2012-06-20 16:38:30 -070010620void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10621 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10622{
10623 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10624 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010625 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10626 /* To silence the KW tool Null chaeck is added */
10627 if(!pSession)
10628 {
10629 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10630 return;
10631 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010632
10633 if(pCommand)
10634 {
10635 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010636 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010637 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010638 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10639 {
10640 //if success, force roaming completion
10641 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10642 }
10643 else
10644 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010645 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010646 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010647 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10648 }
10649}
10650
Jeff Johnson295189b2012-06-20 16:38:30 -070010651eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10652{
10653 eHalStatus status = eHAL_STATUS_SUCCESS;
10654 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10655 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10656 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10657 tCsrRoamInfo *pRoamInfo = NULL;
10658 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010659 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010660 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010661 /* To silence the KW tool Null chaeck is added */
10662 if(!pSession)
10663 {
10664 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10665 return eHAL_STATUS_FAILURE;
10666 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010667 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010668 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010669 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10670 if ( eWNI_SME_DISASSOC_IND == type )
10671 {
10672 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10673 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10674 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010675 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010676 }
10677 else if ( eWNI_SME_DEAUTH_IND == type )
10678 {
10679 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10680 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10681 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010682 /* Convert into proper reason code */
10683 pSession->joinFailStatusCode.reasonCode =
10684 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010685 0 : pDeauthIndMsg->reasonCode;
10686 /* cfg layer expects 0 as reason code if
10687 the driver dosent know the reason code
10688 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010689 }
10690 else
10691 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010692 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010693 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010694 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010695 }
10696
10697 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010698 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010699 {
10700 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10701 }
10702
10703 if ( eWNI_SME_DISASSOC_IND == type )
10704 {
10705 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10706 }
10707 else if ( eWNI_SME_DEAUTH_IND == type )
10708 {
10709 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10710 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010711 if(!HAL_STATUS_SUCCESS(status))
10712 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010713 //If fail to send confirmation to PE, not to trigger roaming
10714 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010715 }
10716
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010717 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010718 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010719 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10720 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010721 if( eWNI_SME_DISASSOC_IND == type)
10722 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010723 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010724 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10725 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010726 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10727 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010728 else if( eWNI_SME_DEAUTH_IND == type )
10729 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010730 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010731 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10732 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010733 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10734 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010735 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010736
10737 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10738 that we are roaming. But if we cannot possibly roam, or if we are unable to
10739 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010740 if(fToRoam)
10741 {
10742 //Only remove the connected BSS in infrastructure mode
10743 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10744 //Not to do anying for lostlink with WDS
10745 if( pMac->roam.configParam.nRoamingTime )
10746 {
10747 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10748 ( eWNI_SME_DEAUTH_IND == type ) ?
10749 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10750 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010751 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010752 //For IBSS, we need to give some more info to HDD
10753 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10754 {
10755 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10756 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10757 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10758 }
10759 else
10760 {
10761 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10762 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010763 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010764 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10765 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10766 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10767 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10768 }
10769 else
10770 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010771 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010772 fToRoam = eANI_BOOLEAN_FALSE;
10773 }
10774 }
10775 else
10776 {
10777 //We are told not to roam, indicate lostlink
10778 fToRoam = eANI_BOOLEAN_FALSE;
10779 }
10780 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010781 if(!fToRoam)
10782 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010783 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010784 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010785 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010786 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10787 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10788 * csrRoamCheckForLinkStatusChange API.
10789 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010790 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10791 }
10792
10793 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010794 Still enable idle scan for polling in case concurrent sessions are running */
10795 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10796 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010797 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010798 }
10799 }
10800
10801 return (status);
10802}
10803
Jeff Johnson295189b2012-06-20 16:38:30 -070010804eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10805{
10806 eHalStatus status = eHAL_STATUS_SUCCESS;
10807 tListElem *pEntry = NULL;
10808 tSmeCmd *pCommand = NULL;
10809 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010810
10811 if(!pSession)
10812 {
10813 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10814 return eHAL_STATUS_FAILURE;
10815 }
10816
Jeff Johnson295189b2012-06-20 16:38:30 -070010817 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010818 //Only remove the connected BSS in infrastructure mode
10819 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10820 if(pMac->roam.configParam.nRoamingTime)
10821 {
10822 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10823 {
10824 //before starting the lost link logic release the roam command for handoff
10825 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10826 if(pEntry)
10827 {
10828 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10829 }
10830 if(pCommand)
10831 {
10832 if (( eSmeCommandRoam == pCommand->command ) &&
10833 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10834 {
10835 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10836 {
10837 csrReleaseCommandRoam( pMac, pCommand );
10838 }
10839 }
10840 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010841 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010842 }
10843 }
10844 else
10845 {
10846 //We are told not to roam, indicate lostlink
10847 status = eHAL_STATUS_FAILURE;
10848 }
10849
10850 return (status);
10851}
Jeff Johnson295189b2012-06-20 16:38:30 -070010852void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10853{
10854 tListElem *pEntry;
10855 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010856 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10857 if ( pEntry )
10858 {
10859 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10860 if ( eSmeCommandWmStatusChange == pCommand->command )
10861 {
10862 // Nothing to process in a Lost Link completion.... It just kicks off a
10863 // roaming sequence.
10864 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10865 {
10866 csrReleaseCommandWmStatusChange( pMac, pCommand );
10867 }
10868 else
10869 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010870 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010871 }
10872
10873 }
10874 else
10875 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010876 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010877 }
10878 }
10879 else
10880 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010881 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010882 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010883 smeProcessPendingQueue( pMac );
10884}
10885
Jeff Johnson295189b2012-06-20 16:38:30 -070010886void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10887{
10888 eHalStatus status = eHAL_STATUS_FAILURE;
10889 tSirSmeRsp *pSirSmeMsg;
10890 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010891
10892 if(!pSession)
10893 {
10894 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10895 return;
10896 }
10897
Jeff Johnson295189b2012-06-20 16:38:30 -070010898 switch ( pCommand->u.wmStatusChangeCmd.Type )
10899 {
10900 case eCsrDisassociated:
10901 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10902 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10903 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010904 case eCsrDeauthenticated:
10905 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10906 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10907 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010908 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010909 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010910 break;
10911 }
10912 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10913 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10914 {
10915 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10916 {
10917 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010918 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010919 }
10920 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010921 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10922 // command here since there is nothing else to do.
10923 csrRoamWmStatusChangeComplete( pMac );
10924}
10925
Jeff Johnson295189b2012-06-20 16:38:30 -070010926//This function returns band and mode information.
10927//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10928//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010929static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10930 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010931{
Jeff Johnson295189b2012-06-20 16:38:30 -070010932 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10933 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10934 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010935 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010936
Jeff Johnson295189b2012-06-20 16:38:30 -070010937 //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 -070010938 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10939 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10940 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10941 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010942 {
10943 switch( pMac->roam.configParam.uCfgDot11Mode )
10944 {
10945 case eCSR_CFG_DOT11_MODE_11A:
10946 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10947 eBand = eCSR_BAND_5G;
10948 break;
10949 case eCSR_CFG_DOT11_MODE_11B:
10950 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10951 eBand = eCSR_BAND_24;
10952 break;
10953 case eCSR_CFG_DOT11_MODE_11G:
10954 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10955 eBand = eCSR_BAND_24;
10956 break;
10957 case eCSR_CFG_DOT11_MODE_11N:
10958 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010959 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10960 break;
10961#ifdef WLAN_FEATURE_11AC
10962 case eCSR_CFG_DOT11_MODE_11AC:
10963 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10964 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010965 /* If the operating channel is in 2.4 GHz band, check for
10966 * INI item to disable VHT operation in 2.4 GHz band
10967 */
10968 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10969 !pMac->roam.configParam.enableVhtFor24GHz)
10970 {
10971 /* Disable 11AC operation */
10972 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10973 }
10974 else
10975 {
10976 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10977 }
10978 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010979 }
10980 else
10981 {
10982 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10983 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10984 }
10985 break;
10986 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10987 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10988 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010989 /* If the operating channel is in 2.4 GHz band, check for
10990 * INI item to disable VHT operation in 2.4 GHz band
10991 */
10992 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10993 !pMac->roam.configParam.enableVhtFor24GHz)
10994 {
10995 /* Disable 11AC operation */
10996 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10997 }
10998 else
10999 {
11000 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11001 }
11002 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011003 }
11004 else
11005 {
11006 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11007 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11008 }
11009 break;
11010#endif
11011 case eCSR_CFG_DOT11_MODE_AUTO:
11012 eBand = pMac->roam.configParam.eBand;
11013 if (eCSR_BAND_24 == eBand)
11014 {
11015 // WiFi tests require IBSS networks to start in 11b mode
11016 // without any change to the default parameter settings
11017 // on the adapter. We use ACU to start an IBSS through
11018 // creation of a startIBSS profile. This startIBSS profile
11019 // has Auto MACProtocol and the adapter property setting
11020 // for dot11Mode is also AUTO. So in this case, let's
11021 // start the IBSS network in 11b mode instead of 11g mode.
11022 // So this is for Auto=profile->MacProtocol && Auto=Global.
11023 // dot11Mode && profile->channel is < 14, then start the IBSS
11024 // in b mode.
11025 //
11026 // Note: we used to have this start as an 11g IBSS for best
11027 // performance... now to specify that the user will have to
11028 // set the do11Mode in the property page to 11g to force it.
11029 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11030 }
11031 else
11032 {
11033#ifdef WLAN_FEATURE_11AC
11034 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11035 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011036 /* If the operating channel is in 2.4 GHz band, check for
11037 * INI item to disable VHT operation in 2.4 GHz band
11038 */
11039 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11040 !pMac->roam.configParam.enableVhtFor24GHz)
11041 {
11042 /* Disable 11AC operation */
11043 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11044 }
11045 else
11046 {
11047 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11048 }
11049 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011050 }
11051 else
11052 {
11053 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11054 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11055 }
11056#else
11057 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11058 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11059#endif
11060 }
11061 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011062 default:
11063 // Global dot11 Mode setting is 11a/b/g.
11064 // use the channel number to determine the Mode setting.
11065 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11066 {
11067 eBand = pMac->roam.configParam.eBand;
11068 if(eCSR_BAND_24 == eBand)
11069 {
11070 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11071 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11072 }
11073 else
11074 {
11075 //prefer 5GHz
11076 eBand = eCSR_BAND_5G;
11077 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11078 }
11079 }
11080 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11081 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011082 // WiFi tests require IBSS networks to start in 11b mode
11083 // without any change to the default parameter settings
11084 // on the adapter. We use ACU to start an IBSS through
11085 // creation of a startIBSS profile. This startIBSS profile
11086 // has Auto MACProtocol and the adapter property setting
11087 // for dot11Mode is also AUTO. So in this case, let's
11088 // start the IBSS network in 11b mode instead of 11g mode.
11089 // So this is for Auto=profile->MacProtocol && Auto=Global.
11090 // dot11Mode && profile->channel is < 14, then start the IBSS
11091 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011092 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011093 // Note: we used to have this start as an 11g IBSS for best
11094 // performance... now to specify that the user will have to
11095 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011096 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11097 eBand = eCSR_BAND_24;
11098 }
11099 else
11100 {
11101 // else, it's a 5.0GHz channel. Set mode to 11a.
11102 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11103 eBand = eCSR_BAND_5G;
11104 }
11105 break;
11106 }//switch
11107 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11108 else
11109 {
11110 //dot11 mode is set, lets pick the band
11111 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11112 {
11113 // channel is Auto also.
11114 eBand = pMac->roam.configParam.eBand;
11115 if(eCSR_BAND_ALL == eBand)
11116 {
11117 //prefer 5GHz
11118 eBand = eCSR_BAND_5G;
11119 }
11120 }
11121 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11122 {
11123 eBand = eCSR_BAND_24;
11124 }
11125 else
11126 {
11127 eBand = eCSR_BAND_5G;
11128 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011129 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011130 if(pBand)
11131 {
11132 *pBand = eBand;
11133 }
11134
11135 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011136 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011137 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11138 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011139
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011140 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11141 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 -070011142 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011143#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011144 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011145#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011146 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11147 {
11148 //We cannot do 11n here
11149 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11150 {
11151 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11152 }
11153 else
11154 {
11155 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11156 }
11157 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011158 return( cfgDot11Mode );
11159}
11160
Jeff Johnson295189b2012-06-20 16:38:30 -070011161eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11162{
11163 eHalStatus status;
11164 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011165
11166 if(!pSession)
11167 {
11168 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11169 return eHAL_STATUS_FAILURE;
11170 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011171
11172#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11173 {
11174 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011175 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11176 if(pIbssLog)
11177 {
11178 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11179 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11180 }
11181 }
11182#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011183 // Set the roaming substate to 'stop Bss request'...
11184 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11185
11186 // attempt to stop the Bss (reason code is ignored...)
11187 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011188 if(!HAL_STATUS_SUCCESS(status))
11189 {
11190 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11191 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011192 return (status);
11193}
11194
Jeff Johnson295189b2012-06-20 16:38:30 -070011195//pNumChan is a caller allocated space with the sizeof pChannels
11196eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11197{
11198
11199 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11200 (tANI_U8 *)pChannels,
11201 pNumChan));
11202}
11203
Kiran4a17ebe2013-01-31 10:43:43 -080011204tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11205{
11206 tANI_U32 cfgLength = 0;
11207 tANI_U16 cfgId = 0;
11208 tPowerdBm maxTxPwr = 0;
11209 tANI_U8 *pCountryInfo = NULL;
11210 eHalStatus status;
11211 tANI_U8 count = 0;
11212 tANI_U8 firstChannel;
11213 tANI_U8 maxChannels;
11214
11215 if (CSR_IS_CHANNEL_5GHZ(channel))
11216 {
11217 cfgId = WNI_CFG_MAX_TX_POWER_5;
11218 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11219 }
11220 else if (CSR_IS_CHANNEL_24GHZ(channel))
11221 {
11222 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11223 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11224 }
11225 else
11226 return maxTxPwr;
11227
Kiet Lam64c1b492013-07-12 13:56:44 +053011228 pCountryInfo = vos_mem_malloc(cfgLength);
11229 if ( NULL == pCountryInfo )
11230 status = eHAL_STATUS_FAILURE;
11231 else
11232 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011233 if (status != eHAL_STATUS_SUCCESS)
11234 {
11235 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011236 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011237 __FUNCTION__, status);
11238 goto error;
11239 }
11240 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11241 if (status != eHAL_STATUS_SUCCESS)
11242 {
11243 goto error;
11244 }
11245 /* Identify the channel and maxtxpower */
11246 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11247 {
11248 firstChannel = pCountryInfo[count++];
11249 maxChannels = pCountryInfo[count++];
11250 maxTxPwr = pCountryInfo[count++];
11251
11252 if ((channel >= firstChannel) &&
11253 (channel < (firstChannel + maxChannels)))
11254 {
11255 break;
11256 }
11257 }
11258
11259error:
11260 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011261 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011262
11263 return maxTxPwr;
11264}
11265
11266
Jeff Johnson295189b2012-06-20 16:38:30 -070011267tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11268{
11269 tANI_BOOLEAN fValid = FALSE;
11270 tANI_U32 idxValidChannels;
11271 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11272
11273 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11274 {
11275 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11276 {
11277 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11278 {
11279 fValid = TRUE;
11280 break;
11281 }
11282 }
11283 }
11284 pMac->roam.numValidChannels = len;
11285 return fValid;
11286}
11287
Jeff Johnson295189b2012-06-20 16:38:30 -070011288tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11289{
11290 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11291 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011292 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11293 {
11294 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11295 {
11296 fValid = eANI_BOOLEAN_TRUE;
11297 break;
11298 }
11299 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011300 return (fValid);
11301}
11302
Jeff Johnson295189b2012-06-20 16:38:30 -070011303//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011304 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011305{
Jeff Johnsone7245742012-09-05 17:12:55 -070011306 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011307 tANI_U8 centerChn;
11308 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011309
Jeff Johnson295189b2012-06-20 16:38:30 -070011310 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11311 {
11312 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11313 }
11314 else
11315 {
11316 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11317 }
11318 //Figure what the other side's CB mode
11319 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11320 {
11321 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11322 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011323 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11324 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11325 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11326 "\x00\x0f\xac\x02",4))
11327 //In Case WPA1 and TKIP is the only one cipher suite in Unicast.
11328 ||(pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
11329 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
11330 "\x00\x50\xf2\x02",4)))
11331
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011332 {
11333 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11334 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11335 }
11336
11337 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011338 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011339 /* This is called during INFRA STA/CLIENT and should use the merged value of
11340 * supported channel width and recommended tx width as per standard
11341 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011342 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011343 pIes->HTCaps.supportedChannelWidthSet,
11344 pIes->HTInfo.recommendedTxWidthSet,
11345 pIes->HTInfo.secondaryChannelOffset);
11346
11347 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11348 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011349 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011350 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11351 switch (eRet) {
11352 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11353 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11354 break;
11355 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11356 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11357 break;
11358 case PHY_SINGLE_CHANNEL_CENTERED:
11359 default:
11360 centerChn = primaryChn;
11361 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011362 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011363 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011364 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011365 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053011366 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011367 }
11368 }
11369 }
11370 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011371 return eRet;
11372}
Jeff Johnson295189b2012-06-20 16:38:30 -070011373tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11374{
11375 tANI_BOOLEAN fFound = FALSE;
11376 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011377 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11378 {
11379 if( pCipherList->encryptionType[idx] == encryptionType )
11380 {
11381 fFound = TRUE;
11382 break;
11383 }
11384 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011385 return fFound;
11386}
Jeff Johnson295189b2012-06-20 16:38:30 -070011387tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11388{
11389 tANI_BOOLEAN fFound = FALSE;
11390 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011391 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11392 {
11393 if( pAuthList->authType[idx] == authType )
11394 {
11395 fFound = TRUE;
11396 break;
11397 }
11398 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011399 return fFound;
11400}
Jeff Johnson295189b2012-06-20 16:38:30 -070011401tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11402{
11403 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11404 tCsrScanResultFilter *pScanFilter = NULL;
11405 eHalStatus status = eHAL_STATUS_SUCCESS;
11406
11407 if(pProfile1 && pProfile2)
11408 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011409 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11410 if ( NULL == pScanFilter )
11411 status = eHAL_STATUS_FAILURE;
11412 else
11413 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011414 if(HAL_STATUS_SUCCESS(status))
11415 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011416 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011417 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11418 if(HAL_STATUS_SUCCESS(status))
11419 {
11420 fCheck = eANI_BOOLEAN_FALSE;
11421 do
11422 {
11423 tANI_U32 i;
11424 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11425 {
11426 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11427 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11428 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11429 if ( fCheck ) break;
11430 }
11431 if(!fCheck)
11432 {
11433 break;
11434 }
11435 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11436 || pProfile2->BSSType != pProfile1->BSSType
11437 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11438 )
11439 {
11440 fCheck = eANI_BOOLEAN_FALSE;
11441 break;
11442 }
11443#ifdef WLAN_FEATURE_VOWIFI_11R
11444 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11445 {
11446 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11447 {
11448 fCheck = eANI_BOOLEAN_FALSE;
11449 break;
11450 }
11451 }
11452#endif
11453 //Match found
11454 fCheck = eANI_BOOLEAN_TRUE;
11455 }while(0);
11456 csrFreeScanFilter(pMac, pScanFilter);
11457 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011458 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011459 }
11460 }
11461
11462 return (fCheck);
11463}
11464
Jeff Johnson295189b2012-06-20 16:38:30 -070011465tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11466{
11467 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11468 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011469 do
11470 {
11471 //Only check for static WEP
11472 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11473 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11474 {
11475 fCheck = eANI_BOOLEAN_TRUE;
11476 break;
11477 }
11478 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11479 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11480 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11481 {
11482 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011483 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11484 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011485 {
11486 break;
11487 }
11488 }
11489 if( i == CSR_MAX_NUM_KEY)
11490 {
11491 fCheck = eANI_BOOLEAN_TRUE;
11492 }
11493 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011494 return (fCheck);
11495}
11496
Jeff Johnson295189b2012-06-20 16:38:30 -070011497//IBSS
11498
Jeff Johnson295189b2012-06-20 16:38:30 -070011499tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11500{
11501 tANI_U8 channel = 0;
11502 tANI_U32 idx;
11503 tANI_U32 idxValidChannels;
11504 tANI_BOOLEAN fFound = FALSE;
11505 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11506
11507 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11508 {
11509 channel = pMac->roam.configParam.AdHocChannel5G;
11510 if(!csrRoamIsChannelValid(pMac, channel))
11511 {
11512 channel = 0;
11513 }
11514 }
11515 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11516 {
11517 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11518 {
11519 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11520 {
11521 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11522 {
11523 fFound = TRUE;
11524 channel = csrStartIbssChannels50[ idx ];
11525 }
11526 }
11527 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011528 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11529 if (!fFound)
11530 {
11531 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11532 {
11533 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11534 {
11535 channel = csrStartIbssChannels50[ idx ];
11536 break;
11537 }
11538 }
11539 }
11540 }//if
11541
11542 return( channel );
11543}
11544
Jeff Johnson295189b2012-06-20 16:38:30 -070011545tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11546{
11547 tANI_U8 channel = 1;
11548 tANI_U32 idx;
11549 tANI_U32 idxValidChannels;
11550 tANI_BOOLEAN fFound = FALSE;
11551 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11552
11553 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11554 {
11555 channel = pMac->roam.configParam.AdHocChannel24;
11556 if(!csrRoamIsChannelValid(pMac, channel))
11557 {
11558 channel = 0;
11559 }
11560 }
11561
11562 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11563 {
11564 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11565 {
11566 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11567 {
11568 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11569 {
11570 fFound = TRUE;
11571 channel = csrStartIbssChannels24[ idx ];
11572 }
11573 }
11574 }
11575 }
11576
11577 return( channel );
11578}
11579
Jeff Johnson295189b2012-06-20 16:38:30 -070011580static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11581 tCsrRoamStartBssParams *pParam )
11582{
11583 eCsrCfgDot11Mode cfgDot11Mode;
11584 eCsrBand eBand;
11585 tANI_U8 channel = 0;
11586 tSirNwType nwType;
11587 tANI_U8 operationChannel = 0;
11588
11589 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11590 {
11591 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11592 }
11593
Jeff Johnson295189b2012-06-20 16:38:30 -070011594 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011595
Jeff Johnson295189b2012-06-20 16:38:30 -070011596 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11597 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11598 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11599 )
11600 {
11601 /* This should never happen */
11602 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011603 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011604 pProfile->csrPersona);
11605 VOS_ASSERT(0);
11606 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011607 switch( cfgDot11Mode )
11608 {
11609 case eCSR_CFG_DOT11_MODE_11G:
11610 nwType = eSIR_11G_NW_TYPE;
11611 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011612 case eCSR_CFG_DOT11_MODE_11B:
11613 nwType = eSIR_11B_NW_TYPE;
11614 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011615 case eCSR_CFG_DOT11_MODE_11A:
11616 nwType = eSIR_11A_NW_TYPE;
11617 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011618 default:
11619 case eCSR_CFG_DOT11_MODE_11N:
11620 case eCSR_CFG_DOT11_MODE_TAURUS:
11621 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11622 if(eCSR_BAND_24 == eBand)
11623 {
11624 nwType = eSIR_11G_NW_TYPE;
11625 }
11626 else
11627 {
11628 nwType = eSIR_11A_NW_TYPE;
11629 }
11630 break;
11631 }
11632
11633 pParam->extendedRateSet.numRates = 0;
11634
11635 switch ( nwType )
11636 {
11637 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011638 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011639 case eSIR_11A_NW_TYPE:
11640
11641 pParam->operationalRateSet.numRates = 8;
11642
11643 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11644 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11645 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11646 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11647 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11648 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11649 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11650 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11651
11652 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11653 {
11654 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11655 if( 0 == channel &&
11656 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11657 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11658 )
11659 {
11660 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11661 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11662 nwType = eSIR_11B_NW_TYPE;
11663 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11664 pParam->operationalRateSet.numRates = 4;
11665 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11666 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11667 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11668 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11669 }
11670 }
11671 else
11672 {
11673 channel = operationChannel;
11674 }
11675 break;
11676
11677 case eSIR_11B_NW_TYPE:
11678 pParam->operationalRateSet.numRates = 4;
11679 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11680 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11681 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11682 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011683 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11684 {
11685 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11686 }
11687 else
11688 {
11689 channel = operationChannel;
11690 }
11691
11692 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011693 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011694 /* For P2P Client and P2P GO, disable 11b rates */
11695 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11696 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11697 )
11698 {
11699 pParam->operationalRateSet.numRates = 8;
11700
11701 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11702 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11703 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11704 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11705 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11706 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11707 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11708 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11709 }
11710 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011711 {
11712 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011713 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11714 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11715 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11716 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11717
11718 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011719 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11720 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11721 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11722 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11723 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11724 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11725 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11726 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11727 }
11728
11729 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11730 {
11731 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11732 }
11733 else
11734 {
11735 channel = operationChannel;
11736 }
11737
11738 break;
11739 }
11740 pParam->operationChn = channel;
11741 pParam->sirNwType = nwType;
11742}
11743
Jeff Johnson295189b2012-06-20 16:38:30 -070011744static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11745 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11746{
11747
11748 if( pParam )
11749 {
11750 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011751 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011752 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011753 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011754
11755 if( pIes )
11756 {
11757 if(pIes->SuppRates.present)
11758 {
11759 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11760 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11761 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011762 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 -070011763 pIes->SuppRates.num_rates);
11764 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11765 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011766 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11767 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011768 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011769 if (pIes->ExtSuppRates.present)
11770 {
11771 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011772 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011773 {
11774 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11775 SIR_MAC_RATESET_EID_MAX, resetting to \
11776 SIR_MAC_RATESET_EID_MAX"),
11777 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011778 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011779 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011780 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011781 pIes->ExtSuppRates.rates,
11782 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11783 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011784 if( pIes->SSID.present )
11785 {
11786 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011787 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11788 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011789 }
11790 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011791 }
11792 else
11793 {
11794 pParam->ssId.length = 0;
11795 pParam->operationalRateSet.numRates = 0;
11796 }
11797 }
11798}
11799
Jeff Johnson295189b2012-06-20 16:38:30 -070011800static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11801{
11802 tANI_U8 MaxRate = 0;
11803 tANI_U32 i;
11804 tANI_U8 *pRate;
11805
11806 pRate = pSirRateSet->rate;
11807 for ( i = 0; i < pSirRateSet->numRates; i++ )
11808 {
11809 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11810 }
11811
11812 // Save the max rate in the connected state information...
11813
11814 // modify LastRates variable as well
11815
11816 return;
11817}
11818
Jeff Johnson295189b2012-06-20 16:38:30 -070011819eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11820 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11821{
11822 eHalStatus status = eHAL_STATUS_SUCCESS;
11823 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011824 // Set the roaming substate to 'Start BSS attempt'...
11825 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011826#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11827 //Need to figure out whether we need to log WDS???
11828 if( CSR_IS_IBSS( pProfile ) )
11829 {
11830 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011831 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11832 if(pIbssLog)
11833 {
11834 if(pBssDesc)
11835 {
11836 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011837 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011838 }
11839 else
11840 {
11841 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11842 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011843 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011844 if(pProfile->ChannelInfo.numOfChannels == 0)
11845 {
11846 pIbssLog->channelSetting = AUTO_PICK;
11847 }
11848 else
11849 {
11850 pIbssLog->channelSetting = SPECIFIED;
11851 }
11852 pIbssLog->operatingChannel = pParam->operationChn;
11853 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11854 }
11855 }
11856#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11857 //Put RSN information in for Starting BSS
Abhishek Singh3f9cbb72014-06-04 15:16:27 +053011858 if (pProfile->nRSNReqIELength && pProfile->pRSNReqIE) {
11859 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11860 pParam->pRSNIE = pProfile->pRSNReqIE;
11861 } else if (pProfile->nWPAReqIELength && pProfile->pWPAReqIE) {
11862 pParam->nRSNIELength = (tANI_U16)pProfile->nWPAReqIELength;
11863 pParam->pRSNIE = pProfile->pWPAReqIE;
11864 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011865
Jeff Johnson295189b2012-06-20 16:38:30 -070011866 pParam->privacy = pProfile->privacy;
11867 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11868 pParam->authType = pProfile->csr80211AuthType;
11869 pParam->beaconInterval = pProfile->beaconInterval;
11870 pParam->dtimPeriod = pProfile->dtimPeriod;
11871 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11872 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11873 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11874 {
11875 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11876 {
11877 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11878 }
11879 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011880 pParam->protEnabled = pProfile->protEnabled;
11881 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11882 pParam->ht_protection = pProfile->cfg_protection;
11883 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011884
Jeff Johnson295189b2012-06-20 16:38:30 -070011885 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11886 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011887 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080011888
11889#ifdef WLAN_FEATURE_11W
11890 pParam->mfpCapable = (0 != pProfile->MFPCapable);
11891 pParam->mfpRequired = (0 != pProfile->MFPRequired);
11892#endif
11893
Jeff Johnson295189b2012-06-20 16:38:30 -070011894 // When starting an IBSS, start on the channel from the Profile.
11895 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011896 return (status);
11897}
11898
Jeff Johnson295189b2012-06-20 16:38:30 -070011899static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011900 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011901{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011902 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011903 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011904 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011905
11906 if(!pSession)
11907 {
11908 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11909 return;
11910 }
11911
Jeff Johnson295189b2012-06-20 16:38:30 -070011912 if( pBssDesc )
11913 {
11914 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11915 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11916 //The following code has to be do after that.
11917 //For WDS station, use selfMac as the self BSSID
11918 if( CSR_IS_WDS_STA( pProfile ) )
11919 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011920 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11921 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011922 }
11923 }
11924 else
11925 {
11926 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011927 //Use the first SSID
11928 if(pProfile->SSIDs.numOfSSIDs)
11929 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011930 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11931 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011932 }
11933 //For WDS station, use selfMac as the self BSSID
11934 if( CSR_IS_WDS_STA( pProfile ) )
11935 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011936 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11937 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011938 }
11939 //Use the first BSSID
11940 else if( pProfile->BSSIDs.numOfBSSIDs )
11941 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011942 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11943 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011944 }
11945 else
11946 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011947 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011948 }
11949 }
11950 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011951 //Set operating channel in pProfile which will be used
11952 //in csrRoamSetBssConfigCfg() to determine channel bonding
11953 //mode and will be configured in CFG later
11954 pProfile->operationChannel = Channel;
11955
11956 if(Channel == 0)
11957 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053011958 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011959 }
11960 else
11961 {
11962
11963 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011964 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011965 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011966 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011967 {
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053011968 /* TODO- SAP: HT40 Support in SAP 2.4Ghz mode is not enabled.
11969 so channel bonding in 2.4Ghz is configured as 20MHZ
11970 irrespective of the 'channelBondingMode24GHz' Parameter */
11971 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -070011972 }
11973 else
11974 {
11975 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11976 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011977 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011978 pBssConfig->cbMode = cbMode;
11979 pSession->bssParams.cbMode = cbMode;
11980 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011981 }
11982}
11983
Jeff Johnson295189b2012-06-20 16:38:30 -070011984static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11985 tANI_BOOLEAN *pfSameIbss )
11986{
11987 eHalStatus status = eHAL_STATUS_SUCCESS;
11988 tANI_BOOLEAN fSameIbss = FALSE;
11989
11990 if ( csrIsConnStateIbss( pMac, sessionId ) )
11991 {
11992 // Check if any profile parameter has changed ? If any profile parameter
11993 // has changed then stop old BSS and start a new one with new parameters
11994 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11995 {
11996 fSameIbss = TRUE;
11997 }
11998 else
11999 {
12000 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12001 }
12002 }
12003 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12004 {
12005 // Disassociate from the connected Infrastructure network...
12006 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12007 }
12008 else
12009 {
12010 tBssConfigParam *pBssConfig;
12011
Kiet Lam64c1b492013-07-12 13:56:44 +053012012 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12013 if ( NULL == pBssConfig )
12014 status = eHAL_STATUS_FAILURE;
12015 else
12016 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012017 if(HAL_STATUS_SUCCESS(status))
12018 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012019 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012020 // there is no Bss description before we start an IBSS so we need to adopt
12021 // all Bss configuration parameters from the Profile.
12022 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12023 if(HAL_STATUS_SUCCESS(status))
12024 {
12025 //save dotMode
12026 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12027 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012028 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012029 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12030 NULL, pBssConfig,
12031 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012032 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012033
12034 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012035 }//Allocate memory
12036 }
12037
12038 if(pfSameIbss)
12039 {
12040 *pfSameIbss = fSameIbss;
12041 }
12042 return( status );
12043}
12044
Jeff Johnson295189b2012-06-20 16:38:30 -070012045static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12046 tSirSmeNewBssInfo *pNewBss )
12047{
12048 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012049
12050 if(!pSession)
12051 {
12052 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12053 return;
12054 }
12055
Jeff Johnson295189b2012-06-20 16:38:30 -070012056 if( pNewBss )
12057 {
12058 // Set the operating channel.
12059 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12060 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012061 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12062 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012063 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012064 return;
12065}
12066
Jeff Johnson295189b2012-06-20 16:38:30 -070012067#ifdef FEATURE_WLAN_WAPI
12068eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12069 tANI_U32 numItems )
12070{
12071 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12072 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012073 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12074 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012075 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012076 return status;
12077 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012078 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012079 pSession = CSR_GET_SESSION( pMac, sessionId );
12080 if(numItems <= CSR_MAX_BKID_ALLOWED)
12081 {
12082 status = eHAL_STATUS_SUCCESS;
12083 //numItems may be 0 to clear the cache
12084 pSession->NumBkidCache = (tANI_U16)numItems;
12085 if(numItems && pBKIDCache)
12086 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012087 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12088 sizeof(tBkidCacheInfo) * numItems);
12089 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012090 }
12091 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012092 return (status);
12093}
Jeff Johnson295189b2012-06-20 16:38:30 -070012094eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12095 tBkidCacheInfo *pBkidCache)
12096{
12097 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12098 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012099 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12100 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012101 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012102 return status;
12103 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012104 pSession = CSR_GET_SESSION( pMac, sessionId );
12105 if(pNum && pBkidCache)
12106 {
12107 if(pSession->NumBkidCache == 0)
12108 {
12109 *pNum = 0;
12110 status = eHAL_STATUS_SUCCESS;
12111 }
12112 else if(*pNum >= pSession->NumBkidCache)
12113 {
12114 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
12115 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012116 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 -070012117 pSession->NumBkidCache);
12118 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
12119 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012120 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12121 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012122 *pNum = pSession->NumBkidCache;
12123 status = eHAL_STATUS_SUCCESS;
12124 }
12125 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012126 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012127}
Jeff Johnson295189b2012-06-20 16:38:30 -070012128tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12129{
12130 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012131}
12132#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012133eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
12134 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
12135{
12136 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12137 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012138
12139 if(!pSession)
12140 {
12141 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12142 return eHAL_STATUS_FAILURE;
12143 }
12144
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012145 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012146 if(numItems <= CSR_MAX_PMKID_ALLOWED)
12147 {
12148#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12149 {
12150 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012151 vos_mem_set(&secEvent,
12152 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012153 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12154 secEvent.encryptionModeMulticast =
12155 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12156 secEvent.encryptionModeUnicast =
12157 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012158 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012159 secEvent.authMode =
12160 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12161 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12162 }
12163#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012164 status = eHAL_STATUS_SUCCESS;
12165 //numItems may be 0 to clear the cache
12166 pSession->NumPmkidCache = (tANI_U16)numItems;
12167 if(numItems && pPMKIDCache)
12168 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012169 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12170 sizeof(tPmkidCacheInfo) * numItems);
12171 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012172 }
12173 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012174 return (status);
12175}
12176
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012177eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
12178 tANI_U8 *pBSSId )
12179{
12180 eHalStatus status = eHAL_STATUS_FAILURE;
12181 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12182 tANI_BOOLEAN fMatchFound = FALSE;
12183 tANI_U32 Index;
12184 if(!pSession)
12185 {
12186 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12187 return eHAL_STATUS_FAILURE;
12188 }
12189 do
12190 {
12191 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
12192 {
Arif Hussaina7c8e412013-11-20 11:06:42 -080012193 smsLog(pMac, LOGW, "Delete PMKID for "
12194 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Kiet Lamf2f201e2013-11-16 21:24:16 +053012195 if( vos_mem_compare( pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012196 {
12197 fMatchFound = TRUE;
12198 break;
12199 }
12200 }
12201 if( !fMatchFound ) break;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012202 vos_mem_set(pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid), 0);
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012203 status = eHAL_STATUS_SUCCESS;
12204 }
12205 while( 0 );
12206 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
12207 fMatchFound, status);
12208 return status;
12209}
Jeff Johnson295189b2012-06-20 16:38:30 -070012210tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12211{
12212 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12213}
12214
Jeff Johnson295189b2012-06-20 16:38:30 -070012215eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12216{
12217 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12218 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012219
12220 if(!pSession)
12221 {
12222 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12223 return eHAL_STATUS_FAILURE;
12224 }
12225
Jeff Johnson295189b2012-06-20 16:38:30 -070012226 if(pNum && pPmkidCache)
12227 {
12228 if(pSession->NumPmkidCache == 0)
12229 {
12230 *pNum = 0;
12231 status = eHAL_STATUS_SUCCESS;
12232 }
12233 else if(*pNum >= pSession->NumPmkidCache)
12234 {
12235 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12236 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012237 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 -070012238 pSession->NumPmkidCache);
12239 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12240 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012241 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
12242 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012243 *pNum = pSession->NumPmkidCache;
12244 status = eHAL_STATUS_SUCCESS;
12245 }
12246 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012247 return (status);
12248}
12249
Jeff Johnson295189b2012-06-20 16:38:30 -070012250eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12251{
12252 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12253 tANI_U32 len;
12254 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012255
12256 if(!pSession)
12257 {
12258 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12259 return eHAL_STATUS_FAILURE;
12260 }
12261
Jeff Johnson295189b2012-06-20 16:38:30 -070012262 if(pLen)
12263 {
12264 len = *pLen;
12265 *pLen = pSession->nWpaRsnReqIeLength;
12266 if(pBuf)
12267 {
12268 if(len >= pSession->nWpaRsnReqIeLength)
12269 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012270 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12271 pSession->nWpaRsnReqIeLength);
12272 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012273 }
12274 }
12275 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012276 return (status);
12277}
12278
Jeff Johnson295189b2012-06-20 16:38:30 -070012279eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12280{
12281 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12282 tANI_U32 len;
12283 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012284
12285 if(!pSession)
12286 {
12287 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12288 return eHAL_STATUS_FAILURE;
12289 }
12290
Jeff Johnson295189b2012-06-20 16:38:30 -070012291 if(pLen)
12292 {
12293 len = *pLen;
12294 *pLen = pSession->nWpaRsnRspIeLength;
12295 if(pBuf)
12296 {
12297 if(len >= pSession->nWpaRsnRspIeLength)
12298 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012299 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12300 pSession->nWpaRsnRspIeLength);
12301 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012302 }
12303 }
12304 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012305 return (status);
12306}
Jeff Johnson295189b2012-06-20 16:38:30 -070012307#ifdef FEATURE_WLAN_WAPI
12308eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12309{
12310 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12311 tANI_U32 len;
12312 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012313
12314 if(!pSession)
12315 {
12316 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12317 return eHAL_STATUS_FAILURE;
12318 }
12319
Jeff Johnson295189b2012-06-20 16:38:30 -070012320 if(pLen)
12321 {
12322 len = *pLen;
12323 *pLen = pSession->nWapiReqIeLength;
12324 if(pBuf)
12325 {
12326 if(len >= pSession->nWapiReqIeLength)
12327 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012328 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12329 pSession->nWapiReqIeLength);
12330 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012331 }
12332 }
12333 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012334 return (status);
12335}
Jeff Johnson295189b2012-06-20 16:38:30 -070012336eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12337{
12338 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12339 tANI_U32 len;
12340 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012341
12342 if(!pSession)
12343 {
12344 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12345 return eHAL_STATUS_FAILURE;
12346 }
12347
Jeff Johnson295189b2012-06-20 16:38:30 -070012348 if(pLen)
12349 {
12350 len = *pLen;
12351 *pLen = pSession->nWapiRspIeLength;
12352 if(pBuf)
12353 {
12354 if(len >= pSession->nWapiRspIeLength)
12355 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012356 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12357 pSession->nWapiRspIeLength);
12358 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012359 }
12360 }
12361 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012362 return (status);
12363}
12364#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012365eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12366{
12367 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12368 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012369
12370 if(!pSession)
12371 {
12372 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12373 return (retStatus);
12374 }
12375
Jeff Johnson295189b2012-06-20 16:38:30 -070012376 if(CSR_IS_ROAMING(pSession))
12377 {
12378 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12379 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12380 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012381 return (retStatus);
12382}
12383
Jeff Johnson295189b2012-06-20 16:38:30 -070012384//This function remove the connected BSS from te cached scan result
12385eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12386 tCsrRoamConnectedProfile *pConnProfile)
12387{
12388 eHalStatus status = eHAL_STATUS_FAILURE;
12389 tCsrScanResultFilter *pScanFilter = NULL;
12390 tListElem *pEntry;
12391 tCsrScanResult *pResult;
12392 tDot11fBeaconIEs *pIes;
12393 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12395 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12396 {
12397 do
12398 {
12399 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012400 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12401 if ( NULL == pScanFilter )
12402 status = eHAL_STATUS_FAILURE;
12403 else
12404 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012405 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012406 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12407 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12408 if ( NULL == pScanFilter->BSSIDs.bssid )
12409 status = eHAL_STATUS_FAILURE;
12410 else
12411 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012412 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012413 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12414 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012415 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12416 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12417 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012418 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12419 if ( NULL == pScanFilter->SSIDs.SSIDList )
12420 status = eHAL_STATUS_FAILURE;
12421 else
12422 status = eHAL_STATUS_SUCCESS;
12423 if (!HAL_STATUS_SUCCESS(status)) break;
12424 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12425 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012426 }
12427 pScanFilter->authType.numEntries = 1;
12428 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12429 pScanFilter->BSSType = pConnProfile->BSSType;
12430 pScanFilter->EncryptionType.numEntries = 1;
12431 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12432 pScanFilter->mcEncryptionType.numEntries = 1;
12433 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12434 //We ignore the channel for now, BSSID should be enough
12435 pScanFilter->ChannelInfo.numOfChannels = 0;
12436 //Also ignore the following fields
12437 pScanFilter->uapsd_mask = 0;
12438 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012439 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012440 pScanFilter->countryCode[0] = 0;
12441 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012442 csrLLLock(&pMac->scan.scanResultList);
12443 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12444 while( pEntry )
12445 {
12446 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12447 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12448 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12449 pScanFilter, NULL, NULL, NULL, &pIes);
12450 //Release the IEs allocated by csrMatchBSS is needed
12451 if( !pResult->Result.pvIes )
12452 {
12453 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012454 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012455 }
12456 if(fMatch)
12457 {
12458 //We found the one
12459 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12460 {
12461 //Free the memory
12462 csrFreeScanResultEntry( pMac, pResult );
12463 }
12464 break;
12465 }
12466 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12467 }//while
12468 csrLLUnlock(&pMac->scan.scanResultList);
12469 }while(0);
12470 if(pScanFilter)
12471 {
12472 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012473 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012474 }
12475 }
12476 return (status);
12477}
12478
Jeff Johnson295189b2012-06-20 16:38:30 -070012479//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012480eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12481{
12482 eHalStatus status = eHAL_STATUS_SUCCESS;
12483 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012484 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12485 {
12486 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12487 {
12488 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12489 {
12490 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012491 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012492 status = eHAL_STATUS_CSR_WRONG_STATE;
12493 break;
12494 }
12495 if( csrIsConnStateInfra( pMac, sessionId ) )
12496 {
12497 if( chnId &&
12498 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12499 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012500 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012501 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12502 status = eHAL_STATUS_CSR_WRONG_STATE;
12503 break;
12504 }
12505 }
12506 }
12507 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012508 return ( status );
12509}
12510
Jeff Johnson295189b2012-06-20 16:38:30 -070012511static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12512{
12513 eHalStatus status = eHAL_STATUS_SUCCESS;
12514 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12515 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012516
12517 if(!pSession)
12518 {
12519 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12520 return eHAL_STATUS_FAILURE;
12521 }
12522
Jeff Johnson295189b2012-06-20 16:38:30 -070012523 if ( csrIsConnStateIbss( pMac, sessionId ) )
12524 {
12525 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12526 }
12527 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12528 {
12529 // Disassociate from the connected Infrastructure network...
12530 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12531 }
12532 else
12533 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012534 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12535 //Otherwise we need to add code to handle the
12536 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12537 //send stop_bss to PE, before we can continue.
12538 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012539 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012540 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012541 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12542 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012543 // there is no Bss description before we start an WDS so we need
12544 // to adopt all Bss configuration parameters from the Profile.
12545 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12546 if(HAL_STATUS_SUCCESS(status))
12547 {
12548 //Save profile for late use
12549 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012550 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12551 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012552 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012553 vos_mem_set(pSession->pCurRoamProfile,
12554 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012555 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12556 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012557 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012558 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012559 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12560 NULL, &bssConfig,
12561 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012562 }
12563 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012564
Jeff Johnson295189b2012-06-20 16:38:30 -070012565 return( status );
12566}
12567
Jeff Johnson295189b2012-06-20 16:38:30 -070012568////////////////////Mail box
12569
Jeff Johnson295189b2012-06-20 16:38:30 -070012570//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12571//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012572static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12573 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12575{
12576 tCsrChannelSet channelGroup;
12577 tSirMacCapabilityInfo *pAP_capabilityInfo;
12578 tAniBool fTmp;
12579 tANI_BOOLEAN found = FALSE;
12580 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012581 tANI_S8 pwrLimit = 0;
12582 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012583 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12584 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12585 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12586 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012587 // 802.11h
12588 //We can do this because it is in HOST CPU order for now.
12589 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012590 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12591 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12592 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012593 fTmp = (tAniBool)pal_cpu_to_be32(1);
12594 }
12595 else
12596 fTmp = (tAniBool)0;
12597
12598 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012599 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012600 pBuf += sizeof(tAniBool);
12601 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012602 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012603 // This is required for 11k test VoWiFi Ent: Test 2.
12604 // We need the power capabilities for Assoc Req.
12605 // This macro is provided by the halPhyCfg.h. We pick our
12606 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012607 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12608 if (0 != pwrLimit)
12609 {
12610 *pBuf++ = pwrLimit;
12611 }
12612 else
12613 {
12614 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12615 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012616 size = sizeof(pMac->roam.validChannelList);
12617 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12618 {
12619 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12620 for ( i = 0; i < size; i++)
12621 {
12622 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12623
12624 }
12625 }
12626 else
12627 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012628 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012629 *pBuf++ = 0; //tSirSupChnl->numChnl
12630 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012631 //Check whether it is ok to enter UAPSD
12632#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12633 if( btcIsReadyForUapsd(pMac) )
12634#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12635 {
12636 *pBuf++ = uapsdMask;
12637 }
12638#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12639 else
12640 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012641 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012642 *pBuf++ = 0;
12643 }
12644#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12645
Jeff Johnson295189b2012-06-20 16:38:30 -070012646 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012647 vos_mem_copy(pBuf, pBssDescription,
12648 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012649 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12650}
12651
Jeff Johnson295189b2012-06-20 16:38:30 -070012652/*
12653 * The communication between HDD and LIM is thru mailbox (MB).
12654 * Both sides will access the data structure "tSirSmeJoinReq".
12655 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12656 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12657 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12658 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12659 */
12660eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012661 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012662{
12663 eHalStatus status = eHAL_STATUS_SUCCESS;
12664 tSirSmeJoinReq *pMsg;
12665 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012666 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012667 tANI_U16 msgLen, wTmp, ieLen;
12668 tSirMacRateSet OpRateSet;
12669 tSirMacRateSet ExRateSet;
12670 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12671 tANI_U32 dwTmp;
12672 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012673 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012674
12675 if(!pSession)
12676 {
12677 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12678 return eHAL_STATUS_FAILURE;
12679 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012680 /* To satisfy klockworks */
12681 if (NULL == pBssDescription)
12682 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012683 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012684 return eHAL_STATUS_FAILURE;
12685 }
12686
Jeff Johnson295189b2012-06-20 16:38:30 -070012687 do {
12688 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12689 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053012690 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012691 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12692 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12693 // IE fields, but the length field in the bssDescription needs to be interpreted to
12694 // determine length of the IE fields.
12695 //
12696 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12697 // add in the length from the bssDescription (then add the size of the 'length' field
12698 // itself because that is NOT included in the length field).
12699 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12700 pBssDescription->length + sizeof( pBssDescription->length ) +
12701 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 +053012702 pMsg = vos_mem_malloc(msgLen);
12703 if (NULL == pMsg)
12704 status = eHAL_STATUS_FAILURE;
12705 else
12706 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012707 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012708 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012709 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012710 pMsg->length = pal_cpu_to_be16(msgLen);
12711 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012712 // sessionId
12713 *pBuf = (tANI_U8)sessionId;
12714 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012715 // transactionId
12716 *pBuf = 0;
12717 *( pBuf + 1 ) = 0;
12718 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012719 // ssId
12720 if( pIes->SSID.present && pIes->SSID.num_ssid )
12721 {
12722 // ssId len
12723 *pBuf = pIes->SSID.num_ssid;
12724 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012725 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012726 pBuf += pIes->SSID.num_ssid;
12727 }
12728 else
12729 {
12730 *pBuf = 0;
12731 pBuf++;
12732 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012733 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012734 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12735 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012736 pBuf += sizeof(tSirMacAddr);
12737 // bsstype
12738 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12739 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012740 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012741 pBuf += sizeof(tSirBssType);
12742 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012743 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12744 if (pBssDescription->channelId <= 14 &&
12745 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12746 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12747 {
12748 //Need to disable VHT operation in 2.4 GHz band
12749 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12750 }
12751 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012752 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012753 //Persona
12754 *pBuf = (tANI_U8)pProfile->csrPersona;
12755 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012756 //CBMode
12757 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12758 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012759
12760 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012761 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12762
Jeff Johnson295189b2012-06-20 16:38:30 -070012763 // uapsdPerAcBitmask
12764 *pBuf = pProfile->uapsd_mask;
12765 pBuf++;
12766
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012767
12768
Jeff Johnson295189b2012-06-20 16:38:30 -070012769 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012770 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012771 {
12772 // OperationalRateSet
12773 if (OpRateSet.numRates) {
12774 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012775 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012776 pBuf += OpRateSet.numRates;
12777 } else *pBuf++ = 0;
12778 // ExtendedRateSet
12779 if (ExRateSet.numRates) {
12780 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012781 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012782 pBuf += ExRateSet.numRates;
12783 } else *pBuf++ = 0;
12784 }
12785 else
12786 {
12787 *pBuf++ = 0;
12788 *pBuf++ = 0;
12789 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012790 // rsnIE
12791 if ( csrIsProfileWpa( pProfile ) )
12792 {
12793 // Insert the Wpa IE into the join request
12794 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12795 (tCsrWpaIe *)( wpaRsnIE ) );
12796 }
12797 else if( csrIsProfileRSN( pProfile ) )
12798 {
12799 // Insert the RSN IE into the join request
12800 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12801 (tCsrRSNIe *)( wpaRsnIE ) );
12802 }
12803#ifdef FEATURE_WLAN_WAPI
12804 else if( csrIsProfileWapi( pProfile ) )
12805 {
12806 // Insert the WAPI IE into the join request
12807 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12808 (tCsrWapiIe *)( wpaRsnIE ) );
12809 }
12810#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012811 else
12812 {
12813 ieLen = 0;
12814 }
12815 //remember the IE for future use
12816 if( ieLen )
12817 {
12818 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12819 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012820 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 -070012821 ieLen = DOT11F_IE_RSN_MAX_LEN;
12822 }
12823#ifdef FEATURE_WLAN_WAPI
12824 if( csrIsProfileWapi( pProfile ) )
12825 {
12826 //Check whether we need to allocate more memory
12827 if(ieLen > pSession->nWapiReqIeLength)
12828 {
12829 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12830 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012831 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012832 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012833 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12834 if (NULL == pSession->pWapiReqIE)
12835 status = eHAL_STATUS_FAILURE;
12836 else
12837 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 if(!HAL_STATUS_SUCCESS(status)) break;
12839 }
12840 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012841 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012842 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012843 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012844 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012845 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012846 pBuf += ieLen;
12847 }
12848 else//should be WPA/WPA2 otherwise
12849#endif /* FEATURE_WLAN_WAPI */
12850 {
12851 //Check whether we need to allocate more memory
12852 if(ieLen > pSession->nWpaRsnReqIeLength)
12853 {
12854 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12855 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012856 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012857 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012858 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12859 if (NULL == pSession->pWpaRsnReqIE)
12860 status = eHAL_STATUS_FAILURE;
12861 else
12862 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012863 if(!HAL_STATUS_SUCCESS(status)) break;
12864 }
12865 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012866 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012867 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012868 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012869 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012870 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012871 pBuf += ieLen;
12872 }
12873 }
12874 else
12875 {
12876 //free whatever old info
12877 pSession->nWpaRsnReqIeLength = 0;
12878 if(pSession->pWpaRsnReqIE)
12879 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012880 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012881 pSession->pWpaRsnReqIE = NULL;
12882 }
12883#ifdef FEATURE_WLAN_WAPI
12884 pSession->nWapiReqIeLength = 0;
12885 if(pSession->pWapiReqIE)
12886 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012887 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012888 pSession->pWapiReqIE = NULL;
12889 }
12890#endif /* FEATURE_WLAN_WAPI */
12891 //length is two bytes
12892 *pBuf = 0;
12893 *(pBuf + 1) = 0;
12894 pBuf += 2;
12895 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012896#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012897 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012898 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012899 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012900 //length is two bytes
12901 *pBuf = 0;
12902 *(pBuf + 1) = 0;
12903 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012904 }
12905 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012906 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012907 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012908 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012909 {
12910 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012911#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012912 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080012913 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012914 pSession->suppCckmIeInfo.cckmIe, ieLen);
12915#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012916 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012917 pSession,
12918 pProfile,
12919 pBssDescription,
12920 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012921 pSession->nWpaRsnReqIeLength,
12922 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012923#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012924 }
12925 else
12926 {
12927 ieLen = 0;
12928 }
12929 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12930 if( ieLen )
12931 {
12932 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12933 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012934 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012935 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012936 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012937 pBuf += ieLen;
12938 }
12939 else
12940 {
12941 //Indicate you have no CCKM IE
12942 //length is two bytes
12943 *pBuf = 0;
12944 *(pBuf + 1) = 0;
12945 pBuf += 2;
12946 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012947 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012948#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070012949 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053012950 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070012951 {
12952 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012953 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012954 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012955 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012956 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012957 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012958 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053012959 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012960 pBuf += ieLen;
12961 }
12962 else
12963 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053012964 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012965 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012966 *pBuf = 0;
12967 *(pBuf + 1) = 0;
12968 pBuf += 2;
12969 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012970 // addIEAssoc
12971 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12972 {
12973 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012974 if(ieLen > pSession->nAddIEAssocLength)
12975 {
12976 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012977 {
12978 vos_mem_free(pSession->pAddIEAssoc);
12979 }
12980 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12981 if (NULL == pSession->pAddIEAssoc)
12982 status = eHAL_STATUS_FAILURE;
12983 else
12984 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012985 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012986 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012987 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012988 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012989 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012990 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012991 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012992 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012993 pBuf += ieLen;
12994 }
12995 else
12996 {
12997 pSession->nAddIEAssocLength = 0;
12998 if(pSession->pAddIEAssoc)
12999 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013000 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013001 pSession->pAddIEAssoc = NULL;
13002 }
13003 *pBuf = 0;
13004 *(pBuf + 1) = 0;
13005 pBuf += 2;
13006 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013007
13008 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013009 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013010 //Unmask any AC in reassoc that is ACM-set
13011 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13012 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013013 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013014 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13015 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013016#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013017 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013018#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013019 }
13020 else
13021 {
13022 uapsd_mask = 0;
13023 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013024 }
13025 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013026
Jeff Johnson295189b2012-06-20 16:38:30 -070013027 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013028 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013029 pBuf += sizeof(tANI_U32);
13030
Jeff Johnson295189b2012-06-20 16:38:30 -070013031 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013032 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013033 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013034#ifdef WLAN_FEATURE_11W
13035 //MgmtEncryption
13036 if (pProfile->MFPEnabled)
13037 {
13038 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13039 }
13040 else
13041 {
13042 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13043 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013044 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013045 pBuf += sizeof(tANI_U32);
13046#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013047#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013048 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013049 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013050#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013051 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013052 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013053#endif
13054 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013055 {
13056 // is11Rconnection;
13057 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013058 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013059 pBuf += sizeof(tAniBool);
13060 }
13061 else
13062 {
13063 // is11Rconnection;
13064 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013065 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013066 pBuf += sizeof(tAniBool);
13067 }
13068#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013069#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013070
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013071 // isESEFeatureIniEnabled
13072 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013073 {
13074 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013075 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013076 pBuf += sizeof(tAniBool);
13077 }
13078 else
13079 {
13080 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013081 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013082 pBuf += sizeof(tAniBool);
13083 }
13084
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013085 /* A profile can not be both ESE and 11R. But an 802.11R AP
13086 * may be advertising support for ESE as well. So if we are
13087 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013088 * If we are associating explictly 11R only then we will get
13089 * 11R.
13090 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013091 if ((csrIsProfileESE(pProfile) ||
13092 ((pIes->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +053013093 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013094 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013095 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013096 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013097 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013098 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013099 pBuf += sizeof(tAniBool);
13100 }
13101 else
13102 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013103 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013104 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013105 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013106 pBuf += sizeof(tAniBool);
13107 }
13108
13109 if (eWNI_SME_JOIN_REQ == messageType)
13110 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013111 tESETspecInfo eseTspec;
13112 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013113 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013114 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13115 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13116 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013117 }
13118 else if (eWNI_SME_REASSOC_REQ == messageType)
13119 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013120 if ((csrIsProfileESE(pProfile) ||
13121 ((pIes->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +053013122 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013123 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013124 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013125 tESETspecInfo eseTspec;
13126 // ESE Tspec information
13127 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13128 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13129 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013130 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013131 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013132 if (eseTspec.numTspecs) {
13133 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13134 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013135 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013136 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013137 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013138 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013139 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013140 tESETspecInfo eseTspec;
13141 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013142 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013143 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13144 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13145 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013146 }
13147 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013148#endif // FEATURE_WLAN_ESE
13149#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013150 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013151 if (pMac->roam.configParam.isFastTransitionEnabled
13152#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013153 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013154#endif
13155 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013157 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013158 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013159 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013160 }
13161 else
13162 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013163 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013164 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013165 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013166 }
13167#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013168#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013169 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013170 {
13171 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013172 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013173 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013174 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013175 }
13176 else
13177 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013178 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013179 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013180 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013181 }
13182#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013183
13184 // txLdpcIniFeatureEnabled
13185 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13186 pBuf++;
13187
Kiran4a17ebe2013-01-31 10:43:43 -080013188 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13189 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13190 {
13191 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13192 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13193 csrApplyPower2Current(pMac);
13194 }
13195
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013196#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013197 // txBFIniFeatureEnabled
13198 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13199 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013200
13201 // txBFCsnValue
13202 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13203 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053013204
13205 /* Only enable MuBf if no other MuBF session exist
13206 * and FW and HOST is MuBF capable.
13207 */
13208 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
13209 {
13210 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
13211 pBuf++;
13212 }
13213 else
13214 {
13215 *pBuf = 0;
13216 pBuf++;
13217 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013218#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013219 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13220 pBuf++;
13221
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013222 // WME
13223 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13224 {
13225 //WME enabled
13226 dwTmp = pal_cpu_to_be32(TRUE);
13227 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13228 pBuf += sizeof(tAniBool);
13229 }
13230 else
13231 {
13232 dwTmp = pal_cpu_to_be32(FALSE);
13233 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13234 pBuf += sizeof(tAniBool);
13235 }
13236
13237 // QOS
13238 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13239 {
13240 //QOS enabled
13241 dwTmp = pal_cpu_to_be32(TRUE);
13242 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13243 pBuf += sizeof(tAniBool);
13244 }
13245 else
13246 {
13247 dwTmp = pal_cpu_to_be32(FALSE);
13248 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13249 pBuf += sizeof(tAniBool);
13250 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013251 //BssDesc
13252 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13253 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013254
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013255 status = palSendMBMessage(pMac->hHdd, pMsg );
13256 if(!HAL_STATUS_SUCCESS(status))
13257 {
13258 break;
13259 }
13260 else
13261 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013262#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013263 if (eWNI_SME_JOIN_REQ == messageType)
13264 {
13265 //Tush-QoS: notify QoS module that join happening
13266 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13267 }
13268 else if (eWNI_SME_REASSOC_REQ == messageType)
13269 {
13270 //Tush-QoS: notify QoS module that reassoc happening
13271 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13272 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013273#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013274 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013275 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013276 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013277}
13278
Jeff Johnson295189b2012-06-20 16:38:30 -070013279//
13280eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13281{
13282 eHalStatus status = eHAL_STATUS_SUCCESS;
13283 tSirSmeDisassocReq *pMsg;
13284 tANI_U8 *pBuf;
13285 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013286 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13287 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13288 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013289 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013290 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13291 if (NULL == pMsg)
13292 status = eHAL_STATUS_FAILURE;
13293 else
13294 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013295 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013296 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013297 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13298 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013299 pBuf = &pMsg->sessionId;
13300 // sessionId
13301 *pBuf++ = (tANI_U8)sessionId;
13302 // transactionId
13303 *pBuf = 0;
13304 *( pBuf + 1 ) = 0;
13305 pBuf += sizeof(tANI_U16);
13306
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013307 if ( (pSession->pCurRoamProfile != NULL) &&
13308 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13309 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 {
13311 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013312 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13313 sizeof( tSirMacAddr ));
13314 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013315 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013317 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13318 //perMacAddr is passed as bssId for softAP
13319 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013320 pBuf = pBuf + sizeof ( tSirMacAddr );
13321 }
13322 else
13323 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013324 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013325 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13326 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013327 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013328 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13329 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013330 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013331 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013332 if(!HAL_STATUS_SUCCESS(status))
13333 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013334 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013335 break;
13336 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013337 // reasonCode
13338 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013339 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13340 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013341 if(!HAL_STATUS_SUCCESS(status))
13342 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013343 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013344 break;
13345 }
13346 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013347 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13348 Here we should not send the disassoc over the air to the AP */
13349 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13350#ifdef WLAN_FEATURE_VOWIFI_11R
13351 && csrRoamIs11rAssoc(pMac)
13352#endif
13353 )
13354 {
13355 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13356 }
13357 pBuf += sizeof(tANI_U8);
13358 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013359 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013360 return( status );
13361}
Jeff Johnson295189b2012-06-20 16:38:30 -070013362eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13363{
13364 eHalStatus status = eHAL_STATUS_SUCCESS;
13365 tSirSmeTkipCntrMeasReq *pMsg;
13366 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013367 do
13368 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013369 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13370 if ( NULL == pMsg )
13371 status = eHAL_STATUS_FAILURE;
13372 else
13373 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013374 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013375 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013376 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13377 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013378 pBuf = &pMsg->sessionId;
13379 // sessionId
13380 *pBuf++ = (tANI_U8)sessionId;
13381 // transactionId
13382 *pBuf = 0;
13383 *( pBuf + 1 ) = 0;
13384 pBuf += sizeof(tANI_U16);
13385 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013386 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13387 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013388 pBuf = pBuf + sizeof ( tSirMacAddr );
13389 // bEnable
13390 *pBuf = (tANI_BOOLEAN)bEnable;
13391 if(!HAL_STATUS_SUCCESS(status))
13392 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013393 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013394 break;
13395 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013396 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013397 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013398 return( status );
13399}
Jeff Johnson295189b2012-06-20 16:38:30 -070013400eHalStatus
13401csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13402 VOS_MODULE_ID modId, tSirMacAddr bssId,
13403 void *pUsrContext, void *pfnSapEventCallback,
13404 tANI_U8 *pAssocStasBuf )
13405{
13406 eHalStatus status = eHAL_STATUS_SUCCESS;
13407 tSirSmeGetAssocSTAsReq *pMsg;
13408 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13409 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013410 do
13411 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013412 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13413 if ( NULL == pMsg )
13414 status = eHAL_STATUS_FAILURE;
13415 else
13416 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013417 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013418 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013419 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013420 pBuf = (tANI_U8 *)&pMsg->bssId;
13421 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013422 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013423 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013424 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013425 // modId
13426 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013427 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013428 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013429 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013430 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13431 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013432 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013433 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13434 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013435 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013436 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13437 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013438 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013439 status = palSendMBMessage( pMac->hHdd, pMsg );
13440 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013441 return( status );
13442 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013443eHalStatus
13444csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13445 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13446 {
13447 eHalStatus status = eHAL_STATUS_SUCCESS;
13448 tSirSmeGetWPSPBCSessionsReq *pMsg;
13449 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013450
Jeff Johnson295189b2012-06-20 16:38:30 -070013451 do
13452 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013453 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13454 if ( NULL == pMsg )
13455 status = eHAL_STATUS_FAILURE;
13456 else
13457 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013458 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013459 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013460 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013461 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013462 VOS_ASSERT(pBuf);
13463
Jeff Johnson295189b2012-06-20 16:38:30 -070013464 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013465 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013466 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13467 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013468 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013469 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13470 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013471 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013472 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013473 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013474 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013475 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013476 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013477 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013478 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013479 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013480 return( status );
13481}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013482
13483eHalStatus
13484csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13485{
13486 tpSirChangeBIParams pMsg;
13487 tANI_U16 len = 0;
13488 eHalStatus status = eHAL_STATUS_SUCCESS;
13489 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13490
13491 if(!pSession)
13492 {
13493 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13494 return eHAL_STATUS_FAILURE;
13495 }
13496
13497 //NO need to update the Beacon Params if update beacon parameter flag is not set
13498 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13499 return eHAL_STATUS_SUCCESS;
13500
13501 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13502
13503 /* Create the message and send to lim */
13504 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013505 pMsg = vos_mem_malloc(len);
13506 if ( NULL == pMsg )
13507 status = eHAL_STATUS_FAILURE;
13508 else
13509 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013510 if(HAL_STATUS_SUCCESS(status))
13511 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013512 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013513 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13514 pMsg->length = len;
13515
13516 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013517 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13518 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013519 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13520 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013521 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013522 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013523 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13524 status = palSendMBMessage(pMac->hHdd, pMsg);
13525 }
13526 return status;
13527}
13528
Jeff Johnson295189b2012-06-20 16:38:30 -070013529eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13530{
13531 eHalStatus status = eHAL_STATUS_SUCCESS;
13532 tSirSmeDeauthReq *pMsg;
13533 tANI_U8 *pBuf;
13534 tANI_U16 wTmp;
13535 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13536 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13537 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013539 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13540 if ( NULL == pMsg )
13541 status = eHAL_STATUS_FAILURE;
13542 else
13543 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013544 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013545 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13547 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13548 //sessionId
13549 pBuf = &pMsg->sessionId;
13550 *pBuf++ = (tANI_U8)sessionId;
13551
13552 //tansactionId
13553 *pBuf = 0;
13554 *(pBuf + 1 ) = 0;
13555 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013556 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013557 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013558 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13559 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013560 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13561 sizeof( pMsg->peerMacAddr ) );
13562 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013563 pBuf = pBuf + sizeof(tSirMacAddr);
13564 }
13565 else
13566 {
13567 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013568 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13569 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013570 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013571 }
13572 if(!HAL_STATUS_SUCCESS(status))
13573 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013574 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013575 break;
13576 }
13577 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013578 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13579 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013580 pBuf = pBuf + sizeof(tSirMacAddr);
13581 if(!HAL_STATUS_SUCCESS(status))
13582 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013583 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013584 break;
13585 }
13586 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013587 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13588 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013589 if(!HAL_STATUS_SUCCESS(status))
13590 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013591 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013592 break;
13593 }
13594 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013595 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013596 return( status );
13597}
13598
Jeff Johnson295189b2012-06-20 16:38:30 -070013599eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13600{
13601 eHalStatus status = eHAL_STATUS_SUCCESS;
13602 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013603 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013604 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13605 if ( NULL == pMsg )
13606 status = eHAL_STATUS_FAILURE;
13607 else
13608 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013609 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013610 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013611 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13612 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13613 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013614 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13615 sizeof(pMsg->peerMacAddr));
13616 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013617 if(!HAL_STATUS_SUCCESS(status))
13618 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013619 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 break;
13621 }
13622//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013623 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13624 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013625 if(!HAL_STATUS_SUCCESS(status))
13626 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013627 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013628 break;
13629 }
13630//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013631 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013632 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013633 return( status );
13634}
13635
Jeff Johnson295189b2012-06-20 16:38:30 -070013636eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13637{
13638 eHalStatus status = eHAL_STATUS_SUCCESS;
13639 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013640 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013641 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13642 if ( NULL == pMsg )
13643 status = eHAL_STATUS_FAILURE;
13644 else
13645 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013646 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013647 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13649 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13650 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013651 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13652 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013653 if(!HAL_STATUS_SUCCESS(status))
13654 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013655 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013656 break;
13657 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013658 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13659 sizeof(pMsg->peerMacAddr));
13660 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013661 if(!HAL_STATUS_SUCCESS(status))
13662 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013663 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013664 break;
13665 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013666 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013667 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013668 return( status );
13669}
Jeff Johnson295189b2012-06-20 16:38:30 -070013670eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13671{
13672 eHalStatus status = eHAL_STATUS_SUCCESS;
13673 tSirSmeAssocCnf *pMsg;
13674 tANI_U8 *pBuf;
13675 tSirResultCodes statusCode;
13676 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013677 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013678 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13679 if ( NULL == pMsg )
13680 status = eHAL_STATUS_FAILURE;
13681 else
13682 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013683 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013684 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013685 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13686 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 pBuf = (tANI_U8 *)&pMsg->statusCode;
13688 if(HAL_STATUS_SUCCESS(Halstatus))
13689 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13690 else
13691 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013692 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013693 pBuf += sizeof(tSirResultCodes);
13694 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013695 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13696 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013697 pBuf += sizeof (tSirMacAddr);
13698 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013699 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13700 sizeof(tSirMacAddr));
13701 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013702 pBuf += sizeof (tSirMacAddr);
13703 // aid
13704 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013705 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 pBuf += sizeof (tANI_U16);
13707 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013708 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13709 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013710 pBuf += sizeof (tSirMacAddr);
13711 // alternateChannelId
13712 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013713 status = palSendMBMessage( pMac->hHdd, pMsg );
13714 if(!HAL_STATUS_SUCCESS(status))
13715 {
13716 //pMsg is freed by palSendMBMessage
13717 break;
13718 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013719 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013720 return( status );
13721}
Jeff Johnson295189b2012-06-20 16:38:30 -070013722eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13723 tpSirSmeAssocInd pAssocInd,
13724 eHalStatus Halstatus,
13725 tANI_U8 sessionId)
13726{
13727 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013728 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13729 tANI_U8 *pBuf;
13730 tSirResultCodes statusCode;
13731 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013732 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013733 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13734 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13735 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013736
Jeff Johnson295189b2012-06-20 16:38:30 -070013737 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13738 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13739
13740 pMsg->sessionId = sessionId;
13741
13742 pBuf = (tANI_U8 *)&pMsg->statusCode;
13743 if(HAL_STATUS_SUCCESS(Halstatus))
13744 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13745 else
13746 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013747 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013748 pBuf += sizeof(tSirResultCodes);
13749 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013750 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 pBuf += sizeof (tSirMacAddr);
13752 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013753 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13754 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013755 pBuf += sizeof (tSirMacAddr);
13756 // StaId
13757 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013758 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013759 pBuf += sizeof (tANI_U16);
13760 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013761 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013762 pBuf += sizeof (tSirMacAddr);
13763 // alternateChannelId
13764 *pBuf = 11;
13765 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013766 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013767 //Wmm
13768 *pBuf = pAssocInd->wmmEnabledSta;
13769 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013770 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013771 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013773 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013774 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013775 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013776 //reassocReq
13777 *pBuf = pAssocInd->reassocReq;
13778 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013779 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13780 msgQ.bodyptr = pMsg;
13781 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013782 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013784 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013785}
Jeff Johnson295189b2012-06-20 16:38:30 -070013786
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013787eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013788 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13789 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13790 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13791 tANI_U8 *pKeyRsc )
13792{
13793 tSirSmeSetContextReq *pMsg;
13794 tANI_U16 msgLen;
13795 eHalStatus status = eHAL_STATUS_FAILURE;
13796 tAniEdType tmpEdType;
13797 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013798 tANI_U8 *pBuf = NULL;
13799 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013800 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Sushant Kaushike7de85f2014-06-16 17:13:30 +053013801 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
13802 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013803 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013804 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013805 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13806 // key set. Since we only support upto one key, we always allocate memory for 1 key
13807 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13808 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13809 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13810 ( sizeof( pMsg->keyMaterial.key ) );
13811
Kiet Lam64c1b492013-07-12 13:56:44 +053013812 pMsg = vos_mem_malloc(msgLen);
13813 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13814 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13816 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013817 //sessionId
13818 pBuf = &pMsg->sessionId;
13819 *pBuf = (tANI_U8)sessionId;
13820 pBuf++;
13821 // transactionId
13822 *pBuf = 0;
13823 *(pBuf + 1) = 0;
13824 pBuf += sizeof(tANI_U16);
13825 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013826 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013827
13828 pBuf += sizeof(tSirMacAddr);
13829
13830 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013831 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13832 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013833
13834 pBuf += sizeof(tSirMacAddr);
13835
13836 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013837 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13838 // in the tSirKeyMaterial keyMaterial; field).
13839 //
13840 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13841 // shorter than this max size. Is LIM interpreting this ok ?
13842 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 -070013843 // set pMsg->keyMaterial.edType
13844 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013845 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013846 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013847 // set the pMsg->keyMaterial.numKeys field
13848 *p = numKeys;
13849 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013850 // set pSirKey->keyId = keyId;
13851 *p = keyId;
13852 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013853 // set pSirKey->unicast = (tANI_U8)fUnicast;
13854 *p = (tANI_U8)fUnicast;
13855 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013856 // set pSirKey->keyDirection = aniKeyDirection;
13857 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013858 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013859 p += sizeof(tAniKeyDirection);
13860 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013861 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013862 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013863 // set pSirKey->paeRole
13864 *p = paeRole; // 0 is Supplicant
13865 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013866 // set pSirKey->keyLength = keyLength;
13867 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013868 if ( keyLength && pKey )
13869 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013870 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013871 if(keyLength == 16)
13872 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013873 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 -070013874 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13875 pKey[5], pKey[6], pKey[7], pKey[8],
13876 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13877 }
13878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013879 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013880 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 return( status );
13882}
13883
Jeff Johnson295189b2012-06-20 16:38:30 -070013884eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13885 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13886{
13887 eHalStatus status;
13888 tSirSmeStartBssReq *pMsg;
13889 tANI_U8 *pBuf = NULL;
13890 tANI_U8 *wTmpBuf = NULL;
13891 tANI_U16 msgLen, wTmp;
13892 tANI_U32 dwTmp;
13893 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013894 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013895 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013896 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013897
13898 if(!pSession)
13899 {
13900 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13901 return eHAL_STATUS_FAILURE;
13902 }
13903
Jeff Johnson295189b2012-06-20 16:38:30 -070013904 do {
13905 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13906 pSession->joinFailStatusCode.reasonCode = 0;
13907 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013908 pMsg = vos_mem_malloc(msgLen);
13909 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13910 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013911 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013912 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013913 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013914 //sessionId
13915 *pBuf = (tANI_U8)sessionId;
13916 pBuf++;
13917 // transactionId
13918 *pBuf = 0;
13919 *(pBuf + 1) = 0;
13920 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013921 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013922 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013923 pBuf += sizeof(tSirMacAddr);
13924 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013925 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013926 pBuf += sizeof(tSirMacAddr);
13927 // beaconInterval
13928 if( pBssDesc && pBssDesc->beaconInterval )
13929 {
13930 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13931 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013932 else if(pParam->beaconInterval)
13933 {
13934 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13935 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013936 else
13937 {
13938 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13939 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013940 if(csrIsconcurrentsessionValid (pMac, sessionId,
13941 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013942 == eHAL_STATUS_SUCCESS )
13943 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013944 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013945 pParam->bssPersona);
13946 //Update the beacon Interval
13947 pParam->beaconInterval = wTmp;
13948 }
13949 else
13950 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013951 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013952 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013953 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013954 return status;
13955 }
13956
Kiet Lam64c1b492013-07-12 13:56:44 +053013957 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013958 pBuf += sizeof(tANI_U16);
13959 // dot11mode
13960 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13961 pBuf += 1;
13962 // bssType
13963 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013964 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013965 pBuf += sizeof(tSirBssType);
13966 // ssId
13967 if( pParam->ssId.length )
13968 {
13969 // ssId len
13970 *pBuf = pParam->ssId.length;
13971 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013972 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013973 pBuf += pParam->ssId.length;
13974 }
13975 else
13976 {
13977 *pBuf = 0;
13978 pBuf++;
13979 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013980 // set the channel Id
13981 *pBuf = pParam->operationChn;
13982 pBuf++;
13983 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013984 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013985 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013986 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013987
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 // Set privacy
13989 *pBuf = pParam->privacy;
13990 pBuf++;
13991
13992 //Set Uapsd
13993 *pBuf = pParam->ApUapsdEnable;
13994 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013995 //Set SSID hidden
13996 *pBuf = pParam->ssidHidden;
13997 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013998 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13999 pBuf++;
14000
14001 //Ht protection Enable/Disable
14002 *pBuf = (tANI_U8)pParam->protEnabled;
14003 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014004 //Enable Beacons to Receive for OBSS protection Enable/Disable
14005 *pBuf = (tANI_U8)pParam->obssProtEnabled;
14006 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014007 //set cfg related to protection
14008 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053014009 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014010 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014011 // Set Auth type
14012 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014013 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014014 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014015 // Set DTIM
14016 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053014017 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014018 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 // Set wps_state
14020 *pBuf = pParam->wps_state;
14021 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080014022 // set isCoalesingInIBSSAllowed
14023 *pBuf = pMac->isCoalesingInIBSSAllowed;
14024 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014025 //Persona
14026 *pBuf = (tANI_U8)pParam->bssPersona;
14027 pBuf++;
14028
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080014029 //txLdpcIniFeatureEnabled
14030 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
14031 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070014032
Chet Lanctot8cecea22014-02-11 19:09:36 -080014033#ifdef WLAN_FEATURE_11W
14034 // Set MFP capable/required
14035 *pBuf = (tANI_U8)pParam->mfpCapable;
14036 pBuf++;
14037 *pBuf = (tANI_U8)pParam->mfpRequired;
14038 pBuf++;
14039#endif
14040
krunal soni4f087d22013-07-29 16:32:26 -070014041 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070014042 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
14043 {
14044 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053014045 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014046 break;
14047 }
14048 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053014049 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014050 pBuf += sizeof(tANI_U16);
14051 if( wTmp )
14052 {
14053 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053014054 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014055 pBuf += wTmp;
14056 }
14057 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014058 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014059 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014060 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
14061 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014062 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
14063 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070014064 pBuf += pParam->operationalRateSet.numRates ;
14065 *pBuf++ = pParam->extendedRateSet.numRates;
14066 if(0 != pParam->extendedRateSet.numRates)
14067 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014068 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
14069 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070014070 pBuf += pParam->extendedRateSet.numRates;
14071 }
krunal sonie9002db2013-11-25 14:24:17 -080014072
Jeff Johnson295189b2012-06-20 16:38:30 -070014073 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
14074 pMsg->length = pal_cpu_to_be16(msgLen);
14075
14076 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014077 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014078 return( status );
14079}
14080
Jeff Johnson295189b2012-06-20 16:38:30 -070014081eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
14082{
14083 eHalStatus status = eHAL_STATUS_FAILURE;
14084 tSirSmeStopBssReq *pMsg;
14085 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14086 tANI_U8 *pBuf;
14087 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070014088
14089 if(!pSession)
14090 {
14091 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14092 return eHAL_STATUS_FAILURE;
14093 }
14094
Jeff Johnson295189b2012-06-20 16:38:30 -070014095 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014096 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14097 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14098 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014099 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14100 pBuf = &pMsg->sessionId;
14101 //sessionId
14102 *pBuf = (tANI_U8)sessionId;
14103 pBuf++;
14104 // transactionId
14105 *pBuf = 0;
14106 pBuf += sizeof(tANI_U16);
14107 //reason code
14108 *pBuf = 0;
14109 pBuf += sizeof(tSirResultCodes);
14110 // bssid
14111 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14112 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14113 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014114 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
14115 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014116 }
14117 else
14118 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014119 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14120 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014121 }
14122 pBuf += sizeof(tSirMacAddr);
14123 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
14124 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014125 status = palSendMBMessage( pMac->hHdd, pMsg );
14126#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053014127 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14128 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14129 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014130 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14131 pMsg->reasonCode = 0;
14132 // bssid
14133 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14134 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14135 {
14136 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
14137 }
14138 else
14139 {
14140 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
14141 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014142 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014143 pMsg->transactionId = 0;
14144 pMsg->sessionId = (tANI_U8)sessionId;
14145 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
14146 status = palSendMBMessage( pMac->hHdd, pMsg );
14147#endif
14148 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014149 return( status );
14150}
14151
Jeff Johnson295189b2012-06-20 16:38:30 -070014152eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14153 tCsrRoamModifyProfileFields *pModProfileFields,
14154 tANI_U32 *pRoamId, v_BOOL_t fForce)
14155{
Jeff Johnson295189b2012-06-20 16:38:30 -070014156 eHalStatus status = eHAL_STATUS_FAILURE;
14157 tANI_U32 roamId = 0;
14158 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014159 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014160 (fForce || (!vos_mem_compare( &pModProfileFields,
14161 &pSession->connectedProfile.modifyProfileFields,
14162 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014163 {
14164 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14165 if(pRoamId)
14166 {
14167 *pRoamId = roamId;
14168 }
14169
Jeff Johnson295189b2012-06-20 16:38:30 -070014170 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14171 eCsrSmeIssuedReassocToSameAP, roamId,
14172 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014173 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014174 return status;
14175}
Jeff Johnson295189b2012-06-20 16:38:30 -070014176static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14177{
14178 eHalStatus status = eHAL_STATUS_SUCCESS;
14179 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014180 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014181 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14182 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14183 return (status);
14184}
Jeff Johnson295189b2012-06-20 16:38:30 -070014185eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14186{
14187 eHalStatus status = eHAL_STATUS_SUCCESS;
14188 tListElem *pEntry = NULL;
14189 tSmeCmd *pCommand = NULL;
14190 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014191 do
14192 {
14193 if(pMsg == NULL)
14194 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014195 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014196 status = eHAL_STATUS_FAILURE;
14197 break;
14198 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014199 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14200 if(pEntry)
14201 {
14202 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14203 if(eSmeCommandAddStaSession == pCommand->command)
14204 {
14205 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014206 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053014207 if (pRsp->status == eSIR_FAILURE) {
14208 VOS_ASSERT( 0 );
14209 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014210 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014211 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014212 //Remove this command out of the active list
14213 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14214 {
14215 //Now put this command back on the avilable command list
14216 csrReleaseCommand(pMac, pCommand);
14217 }
14218 smeProcessPendingQueue( pMac );
14219 }
14220 else
14221 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014222 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 -070014223 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014224 status = eHAL_STATUS_FAILURE;
14225 break;
14226 }
14227 }
14228 else
14229 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014230 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 -070014231 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014232 status = eHAL_STATUS_FAILURE;
14233 break;
14234 }
14235 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014236 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014237}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014238eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14239 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014240{
14241 tSirSmeAddStaSelfReq *pMsg;
14242 tANI_U16 msgLen;
14243 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014244 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014245 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014246 pMsg = vos_mem_malloc(msgLen);
14247 if ( NULL == pMsg ) break;
14248 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014249 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14250 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014251 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014252 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014253 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14254
14255 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14256
Arif Hussain24bafea2013-11-15 15:10:03 -080014257 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14258 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014259 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014260 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014261 return( status );
14262}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014263eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14264 tANI_U32 sessionId,
14265 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014266{
14267 eHalStatus status = eHAL_STATUS_SUCCESS;
14268 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014269 pCommand = csrGetCommandBuffer(pMac);
14270 if(NULL == pCommand)
14271 {
14272 status = eHAL_STATUS_RESOURCES;
14273 }
14274 else
14275 {
14276 pCommand->command = eSmeCommandAddStaSession;
14277 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014278 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14279 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014280 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014281 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14282 if( !HAL_STATUS_SUCCESS( status ) )
14283 {
14284 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014285 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014286 }
14287 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014288 return (status);
14289}
Jeff Johnson295189b2012-06-20 16:38:30 -070014290eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14291{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014292 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014293}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014294eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14295 csrRoamCompleteCallback callback,
14296 void *pContext, tANI_U8 *pSelfMacAddr,
14297 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014298{
14299 eHalStatus status = eHAL_STATUS_SUCCESS;
14300 tANI_U32 i;
14301 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014302 *pbSessionId = CSR_SESSION_ID_INVALID;
14303 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14304 {
14305 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14306 {
14307 pSession = CSR_GET_SESSION( pMac, i );
14308 status = eHAL_STATUS_SUCCESS;
14309 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14310 pSession->sessionId = (tANI_U8)i;
14311 pSession->callback = callback;
14312 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014313 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014314 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014315 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14316 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014317 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014318 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014319 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014320 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014321 break;
14322 }
14323#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014324 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14325 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014326 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014327 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014328 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014329 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014330 break;
14331 }
14332#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014333 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014334 break;
14335 }
14336 }
14337 if( CSR_ROAM_SESSION_MAX == i )
14338 {
14339 //No session is available
14340 status = eHAL_STATUS_RESOURCES;
14341 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014342 return ( status );
14343}
Jeff Johnson295189b2012-06-20 16:38:30 -070014344eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14345{
14346 eHalStatus status = eHAL_STATUS_SUCCESS;
14347 tListElem *pEntry = NULL;
14348 tSmeCmd *pCommand = NULL;
14349 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014350 do
14351 {
14352 if(pMsg == NULL)
14353 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014354 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014355 status = eHAL_STATUS_FAILURE;
14356 break;
14357 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014358 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14359 if(pEntry)
14360 {
14361 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14362 if(eSmeCommandDelStaSession == pCommand->command)
14363 {
14364 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014365 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014366 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014367 //This session is done.
14368 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014369 if(pCommand->u.delStaSessionCmd.callback)
14370 {
14371
14372 status = sme_ReleaseGlobalLock( &pMac->sme );
14373 if ( HAL_STATUS_SUCCESS( status ) )
14374 {
14375 pCommand->u.delStaSessionCmd.callback(
14376 pCommand->u.delStaSessionCmd.pContext);
14377 status = sme_AcquireGlobalLock( &pMac->sme );
14378 if (! HAL_STATUS_SUCCESS( status ) )
14379 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014380 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014381 return status;
14382 }
14383 }
14384 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014385 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014386 }
14387 }
14388
14389 //Remove this command out of the active list
14390 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14391 {
14392 //Now put this command back on the avilable command list
14393 csrReleaseCommand(pMac, pCommand);
14394 }
14395 smeProcessPendingQueue( pMac );
14396 }
14397 else
14398 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014399 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 -070014400 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014401 status = eHAL_STATUS_FAILURE;
14402 break;
14403 }
14404 }
14405 else
14406 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014407 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 -070014408 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014409 status = eHAL_STATUS_FAILURE;
14410 break;
14411 }
14412 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014413 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014414}
Jeff Johnson295189b2012-06-20 16:38:30 -070014415eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14416{
14417 tSirSmeDelStaSelfReq *pMsg;
14418 tANI_U16 msgLen;
14419 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014420 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014421 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14422 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014423 pMsg = vos_mem_malloc(msgLen);
14424 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14425 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014426 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14427 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014428 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014429 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14430 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014431 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014432 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014433 return( status );
14434}
Jeff Johnson295189b2012-06-20 16:38:30 -070014435eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14436 tSirMacAddr sessionMacAddr,
14437 csrRoamSessionCloseCallback callback,
14438 void *pContext)
14439{
14440 eHalStatus status = eHAL_STATUS_SUCCESS;
14441 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014442 pCommand = csrGetCommandBuffer(pMac);
14443 if(NULL == pCommand)
14444 {
14445 status = eHAL_STATUS_RESOURCES;
14446 }
14447 else
14448 {
14449 pCommand->command = eSmeCommandDelStaSession;
14450 pCommand->sessionId = (tANI_U8)sessionId;
14451 pCommand->u.delStaSessionCmd.callback = callback;
14452 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014453 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14454 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014455 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14456 if( !HAL_STATUS_SUCCESS( status ) )
14457 {
14458 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014459 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014460 }
14461 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014462 return (status);
14463}
Jeff Johnson295189b2012-06-20 16:38:30 -070014464eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14465{
14466 return csrSendMBDelSelfStaReqMsg( pMac,
14467 pCommand->u.delStaSessionCmd.selfMacAddr );
14468}
Jeff Johnson295189b2012-06-20 16:38:30 -070014469static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14470{
14471 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14472 tListElem *pEntry, *pNext;
14473 tSmeCmd *pCommand;
14474 tDblLinkList localList;
14475
14476 vos_mem_zero(&localList, sizeof(tDblLinkList));
14477 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14478 {
14479 smsLog(pMac, LOGE, FL(" failed to open list"));
14480 return;
14481 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014482 csrLLLock(pList);
14483 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14484 while(pEntry != NULL)
14485 {
14486 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14487 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14488 if(pCommand->sessionId == sessionId)
14489 {
14490 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14491 {
14492 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14493 }
14494 }
14495 pEntry = pNext;
14496 }
14497 csrLLUnlock(pList);
14498
14499 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14500 {
14501 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14502 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14503 }
14504 csrLLClose(&localList);
14505}
14506
Jeff Johnson295189b2012-06-20 16:38:30 -070014507void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14508{
14509 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14510 {
14511 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014512 csrRoamStop(pMac, sessionId);
14513 csrFreeConnectBssDesc(pMac, sessionId);
14514 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14515 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014516 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014517#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014518 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014519#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014520 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14521 if (pMac->fScanOffload)
14522 {
14523 purgeSmeSessionCmdList(pMac, sessionId,
14524 &pMac->sme.smeScanCmdPendingList);
14525 }
14526
Jeff Johnson295189b2012-06-20 16:38:30 -070014527 purgeCsrSessionCmdList(pMac, sessionId);
14528 csrInitSession(pMac, sessionId);
14529 }
14530}
14531
Jeff Johnson295189b2012-06-20 16:38:30 -070014532eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14533 tANI_BOOLEAN fSync,
14534 csrRoamSessionCloseCallback callback,
14535 void *pContext )
14536{
14537 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014538 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14539 {
14540 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14541 if(fSync)
14542 {
14543 csrCleanupSession(pMac, sessionId);
14544 }
14545 else
14546 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014547 purgeSmeSessionCmdList(pMac, sessionId,
14548 &pMac->sme.smeCmdPendingList);
14549 if (pMac->fScanOffload)
14550 {
14551 purgeSmeSessionCmdList(pMac, sessionId,
14552 &pMac->sme.smeScanCmdPendingList);
14553 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014554 purgeCsrSessionCmdList(pMac, sessionId);
14555 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14556 pSession->selfMacAddr, callback, pContext);
14557 }
14558 }
14559 else
14560 {
14561 status = eHAL_STATUS_INVALID_PARAMETER;
14562 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014563 return ( status );
14564}
14565
Jeff Johnson295189b2012-06-20 16:38:30 -070014566static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14567{
14568 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014569
14570 if(!pSession)
14571 {
14572 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14573 return;
14574 }
14575
Jeff Johnson295189b2012-06-20 16:38:30 -070014576 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14577 pSession->sessionId = CSR_SESSION_ID_INVALID;
14578 pSession->callback = NULL;
14579 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014580 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14581 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14582 csrFreeRoamProfile( pMac, sessionId );
14583 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14584 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14585 csrFreeConnectBssDesc(pMac, sessionId);
14586 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014587 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14588 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014589 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014590 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014591 pSession->pWpaRsnReqIE = NULL;
14592 }
14593 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014594 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014595 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014596 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014597 pSession->pWpaRsnRspIE = NULL;
14598 }
14599 pSession->nWpaRsnRspIeLength = 0;
14600#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014601 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014602 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014603 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014604 pSession->pWapiReqIE = NULL;
14605 }
14606 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014607 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014608 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014609 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014610 pSession->pWapiRspIE = NULL;
14611 }
14612 pSession->nWapiRspIeLength = 0;
14613#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014614 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014615 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014616 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014617 }
14618 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014619
Kiet Lam64c1b492013-07-12 13:56:44 +053014620 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014621 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014622 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014623 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014624 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014625 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014626}
14627
Jeff Johnson295189b2012-06-20 16:38:30 -070014628eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14629{
14630 eHalStatus status = eHAL_STATUS_FAILURE;
14631 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014632 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14633 {
14634 if( CSR_IS_SESSION_VALID( pMac, i ) )
14635 {
14636 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14637 {
14638 //Found it
14639 status = eHAL_STATUS_SUCCESS;
14640 *pSessionId = i;
14641 break;
14642 }
14643 }
14644 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014645 return( status );
14646}
14647
Jeff Johnson295189b2012-06-20 16:38:30 -070014648//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14649//session because for IBSS, the bssid changes.
14650static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14651{
14652 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14653 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014654 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14655 {
14656 if( CSR_IS_SESSION_VALID( pMac, i ) )
14657 {
14658 pSession = CSR_GET_SESSION( pMac, i );
14659 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14660 {
14661 //Found it
14662 nRet = i;
14663 break;
14664 }
14665 }
14666 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014667 return (nRet);
14668}
Jeff Johnson295189b2012-06-20 16:38:30 -070014669static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14670{
14671 /* Update the current BSS info in ho control block based on connected
14672 profile info from pmac global structure */
14673
Arif Hussain24bafea2013-11-15 15:10:03 -080014674 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14675 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014676 /* Check for user misconfig of RSSI trigger threshold */
14677 pMac->roam.configParam.vccRssiThreshold =
14678 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14679 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14680 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014681 /* Check for user misconfig of UL MAC Loss trigger threshold */
14682 pMac->roam.configParam.vccUlMacLossThreshold =
14683 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14684 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014685#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14686 {
14687 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014688 /* Indicate the neighbor roal algorithm about the connect indication */
14689 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14690 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14691 }
14692#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014693}
14694
Jeff Johnson295189b2012-06-20 16:38:30 -070014695static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14696{
14697 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014698
14699 if(!pSession)
14700 {
14701 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14702 return;
14703 }
14704
Jeff Johnson295189b2012-06-20 16:38:30 -070014705 //Only to handle the case for Handover on infra link
14706 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14707 {
14708 return;
14709 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014710 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14711 csrRoamDeregStatisticsReq(pMac);
14712 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14713#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14714 /* Indicate the neighbor roal algorithm about the disconnect indication */
14715 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14716#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014717
14718 //Remove this code once SLM_Sessionization is supported
14719 //BMPS_WORKAROUND_NOT_NEEDED
14720 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014721 csrIsInfraApStarted( pMac ) &&
14722 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014723 {
14724 pMac->roam.configParam.doBMPSWorkaround = 0;
14725 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014726}
14727
Jeff Johnson295189b2012-06-20 16:38:30 -070014728void csrRoamTlStatsTimerHandler(void *pv)
14729{
14730 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14731 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014732 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14733
Jeff Johnsone7245742012-09-05 17:12:55 -070014734 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14735
Jeff Johnson295189b2012-06-20 16:38:30 -070014736#if 0
14737 // TODO Persession .???
14738 //req TL for stats
14739 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14740 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014741 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014742 }
14743 else
14744 {
14745 //save in SME
14746 csrRoamSaveStatsFromTl(pMac, tlStats);
14747 }
14748#endif
14749 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14750 {
14751 if(pMac->roam.tlStatsReqInfo.periodicity)
14752 {
14753 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014754 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14755 pMac->roam.tlStatsReqInfo.periodicity);
14756 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014757 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014758 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014759 return;
14760 }
14761 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14762 }
14763 }
14764}
Jeff Johnson295189b2012-06-20 16:38:30 -070014765void csrRoamPeStatsTimerHandler(void *pv)
14766{
14767 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14768 eHalStatus status;
14769 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14770 VOS_STATUS vosStatus;
14771 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014772 pPeStatsReqListEntry->timerRunning = FALSE;
14773 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14774 {
14775 // If we entered here, meaning the timer could not be successfully
14776 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14777
14778 /* Destroy the timer */
14779 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14780 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14781 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014782 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014783 }
14784
14785 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014786 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014787 pPeStatsReqListEntry = NULL;
14788 }
14789 else
14790 {
14791 if(!pPeStatsReqListEntry->rspPending)
14792 {
14793 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14794 pPeStatsReqListEntry->staId);
14795 if(!HAL_STATUS_SUCCESS(status))
14796 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014797 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014798 }
14799 else
14800 {
14801 pPeStatsReqListEntry->rspPending = TRUE;
14802 }
14803 }
14804
14805 //send down a req
14806 if(pPeStatsReqListEntry->periodicity &&
14807 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14808 {
14809 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14810 if(ePMC_FULL_POWER == powerState)
14811 {
14812 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14813 {
14814 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14815 }
14816 }
14817 else
14818 {
14819 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14820 {
14821 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14822 }
14823 }
14824 //start timer
14825 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14826 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14827 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014828 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014829 return;
14830 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014831 pPeStatsReqListEntry->timerRunning = TRUE;
14832
14833 }
14834
14835 }
14836}
Jeff Johnson295189b2012-06-20 16:38:30 -070014837void csrRoamStatsClientTimerHandler(void *pv)
14838{
14839 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014840 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14841 {
14842#if 0
14843 // TODO Stats fix for multisession
14844 //start the timer
14845 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14846
14847 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14848 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014849 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014850 }
14851#endif
14852 }
14853#if 0
14854 //send up the stats report
14855 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14856 pStaEntry->staId, pStaEntry->pContext);
14857#endif
14858}
14859
14860
14861
Jeff Johnson295189b2012-06-20 16:38:30 -070014862eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14863{
14864 tAniGetPEStatsReq *pMsg;
14865 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014866 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14867 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014868 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014869 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053014870 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014871 }
14872 // need to initiate a stats request to PE
14873 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14874 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14875 pMsg->staId = staId;
14876 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014877 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014878 if(!HAL_STATUS_SUCCESS(status))
14879 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014880 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070014881 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014882 return status;
14883}
Jeff Johnson295189b2012-06-20 16:38:30 -070014884void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14885{
14886 tAniGetPEStatsRsp *pSmeStatsRsp;
14887 eHalStatus status = eHAL_STATUS_FAILURE;
14888 tListElem *pEntry = NULL;
14889 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14890 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14891 tANI_U32 tempMask = 0;
14892 tANI_U8 counter = 0;
14893 tANI_U8 *pStats = NULL;
14894 tANI_U32 length = 0;
14895 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014896 v_S7_t rssi = 0, snr = 0;
14897 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014898 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014899 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14900 if(pSmeStatsRsp->rc)
14901 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014902 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014903 goto post_update;
14904 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014905 tempMask = pSmeStatsRsp->statsMask;
14906 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014907 /* subtract all statistics from this length, and after processing the entire
14908 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14909 * in this 'stats' message.
14910 */
14911 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014912 //new stats info from PE, fill up the stats strucutres in PMAC
14913 while(tempMask)
14914 {
14915 if(tempMask & 1)
14916 {
14917 switch(counter)
14918 {
14919 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014920 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014921 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14922 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014923 pStats += sizeof(tCsrSummaryStatsInfo);
14924 length -= sizeof(tCsrSummaryStatsInfo);
14925 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014926 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014927 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014928 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14929 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014930 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14931 length -= sizeof(tCsrGlobalClassAStatsInfo);
14932 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014933 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014934 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014935 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14936 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014937 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14938 length -= sizeof(tCsrGlobalClassBStatsInfo);
14939 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014940 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014941 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014942 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14943 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014944 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14945 length -= sizeof(tCsrGlobalClassCStatsInfo);
14946 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014947 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014948 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014949 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14950 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014951 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14952 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014953 }
14954 else
14955 {
14956 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014957 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014958 VOS_ASSERT( 0 );
14959 }
14960 if(!HAL_STATUS_SUCCESS(status))
14961 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014962 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014963 }
14964 pStats += sizeof(tCsrPerStaStatsInfo);
14965 length -= sizeof(tCsrPerStaStatsInfo);
14966 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014967 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014968 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014969 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014970 }
14971 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014972 tempMask >>=1;
14973 counter++;
14974 }
14975 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14976 if (length != 0)
14977 {
14978 pRssi = (tANI_U32*)pStats;
14979 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014980 pStats += sizeof(tANI_U32);
14981 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014982 }
14983 else
14984 {
14985 /* If riva is not sending rssi, continue to use the hack */
14986 rssi = RSSI_HACK_BMPS;
14987 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014988
Jeff Johnson295189b2012-06-20 16:38:30 -070014989 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014990
14991 if (length != 0)
14992 {
14993 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014994 pStats += sizeof(tANI_U32);
14995 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014996 }
14997 else
14998 {
14999 linkCapacity = 0;
15000 }
15001
15002 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015003
15004 if (length != 0)
15005 {
15006 pSnr = (tANI_U32*)pStats;
15007 snr = (v_S7_t)*pSnr;
15008 }
15009 else
15010 {
15011 snr = SNR_HACK_BMPS;
15012 }
15013
15014 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015015post_update:
15016 //make sure to update the pe stats req list
15017 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
15018 if(pEntry)
15019 {
15020 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
15021 pPeStaEntry->rspPending = FALSE;
15022
15023 }
15024 //check the one timer cases
15025 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
15026 if(pEntry)
15027 {
Jeff Johnson295189b2012-06-20 16:38:30 -070015028 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015029 if(pTempStaEntry->timerExpired)
15030 {
15031 //send up the stats report
15032 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15033 pTempStaEntry->staId, pTempStaEntry->pContext);
15034 //also remove from the client list
15035 csrRoamRemoveStatListEntry(pMac, pEntry);
15036 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015037 }
15038 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015039}
Jeff Johnson295189b2012-06-20 16:38:30 -070015040tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15041{
15042 tListElem *pEntry = NULL;
15043 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015044 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015045 if(!pEntry)
15046 {
15047 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015048 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015049 return NULL;
15050 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015051 while( pEntry )
15052 {
15053 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015054 if(pTempStaEntry->statsMask == statsMask)
15055 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015056 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015057 break;
15058 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015059 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15060 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015061 return pEntry;
15062}
15063
Jeff Johnson295189b2012-06-20 16:38:30 -070015064tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
15065 tANI_BOOLEAN update)
15066{
15067 tListElem *pEntry;
15068 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015069 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015070 if(!pEntry)
15071 {
15072 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015073 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015074 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015075 return NULL;
15076 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015077 while( pEntry )
15078 {
15079 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015080 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
15081 (pTempStaEntry->statsMask == pStaEntry->statsMask))
15082 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015083 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015084 if(update)
15085 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015086 pTempStaEntry->periodicity = pStaEntry->periodicity;
15087 pTempStaEntry->callback = pStaEntry->callback;
15088 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015089 }
15090 break;
15091 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015092 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15093 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015094 return pEntry;
15095}
Jeff Johnson295189b2012-06-20 16:38:30 -070015096tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15097{
15098 tListElem *pEntry;
15099 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015100 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015101 if(!pEntry)
15102 {
15103 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015104 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015105 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015106 return NULL;
15107 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015108 while( pEntry )
15109 {
15110 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015111 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
15112 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015113 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015114 break;
15115 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015116 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15117 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015118 return pEntry;
15119}
Jeff Johnson295189b2012-06-20 16:38:30 -070015120eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
15121 csrRoamLinkQualityIndCallback callback,
15122 void *pContext)
15123{
15124 pMac->roam.linkQualityIndInfo.callback = callback;
15125 pMac->roam.linkQualityIndInfo.context = pContext;
15126 if( NULL == callback )
15127 {
15128 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
15129 }
15130 else
15131 {
15132 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070015133 /* do we need to invoke the callback to notify client of initial value ?? */
15134 }
15135 return eHAL_STATUS_SUCCESS;
15136}
Jeff Johnson295189b2012-06-20 16:38:30 -070015137void csrRoamVccTrigger(tpAniSirGlobal pMac)
15138{
15139 eCsrRoamLinkQualityInd newVccLinkQuality;
15140 tANI_U32 ul_mac_loss = 0;
15141 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015142 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15143 /*-------------------------------------------------------------------------
15144 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015145 Check for a change in link quality and notify client if necessary
15146 -------------------------------------------------------------------------*/
15147 ul_mac_loss_trigger_threshold =
15148 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015149 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015150 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015151 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015152 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15153 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015154 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015155 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15156 }
15157 else
15158 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015159 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015160 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15161 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015162 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15163 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015164 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15165 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015166 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015167 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15168 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015169 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015170 newVccLinkQuality );
15171
15172 /* we now invoke the callback once to notify client of initial value */
15173 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15174 pMac->roam.linkQualityIndInfo.context );
15175 //event: EVENT_WLAN_VCC
15176 }
15177 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015178 pMac->roam.vccLinkQuality = newVccLinkQuality;
15179
Jeff Johnson295189b2012-06-20 16:38:30 -070015180}
Jeff Johnson295189b2012-06-20 16:38:30 -070015181VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15182 v_U8_t rssiNotification,
15183 void * context)
15184{
15185 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15186 eCsrRoamLinkQualityInd newVccLinkQuality;
15187 // TODO : Session info unavailable
15188 tANI_U32 sessionId = 0;
15189 VOS_STATUS status = VOS_STATUS_SUCCESS;
15190 /*-------------------------------------------------------------------------
15191 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015192 Check for a change in link quality and notify client if necessary
15193 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015194 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015195 pMac->roam.configParam.vccRssiThreshold);
15196 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15197 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015198 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015199 return VOS_STATUS_SUCCESS;
15200 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015201 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15202 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015203 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015204 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15205 }
15206 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15207 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015208 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015209 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15210 }
15211 else
15212 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015213 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015214 //Set to this so the code below won't do anything
15215 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015216 VOS_ASSERT(0);
15217 }
15218
Jeff Johnson295189b2012-06-20 16:38:30 -070015219 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15220 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015221 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015222 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15223 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015224 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015225 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015226 /* we now invoke the callback once to notify client of initial value */
15227 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15228 pMac->roam.linkQualityIndInfo.context );
15229 //event: EVENT_WLAN_VCC
15230 }
15231 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015232 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015233 return status;
15234}
Jeff Johnson295189b2012-06-20 16:38:30 -070015235tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15236 tDblLinkList *pStaList,
15237 tCsrStatsClientReqInfo *pStaEntry)
15238{
15239 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015240 //if same entity requested for same set of stats with different periodicity &
15241 // callback update it
15242 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15243 {
15244
Kiet Lam64c1b492013-07-12 13:56:44 +053015245 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15246 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015247 {
15248 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015249 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015250 return NULL;
15251 }
15252
Jeff Johnson295189b2012-06-20 16:38:30 -070015253 pNewStaEntry->callback = pStaEntry->callback;
15254 pNewStaEntry->pContext = pStaEntry->pContext;
15255 pNewStaEntry->periodicity = pStaEntry->periodicity;
15256 pNewStaEntry->requesterId = pStaEntry->requesterId;
15257 pNewStaEntry->statsMask = pStaEntry->statsMask;
15258 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15259 pNewStaEntry->pMac = pStaEntry->pMac;
15260 pNewStaEntry->staId = pStaEntry->staId;
15261 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15262
15263 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15264 }
15265 return pNewStaEntry;
15266}
15267
Jeff Johnson295189b2012-06-20 16:38:30 -070015268tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15269 tDblLinkList *pStaList,
15270 tCsrPeStatsReqInfo *pStaEntry)
15271{
15272 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015273 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15274 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015275 {
15276 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015277 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015278 return NULL;
15279 }
15280
Jeff Johnson295189b2012-06-20 16:38:30 -070015281 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15282 pNewStaEntry->numClient = pStaEntry->numClient;
15283 pNewStaEntry->periodicity = pStaEntry->periodicity;
15284 pNewStaEntry->statsMask = pStaEntry->statsMask;
15285 pNewStaEntry->pMac = pStaEntry->pMac;
15286 pNewStaEntry->staId = pStaEntry->staId;
15287 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15288 pNewStaEntry->rspPending = pStaEntry->rspPending;
15289
15290 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015291 return pNewStaEntry;
15292}
Jeff Johnson295189b2012-06-20 16:38:30 -070015293eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15294 tCsrRssiCallback callback,
15295 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15296{
15297 eHalStatus status = eHAL_STATUS_SUCCESS;
15298 vos_msg_t msg;
15299 tANI_U32 sessionId;
15300
15301 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015302 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015303 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15304 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015305 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015306 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015307 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015308 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015309 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15310
15311 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15312 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15313 pMsg->sessionId = sessionId;
15314 pMsg->staId = staId;
15315 pMsg->rssiCallback = callback;
15316 pMsg->pDevContext = pContext;
15317 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015318 msg.type = eWNI_SME_GET_RSSI_REQ;
15319 msg.bodyptr = pMsg;
15320 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015321 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15322 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015323 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015324 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015325 status = eHAL_STATUS_FAILURE;
15326 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015327 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015328 return status;
15329}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015330
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015331eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15332 tCsrSnrCallback callback,
15333 tANI_U8 staId, tCsrBssid bssId,
15334 void *pContext)
15335{
15336 eHalStatus status = eHAL_STATUS_SUCCESS;
15337 vos_msg_t msg;
15338 tANI_U32 sessionId;
15339
15340 tAniGetSnrReq *pMsg;
15341
15342 smsLog(pMac, LOG2, FL("called"));
15343
15344 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15345 if (NULL == pMsg )
15346 {
15347 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15348 return status;
15349 }
15350
15351 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15352
15353 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15354 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15355 pMsg->sessionId = sessionId;
15356 pMsg->staId = staId;
15357 pMsg->snrCallback = callback;
15358 pMsg->pDevContext = pContext;
15359 msg.type = eWNI_SME_GET_SNR_REQ;
15360 msg.bodyptr = pMsg;
15361 msg.reserved = 0;
15362
15363 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15364 {
15365 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15366 vos_mem_free((v_VOID_t *)pMsg);
15367 status = eHAL_STATUS_FAILURE;
15368 }
15369
15370 smsLog(pMac, LOG2, FL("returned"));
15371 return status;
15372}
15373
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015374#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015375eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15376 tCsrRssiCallback callback,
15377 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15378{
15379 eHalStatus status = eHAL_STATUS_SUCCESS;
15380 tAniGetRssiReq *pMsg;
15381
Kiet Lam64c1b492013-07-12 13:56:44 +053015382 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15383 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015384 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015385 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015386 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015387 }
15388 // need to initiate a stats request to PE
15389 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15390 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15391 pMsg->staId = staId;
15392 pMsg->rssiCallback = callback;
15393 pMsg->pDevContext = pContext;
15394 pMsg->pVosContext = pVosContext;
15395 status = palSendMBMessage(pMac->hHdd, pMsg );
15396 if(!HAL_STATUS_SUCCESS(status))
15397 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015398 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015399 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015400 status = eHAL_STATUS_FAILURE;
15401 }
15402 return status;
15403}
15404#endif
15405
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015406
15407
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015408#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015409eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15410 tCsrTsmStatsCallback callback,
15411 tANI_U8 staId,
15412 tCsrBssid bssId,
15413 void *pContext,
15414 void* pVosContext,
15415 tANI_U8 tid)
15416{
15417 eHalStatus status = eHAL_STATUS_SUCCESS;
15418 tAniGetTsmStatsReq *pMsg = NULL;
15419
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015420 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15421 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015422 {
15423 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015424 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015425 }
15426 // need to initiate a stats request to PE
15427 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15428 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15429 pMsg->staId = staId;
15430 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015431 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015432 pMsg->tsmStatsCallback = callback;
15433 pMsg->pDevContext = pContext;
15434 pMsg->pVosContext = pVosContext;
15435 status = palSendMBMessage(pMac->hHdd, pMsg );
15436 if(!HAL_STATUS_SUCCESS(status))
15437 {
15438 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15439 //pMsg is freed by palSendMBMessage
15440 status = eHAL_STATUS_FAILURE;
15441 }
15442 return status;
15443}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015444#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015445
15446
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015447/* ---------------------------------------------------------------------------
15448 \fn csrGetTLSTAState
15449 \helper function to get teh TL STA State whenever the function is called.
15450
15451 \param staId - The staID to be passed to the TL
15452 to get the relevant TL STA State
15453 \return the state as tANI_U16
15454 ---------------------------------------------------------------------------*/
15455tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15456{
15457 WLANTL_STAStateType tlSTAState;
15458 tlSTAState = WLANTL_STA_INIT;
15459
15460 //request TL for STA State
15461 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15462 {
15463 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15464 }
15465
15466 return tlSTAState;
15467}
15468
Jeff Johnson295189b2012-06-20 16:38:30 -070015469eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15470 tANI_U32 statsMask,
15471 tCsrStatsCallback callback,
15472 tANI_U32 periodicity, tANI_BOOLEAN cache,
15473 tANI_U8 staId, void *pContext)
15474{
15475 tCsrStatsClientReqInfo staEntry;
15476 tCsrStatsClientReqInfo *pStaEntry = NULL;
15477 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15478 tListElem *pEntry = NULL;
15479 tANI_BOOLEAN found = FALSE;
15480 eHalStatus status = eHAL_STATUS_SUCCESS;
15481 tANI_BOOLEAN insertInClientList = FALSE;
15482 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015483 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015484
15485 if( csrIsAllSessionDisconnected(pMac) )
15486 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015487 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015488 return eHAL_STATUS_FAILURE;
15489 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015490
15491 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15492 {
15493 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15494 return eHAL_STATUS_FAILURE;
15495 }
15496
Jeff Johnson295189b2012-06-20 16:38:30 -070015497 if((!statsMask) && (!callback))
15498 {
15499 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015500 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015501 return eHAL_STATUS_FAILURE;
15502 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015503 //for the search list method for deregister
15504 staEntry.requesterId = requesterId;
15505 staEntry.statsMask = statsMask;
15506 //requester wants to deregister or just an error
15507 if((statsMask) && (!callback))
15508 {
15509 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15510 if(!pEntry)
15511 {
15512 //msg
15513 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015514 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015515 return eHAL_STATUS_FAILURE;
15516 }
15517 else
15518 {
15519 //clean up & return
15520 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015521 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015522 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015523 pStaEntry->pPeStaEntry->numClient--;
15524 //check if we need to delete the entry from peStatsReqList too
15525 if(!pStaEntry->pPeStaEntry->numClient)
15526 {
15527 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15528 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015529 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015530
Jeff Johnson295189b2012-06-20 16:38:30 -070015531 //check if we need to stop the tl stats timer too
15532 pMac->roam.tlStatsReqInfo.numClient--;
15533 if(!pMac->roam.tlStatsReqInfo.numClient)
15534 {
15535 if(pMac->roam.tlStatsReqInfo.timerRunning)
15536 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015537 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15538 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015539 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015540 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015541 return eHAL_STATUS_FAILURE;
15542 }
15543 }
15544 pMac->roam.tlStatsReqInfo.periodicity = 0;
15545 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15546 }
15547 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015548 // Destroy the vos timer...
15549 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15550 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15551 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015552 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015553 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015554 csrRoamRemoveStatListEntry(pMac, pEntry);
15555 pStaEntry = NULL;
15556 return eHAL_STATUS_SUCCESS;
15557 }
15558 }
15559
15560 if(cache && !periodicity)
15561 {
15562 //return the cached stats
15563 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15564 }
15565 else
15566 {
15567 //add the request in the client req list
15568 staEntry.callback = callback;
15569 staEntry.pContext = pContext;
15570 staEntry.periodicity = periodicity;
15571 staEntry.pPeStaEntry = NULL;
15572 staEntry.staId = staId;
15573 staEntry.pMac = pMac;
15574 staEntry.timerExpired = FALSE;
15575
15576
Jeff Johnson295189b2012-06-20 16:38:30 -070015577 //if periodic report requested with non cached result from PE/TL
15578 if(periodicity)
15579 {
15580
15581 //if looking for stats from PE
15582 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15583 {
15584
15585 //check if same request made already & waiting for rsp
15586 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15587 periodicity, &found, staId);
15588 if(!pPeStaEntry)
15589 {
15590 //bail out, maxed out on number of req for PE
15591 return eHAL_STATUS_FAILURE;
15592 }
15593 else
15594 {
15595 staEntry.pPeStaEntry = pPeStaEntry;
15596 }
15597
15598 }
15599 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15600 if(statsMask & (1 << eCsrGlobalClassDStats))
15601 {
15602 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015604 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015605 }
15606 else
15607 {
15608
15609 //update periodicity
15610 if(pMac->roam.tlStatsReqInfo.periodicity)
15611 {
15612 pMac->roam.tlStatsReqInfo.periodicity =
15613 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15614 }
15615 else
15616 {
15617 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15618 }
15619 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15620 {
15621 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15622 }
15623
15624 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15625 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015626 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015627 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015628 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015629 //req TL for class D stats
15630 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15631 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015632 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015633 }
15634 else
15635 {
15636 //save in SME
15637 csrRoamSaveStatsFromTl(pMac, pTlStats);
15638 }
15639 vos_mem_free(pTlStats);
15640 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015641 }
15642 else
15643 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015644 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015645 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015646
Jeff Johnson295189b2012-06-20 16:38:30 -070015647 if(pMac->roam.tlStatsReqInfo.periodicity)
15648 {
15649 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015650 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15651 pMac->roam.tlStatsReqInfo.periodicity);
15652 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015653 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015654 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015655 return eHAL_STATUS_FAILURE;
15656 }
15657 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15658 }
15659 }
15660 }
15661 pMac->roam.tlStatsReqInfo.numClient++;
15662 }
15663
15664 insertInClientList = TRUE;
15665 }
15666 //if one time report requested with non cached result from PE/TL
15667 else if(!cache && !periodicity)
15668 {
15669 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15670 {
15671 //send down a req
15672 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15673 if(!HAL_STATUS_SUCCESS(status))
15674 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015675 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015676 }
15677 //so that when the stats rsp comes back from PE we respond to upper layer
15678 //right away
15679 staEntry.timerExpired = TRUE;
15680 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015681 }
15682 if(statsMask & (1 << eCsrGlobalClassDStats))
15683 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015684 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015685 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015686 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015687 //req TL for class D stats
15688 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15689 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015690 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015691 }
15692 else
15693 {
15694 //save in SME
15695 csrRoamSaveStatsFromTl(pMac, pTlStats);
15696 }
15697 vos_mem_free(pTlStats);
15698 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015699 }
15700 else
15701 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015702 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015703 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015704
15705 }
15706 //if looking for stats from TL only
15707 if(!insertInClientList)
15708 {
15709 //return the stats
15710 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15711 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015712 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015713 if(insertInClientList)
15714 {
15715 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15716 if(!pStaEntry)
15717 {
15718 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015719 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015720 return eHAL_STATUS_FAILURE;
15721 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015722 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015723 //Init & start timer if needed
15724 if(periodicity)
15725 {
15726 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15727 csrRoamStatsClientTimerHandler, pStaEntry );
15728 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15729 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015730 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015731 return eHAL_STATUS_FAILURE;
15732 }
15733 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15734 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15735 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015736 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015737 return eHAL_STATUS_FAILURE;
15738 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015739 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015740 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015741 }
15742 return eHAL_STATUS_SUCCESS;
15743}
15744
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015745#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15746
15747static tSirRetStatus
15748csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15749 tANI_U8* pBD,
15750 tANI_U8 type,
15751 tANI_U8 subType,
15752 tSirMacAddr peerAddr,
15753 tSirMacAddr selfMacAddr)
15754{
15755 tSirRetStatus statusCode = eSIR_SUCCESS;
15756 tpSirMacMgmtHdr pMacHdr;
15757
15758 /* Prepare MAC management header */
15759 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15760
15761 /* Prepare FC */
15762 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15763 pMacHdr->fc.type = type;
15764 pMacHdr->fc.subType = subType;
15765
15766 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015767 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15768 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015769
15770 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15771
15772 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015773 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15774 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015775 return statusCode;
15776} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15777
15778static tSirRetStatus
15779csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15780 tANI_U8 nChannelNum,
15781 tANI_U32 dot11mode,
15782 tSirMacAddr selfMacAddr,
15783 tANI_U8 *pFrame,
15784 tANI_U16 *pusLen)
15785{
15786 tDot11fProbeRequest pr;
15787 tANI_U32 nStatus, nBytes, nPayload;
15788 tSirRetStatus nSirStatus;
15789 /*Bcast tx*/
15790 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15791 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15792
15793
Kiet Lam64c1b492013-07-12 13:56:44 +053015794 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015795
15796 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15797
15798 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15799 {
15800 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15801 }
15802
15803
15804 if (IS_DOT11_MODE_HT(dot11mode))
15805 {
15806 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15807 }
15808
15809
15810 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15811 if ( DOT11F_FAILED( nStatus ) )
15812 {
15813 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15814 "Failed to calculate the packed size f"
15815 "or a Probe Request (0x%08x).\n", nStatus );
15816
15817
15818 nPayload = sizeof( tDot11fProbeRequest );
15819 }
15820 else if ( DOT11F_WARNED( nStatus ) )
15821 {
15822 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15823 "There were warnings while calculating"
15824 "the packed size for a Probe Request ("
15825 "0x%08x).\n", nStatus );
15826 }
15827
15828 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15829
15830 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015831 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015832
15833
15834 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015835 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015836
15837 if ( eSIR_SUCCESS != nSirStatus )
15838 {
15839 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15840 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15841 nSirStatus );
15842 return nSirStatus;
15843 }
15844
15845
15846 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15847 sizeof( tSirMacMgmtHdr ),
15848 nPayload, &nPayload );
15849 if ( DOT11F_FAILED( nStatus ) )
15850 {
15851 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15852 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15853 return eSIR_FAILURE;
15854 }
15855 else if ( DOT11F_WARNED( nStatus ) )
15856 {
15857 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015858 "There were warnings while packing a Probe Request (0x%08x).\n",
15859 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015860 }
15861
15862 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15863 return eSIR_SUCCESS;
15864}
15865
15866eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15867{
15868 vos_msg_t msg;
15869 tSirRoamOffloadScanReq *pRequestBuf;
15870 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15871 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015872 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015873 tANI_U8 *ChannelList = NULL;
15874 tANI_U32 sessionId;
15875 eHalStatus status = eHAL_STATUS_SUCCESS;
15876 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015877 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015878 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015879 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015880 tSirBssDescription *pBssDesc = NULL;
15881 tDot11fBeaconIEs *pIes = NULL;
15882 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080015883 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015884
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015885 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15886
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015887 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015888 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015889 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015890 return eHAL_STATUS_FAILURE;
15891 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015892
15893 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15894 {
15895 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15896 return eHAL_STATUS_FAILURE;
15897 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015898 status = csrRoamGetSessionIdFromBSSID(pMac,
15899 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15900 &sessionId);
15901 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15902 * It is important to ensure that the command is passed down to the FW only
15903 * if the Infra Station is in a connected state.A connected station could also be
15904 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15905 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15906 * irrespective of whichever state we are in.*/
15907 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15908 (command != ROAM_SCAN_OFFLOAD_STOP))
15909 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053015910 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
15911 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
15912 macTraceGetNeighbourRoamState(
15913 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015914 return eHAL_STATUS_FAILURE;
15915 }
15916
15917 if ( !HAL_STATUS_SUCCESS( status ) )
15918 {
15919 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15920 return eHAL_STATUS_FAILURE;
15921 }
15922 pSession = CSR_GET_SESSION( pMac, sessionId );
krunal soni587bf012014-02-04 12:35:11 -080015923 if (NULL == pSession)
15924 {
15925 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15926 "%s:pSession is null", __func__);
15927 return eHAL_STATUS_FAILURE;
15928 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015929 pBssDesc = pSession->pConnectBssDesc;
15930 if (pBssDesc == NULL)
15931 {
15932 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: pBssDesc not found for current session", __func__);
15933 return eHAL_STATUS_FAILURE;
15934 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015935 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15936 if (NULL == pRequestBuf)
15937 {
15938 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15939 return eHAL_STATUS_FAILED_ALLOC;
15940 }
15941
Kiet Lam64c1b492013-07-12 13:56:44 +053015942 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015943 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15944 * host driver reloads, but Riva still up and running*/
Mukul Sharma90506b42014-04-24 13:24:12 +053015945 pRequestBuf->Command = command;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015946 if(command == ROAM_SCAN_OFFLOAD_STOP)
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015947 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015948 pRequestBuf->RoamScanOffloadEnabled = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015949 /*For a STOP Command, there is no need to
15950 * go through filling up all the below parameters
15951 * since they are not required for the STOP command*/
15952 goto send_roam_scan_offload_cmd;
15953 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015954 else
15955 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015956 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15957 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015958 sizeof(tCsrBssid));
15959 pRequestBuf->ConnectedNetwork.ssId.length =
15960 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15961 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15962 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15963 pRequestBuf->ConnectedNetwork.ssId.length);
15964 pRequestBuf->ConnectedNetwork.authentication =
15965 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15966 pRequestBuf->ConnectedNetwork.encryption =
15967 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15968 pRequestBuf->ConnectedNetwork.mcencryption =
15969 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015970 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
15971 {
15972 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015973 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015974 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15975 }
15976 else
15977 {
15978 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
15979 operationChannel = pSession->connectedProfile.operationChannel;
15980
15981 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
15982 {
15983 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15984 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
15985 vos_mem_free(pRequestBuf);
15986 return eHAL_STATUS_FAILURE;
15987 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053015988 if(NULL == pIes)
15989 {
15990 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15991 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053015992 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053015993 return eHAL_STATUS_FAILURE;
15994 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015995 if (pIes->SuppRates.present)
15996 {
15997 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
15998 /*Check for both basic rates and extended rates.*/
15999 for (i = 0; i < pIes->SuppRates.num_rates; i++)
16000 {
16001 /*Check if the Rate is Mandatory or Not*/
16002 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
16003 && (pIes->SuppRates.rates[i] & 0x80))
16004 {
16005 /*Retrieve the actual data rate*/
16006 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
16007 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16008 if (minRate == 0)
16009 minRate = dataRate;
16010 else
16011 minRate = (minRate < dataRate) ? minRate:dataRate;
16012 }
16013 }
16014
16015 if (pIes->ExtSuppRates.present)
16016 {
16017 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
16018 {
16019 /*Check if the Rate is Mandatory or Not*/
16020 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
16021 && (pIes->ExtSuppRates.rates[i] & 0x80))
16022 {
16023 /*Retrieve the actual data rate*/
16024 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
16025 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16026 if (minRate == 0)
16027 minRate = dataRate;
16028 else
16029 minRate = (minRate < dataRate) ? minRate:dataRate;
16030 }
16031 }
16032 }
16033 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
16034 }
16035 else
16036 {
16037 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16038 "%s: Supp Rates not present in pIes", __func__);
16039 vos_mem_free(pRequestBuf);
16040 return eHAL_STATUS_FAILURE;
16041 }
16042 if (NULL != pIes)
16043 {
16044 vos_mem_free(pIes);
16045 pIes = NULL;
16046 }
16047 switch (minRate)
16048 {
16049 case 1:
16050 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
16051 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
16052 break;
16053 case 2:
16054 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
16055 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
16056 break;
16057 case 5:
16058 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
16059 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
16060 break;
16061 case 6:
16062 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16063 {
16064 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
16065 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
16066 }
16067 else
16068 {
16069 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
16070 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
16071 }
16072 break;
16073 case 11:
16074 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
16075 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
16076 break;
16077 case 12:
16078 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16079 {
16080 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
16081 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
16082 }
16083 else
16084 {
16085 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
16086 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
16087 }
16088 break;
16089 case 24:
16090 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16091 {
16092 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
16093 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
16094 }
16095 else
16096 {
16097 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
16098 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
16099 }
16100 break;
16101 default:
16102 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
16103 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16104 break;
16105 }
16106 }
16107 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16108 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
16109 operationChannel, minRate,
16110 pRequestBuf->RxSensitivityThreshold,
16111 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016112 pRequestBuf->RoamRssiDiff =
16113 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016114 pRequestBuf->StartScanReason = reason;
16115 pRequestBuf->NeighborScanTimerPeriod =
16116 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
16117 pRequestBuf->NeighborRoamScanRefreshPeriod =
16118 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
16119 pRequestBuf->NeighborScanChannelMinTime =
16120 pNeighborRoamInfo->cfgParams.minChannelScanTime;
16121 pRequestBuf->NeighborScanChannelMaxTime =
16122 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
16123 pRequestBuf->EmptyRefreshScanPeriod =
16124 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080016125 /* MAWC feature */
16126 pRequestBuf->MAWCEnabled =
16127 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016128#ifdef FEATURE_WLAN_ESE
16129 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016130#endif
16131 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016132#ifdef FEATURE_WLAN_ESE
16133 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016134 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
16135 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016136 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
16137#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016138 currChannelListInfo->numOfChannels == 0)
16139 {
16140
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016141 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
16142 * Give Preference to INI Channels.*/
16143 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
16144 {
16145 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
16146 /*The INI channels need to be filtered with respect to the current
16147 * band that is supported.*/
16148 eBand = pMac->roam.configParam.bandCapability;
16149 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016150 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016151 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16152 "Invalid band, No operation carried out (Band %d)", eBand);
16153 vos_mem_free(pRequestBuf);
16154 return eHAL_STATUS_FAILURE;
16155 }
16156 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
16157 {
16158 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
16159 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
16160 (eCSR_BAND_ALL == eBand))
16161 {
16162 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
16163 csrRoamIsChannelValid(pMac, *ChannelList) &&
16164 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16165 {
16166 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16167 }
16168 }
16169 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016170 }
16171 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16172 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016173 }
16174 else
16175 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016176 ChannelList = pMac->scan.occupiedChannels.channelList;
16177 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
16178 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016179 /*Allow DFS channels only if the DFS channel roam flag is enabled */
16180 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16181 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016182 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16183 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016184 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016185 }
16186 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016187 }
16188 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16189 /* If the profile changes as to what it was earlier, inform the FW through
16190 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
16191 * for the earlier profile and try to learn them afresh.*/
16192 if (reason == REASON_FLUSH_CHANNEL_LIST)
16193 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16194 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016195 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16196 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16197 else
16198 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016199 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016200 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016201 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016202#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016203 else
16204 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016205 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016206 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016207 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016208 if (currChannelListInfo->numOfChannels != 0)
16209 {
16210 ChannelList = currChannelListInfo->ChannelList;
16211 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016212 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016213 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16214 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016215 {
16216 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16217 }
16218 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016219 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016220 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16221 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16222 }
16223 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016224#endif
Kaushik, Sushant5ed8ab62014-03-05 11:21:11 +053016225 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0])) && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016226 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016227 if (j < sizeof(ChannelCacheStr))
16228 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016229 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16230 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016231 }
16232 else
16233 {
16234 break;
16235 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016236 }
16237 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16238 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16239 pRequestBuf->ChannelCacheType,
16240 pRequestBuf->ConnectedNetwork.ChannelCount,
16241 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016242 num_channels = 0;
16243 ChannelList = NULL;
16244
16245 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016246 host_channels = sizeof(pMac->roam.validChannelList);
16247 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016248 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016249 ChannelList = pMac->roam.validChannelList;
16250 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016251 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016252 else
16253 {
16254 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16255 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016256 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016257 return eHAL_STATUS_FAILURE;
16258 }
16259 for(i=0; i<pMac->roam.numValidChannels; i++)
16260 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016261 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16262 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Srinivas Girigowda56076852013-08-20 14:00:50 -070016263 {
16264 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16265 }
16266 ChannelList++;
16267 }
16268 pRequestBuf->ValidChannelCount = num_channels;
16269
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016270 pRequestBuf->MDID.mdiePresent =
16271 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16272 pRequestBuf->MDID.mobilityDomain =
16273 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016274 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16275
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016276 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016277 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16278 * where RFS is the RF Switching time. It is twice RFS to consider the
16279 * time to go off channel and return to the home channel. */
16280 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16281 {
16282 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16283 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16284 " Hence enforcing home away time to disable (0)",
16285 __func__, pRequestBuf->HomeAwayTime,
16286 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16287 pRequestBuf->HomeAwayTime = 0;
16288 }
16289 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016290
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016291 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16292 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16293 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16294 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16295 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16296
16297 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16298 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016299send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016300 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016301 msg.reserved = 0;
16302 msg.bodyptr = pRequestBuf;
16303 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16304 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016305 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16306 vos_mem_free(pRequestBuf);
16307 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016308 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016309 else
16310 {
16311 if (ROAM_SCAN_OFFLOAD_START == command)
16312 bRoamScanOffloadStarted = VOS_TRUE;
16313 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16314 bRoamScanOffloadStarted = VOS_FALSE;
16315 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016316
16317 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16318 return status;
16319}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016320
16321eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16322{
16323 switch(reason)
16324 {
16325 case 0:
16326 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16327 break;
16328 case REASON_OS_REQUESTED_ROAMING_NOW:
16329 csrNeighborRoamProceedWithHandoffReq(pMac);
16330 break;
16331 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016332 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 -070016333 }
16334 return eHAL_STATUS_SUCCESS;
16335}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016336#endif
16337
Jeff Johnson295189b2012-06-20 16:38:30 -070016338tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16339 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16340{
16341 tANI_BOOLEAN found = FALSE;
16342 eHalStatus status = eHAL_STATUS_SUCCESS;
16343 tCsrPeStatsReqInfo staEntry;
16344 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16345 tListElem *pStaEntry = NULL;
16346 VOS_STATUS vosStatus;
16347 tPmcPowerState powerState;
16348 *pFound = FALSE;
16349
16350 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16351 if(pStaEntry)
16352 {
16353 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16354 if(pTempStaEntry->periodicity)
16355 {
16356 pTempStaEntry->periodicity =
16357 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16358 }
16359 else
16360 {
16361 pTempStaEntry->periodicity = periodicity;
16362 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016363 pTempStaEntry->numClient++;
16364 found = TRUE;
16365 }
16366 else
16367 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016368 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016369 staEntry.numClient = 1;
16370 staEntry.periodicity = periodicity;
16371 staEntry.pMac = pMac;
16372 staEntry.rspPending = FALSE;
16373 staEntry.staId = staId;
16374 staEntry.statsMask = statsMask;
16375 staEntry.timerRunning = FALSE;
16376 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16377 if(!pTempStaEntry)
16378 {
16379 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016380 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016381 return NULL;
16382 }
16383 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016384 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16385 if(ePMC_FULL_POWER == powerState)
16386 {
16387 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16388 {
16389 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16390 }
16391 }
16392 else
16393 {
16394 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16395 {
16396 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16397 }
16398 }
16399 if(!pTempStaEntry->timerRunning)
16400 {
16401 //send down a req in case of one time req, for periodic ones wait for timer to expire
16402 if(!pTempStaEntry->rspPending &&
16403 !pTempStaEntry->periodicity)
16404 {
16405 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16406 if(!HAL_STATUS_SUCCESS(status))
16407 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016408 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016409 }
16410 else
16411 {
16412 pTempStaEntry->rspPending = TRUE;
16413 }
16414 }
16415 if(pTempStaEntry->periodicity)
16416 {
16417 if(!found)
16418 {
16419
16420 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16421 csrRoamPeStatsTimerHandler, pTempStaEntry );
16422 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16423 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016424 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016425 return NULL;
16426 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016427 }
16428 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016429 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016430 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16431 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16432 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016433 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016434 return NULL;
16435 }
16436 pTempStaEntry->timerRunning = TRUE;
16437 }
16438 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016439 *pFound = found;
16440 return pTempStaEntry;
16441}
16442
Jeff Johnson295189b2012-06-20 16:38:30 -070016443/*
16444 pStaEntry is no longer invalid upon the return of this function.
16445*/
16446static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16447{
16448 if(pEntry)
16449 {
16450 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16451 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016452 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016453 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016454 }
16455 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016456
16457void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16458{
16459 tListElem *pEntry;
16460 tCsrPeStatsReqInfo *pTempStaEntry;
16461 VOS_STATUS vosStatus;
16462 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016463 if(!pEntry)
16464 {
16465 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016466 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016467 return;
16468 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016469 while( pEntry )
16470 {
16471 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016472 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16473 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016474 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016475 if(pTempStaEntry->timerRunning)
16476 {
16477 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16478 /* If we are not able to stop the timer here, just remove
16479 * the entry from the linked list. Destroy the timer object
16480 * and free the memory in the timer CB
16481 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016482 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016483 {
16484 /* the timer is successfully stopped */
16485 pTempStaEntry->timerRunning = FALSE;
16486
16487 /* Destroy the timer */
16488 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16489 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16490 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016491 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016492 }
16493 }
16494 else
16495 {
16496 // the timer could not be stopped. Hence destroy and free the
16497 // memory for the PE stat entry in the timer CB.
16498 pTempStaEntry->timerStopFailed = TRUE;
16499 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016500 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016501
16502 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16503 {
16504 // Only free the memory if we could stop the timer successfully
16505 if(!pTempStaEntry->timerStopFailed)
16506 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016507 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016508 pTempStaEntry = NULL;
16509 }
16510 break;
16511 }
16512
16513 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16514 }
16515 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016516 return;
16517}
16518
16519
Jeff Johnsone7245742012-09-05 17:12:55 -070016520void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016521{
16522
Jeff Johnsone7245742012-09-05 17:12:55 -070016523 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16524 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16525 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16526 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16527 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16528 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16529 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016530 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016531 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16532 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16533 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16534 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16535 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16536 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016537 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016538 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16539 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016540
16541}
16542
Jeff Johnson295189b2012-06-20 16:38:30 -070016543void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16544 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16545{
16546 tANI_U8 stats[500];
16547 tANI_U8 *pStats = NULL;
16548 tANI_U32 tempMask = 0;
16549 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016550 if(!callback)
16551 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016552 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016553 return;
16554 }
16555 if(!statsMask)
16556 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016557 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016558 return;
16559 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016560 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016561 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016562 while(tempMask)
16563 {
16564 if(tempMask & 1)
16565 {
16566 //new stats info from PE, fill up the stats strucutres in PMAC
16567 switch(counter)
16568 {
16569 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016570 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016571 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16572 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016573 pStats += sizeof(tCsrSummaryStatsInfo);
16574 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016575 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016576 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016577 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16578 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016579 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016580 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016581 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016582 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016583 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16584 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016585 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016586 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016587 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016588 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016589 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16590 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016591 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016592 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016593 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016594 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016595 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16596 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016597 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016598 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016599 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016600 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016601 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16602 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016603 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016604 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016605 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016606 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016607 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016608 }
16609 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016610 tempMask >>=1;
16611 counter++;
16612 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016613 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016614}
16615
Jeff Johnson295189b2012-06-20 16:38:30 -070016616eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16617{
16618 tListElem *pEntry = NULL;
16619 tListElem *pPrevEntry = NULL;
16620 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16621 eHalStatus status = eHAL_STATUS_SUCCESS;
16622 VOS_STATUS vosStatus;
16623 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016624 if(!pEntry)
16625 {
16626 //list empty
16627 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016628 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016629 return status;
16630 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016631 while( pEntry )
16632 {
16633 if(pPrevEntry)
16634 {
16635 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16636 //send up the stats report
16637 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16638 pTempStaEntry->staId, pTempStaEntry->pContext);
16639 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16640 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016641 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016642 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16643 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016644 pTempStaEntry->pPeStaEntry->numClient--;
16645 //check if we need to delete the entry from peStatsReqList too
16646 if(!pTempStaEntry->pPeStaEntry->numClient)
16647 {
16648 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16649 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016650 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016651 //check if we need to stop the tl stats timer too
16652 pMac->roam.tlStatsReqInfo.numClient--;
16653 if(!pMac->roam.tlStatsReqInfo.numClient)
16654 {
16655 if(pMac->roam.tlStatsReqInfo.timerRunning)
16656 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016657 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16658 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016659 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016660 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016661 //we will continue
16662 }
16663 }
16664 pMac->roam.tlStatsReqInfo.periodicity = 0;
16665 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16666 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016667 if (pTempStaEntry->periodicity)
16668 {
16669 //While creating StaEntry in csrGetStatistics,
16670 //Initializing and starting timer only when periodicity is set.
16671 //So Stop and Destroy timer only when periodicity is set.
16672
Jeff Johnsone7245742012-09-05 17:12:55 -070016673 vos_timer_stop( &pTempStaEntry->timer );
16674 // Destroy the vos timer...
16675 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16676 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16677 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016678 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016679 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016680 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016681
Jeff Johnson295189b2012-06-20 16:38:30 -070016682
16683 pPrevEntry = pEntry;
16684 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16685 }
16686 //the last one
16687 if(pPrevEntry)
16688 {
16689 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16690 //send up the stats report
16691 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16692 pTempStaEntry->staId, pTempStaEntry->pContext);
16693 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16694 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016695 return status;
16696
16697}
16698
Jeff Johnson295189b2012-06-20 16:38:30 -070016699eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16700 tRequestFullPowerReason *pReason,
16701 tANI_BOOLEAN *pfNeedPower )
16702{
16703 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16704 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16705 tPmcState pmcState;
16706 eHalStatus status = eHAL_STATUS_SUCCESS;
16707 // TODO : Session info unavailable
16708 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016709 if( pfNeedPower )
16710 {
16711 *pfNeedPower = eANI_BOOLEAN_FALSE;
16712 }
16713 //We only handle CSR commands
16714 if( !(eSmeCsrCommandMask & pCommand->command) )
16715 {
16716 return eHAL_STATUS_SUCCESS;
16717 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016718 //Check PMC state first
16719 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016720 switch( pmcState )
16721 {
16722 case REQUEST_IMPS:
16723 case IMPS:
16724 if( eSmeCommandScan == pCommand->command )
16725 {
16726 switch( pCommand->u.scanCmd.reason )
16727 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016728#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16729 case eCsrScanGetLfrResult:
16730#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016731 case eCsrScanGetResult:
16732 case eCsrScanBGScanAbort:
16733 case eCsrScanBGScanEnable:
16734 case eCsrScanGetScanChnInfo:
16735 //Internal process, no need for full power
16736 fNeedFullPower = eANI_BOOLEAN_FALSE;
16737 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016738 default:
16739 //Other scans are real scan, ask for power
16740 fNeedFullPower = eANI_BOOLEAN_TRUE;
16741 break;
16742 } //switch
16743 }
16744 else
16745 {
16746 //ask for power for roam and status change
16747 fNeedFullPower = eANI_BOOLEAN_TRUE;
16748 }
16749 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016750 case REQUEST_BMPS:
16751 case BMPS:
16752 case REQUEST_START_UAPSD:
16753 case UAPSD:
16754 //We treat WOWL same as BMPS
16755 case REQUEST_ENTER_WOWL:
16756 case WOWL:
16757 if( eSmeCommandRoam == pCommand->command )
16758 {
16759 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16760 tCsrScanResult *pScanResult;
16761 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016762 switch ( pCommand->u.roamCmd.roamReason )
16763 {
16764 case eCsrForcedDisassoc:
16765 case eCsrForcedDisassocMICFailure:
16766 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16767 fNeedFullPower = eANI_BOOLEAN_TRUE;
16768 break;
16769 case eCsrSmeIssuedDisassocForHandoff:
16770 case eCsrForcedDeauth:
16771 case eCsrHddIssuedReassocToSameAP:
16772 case eCsrSmeIssuedReassocToSameAP:
16773 fNeedFullPower = eANI_BOOLEAN_TRUE;
16774 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016775 case eCsrCapsChange:
16776 fNeedFullPower = eANI_BOOLEAN_TRUE;
16777 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016778 default:
16779 //Check whether the profile is already connected. If so, no need for full power
16780 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16781 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16782 {
16783 //Only need to check the first one
16784 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16785 if( pEntry )
16786 {
16787 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16788#if 0
16789 // TODO : Session Specific info pConnectBssDesc
16790 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16791 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16792 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16793 {
16794 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16795 // with Authenticating first. To force this, stop the current association (Disassociate) and
16796 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16797 // a new Association.
16798 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16799 {
16800 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16801 {
16802 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16803 //No need for full power
16804 //Set the flag so the code later can avoid to do the above
16805 //check again.
16806 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16807 break;
16808 }
16809 }
16810 }
16811#endif
16812 }
16813 }
16814 //If we are here, full power is needed
16815 fNeedFullPower = eANI_BOOLEAN_TRUE;
16816 break;
16817 }
16818 }
16819 else if( eSmeCommandWmStatusChange == pCommand->command )
16820 {
16821 //need full power for all
16822 fNeedFullPower = eANI_BOOLEAN_TRUE;
16823 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16824 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016825#ifdef FEATURE_WLAN_TDLS
16826 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16827 {
16828 //TDLS link is getting established. need full power
16829 fNeedFullPower = eANI_BOOLEAN_TRUE;
16830 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16831 }
16832#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016833 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016834 case REQUEST_STOP_UAPSD:
16835 case REQUEST_EXIT_WOWL:
16836 if( eSmeCommandRoam == pCommand->command )
16837 {
16838 fNeedFullPower = eANI_BOOLEAN_TRUE;
16839 switch ( pCommand->u.roamCmd.roamReason )
16840 {
16841 case eCsrForcedDisassoc:
16842 case eCsrForcedDisassocMICFailure:
16843 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16844 break;
16845 default:
16846 break;
16847 }
16848 }
16849 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016850 case STOPPED:
16851 case REQUEST_STANDBY:
16852 case STANDBY:
16853 case LOW_POWER:
16854 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053016855 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
16856 " stopped/standby state %s (%d)" ),
16857 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016858 status = eHAL_STATUS_FAILURE;
16859 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016860 case FULL_POWER:
16861 case REQUEST_FULL_POWER:
16862 default:
16863 //No need to ask for full power. This has to be FULL_POWER state
16864 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016865 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016866 if( pReason )
16867 {
16868 *pReason = reason;
16869 }
16870 if( pfNeedPower )
16871 {
16872 *pfNeedPower = fNeedFullPower;
16873 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016874 return ( status );
16875}
16876
Jeff Johnson295189b2012-06-20 16:38:30 -070016877static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16878{
16879 eHalStatus status = eHAL_STATUS_SUCCESS;
16880 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16881 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016882 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016883 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16884 {
16885 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16886 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016887 return ( status );
16888}
16889
Jeff Johnson295189b2012-06-20 16:38:30 -070016890tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16891{
16892 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016893 if( pCmd )
16894 {
16895 pMac->roam.sPendingCommands++;
16896 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016897 return ( pCmd );
16898}
16899
Jeff Johnson295189b2012-06-20 16:38:30 -070016900void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16901{
16902 if (pMac->roam.sPendingCommands > 0)
16903 {
16904 //All command allocated through csrGetCommandBuffer need to
16905 //decrement the pending count when releasing.
16906 pMac->roam.sPendingCommands--;
16907 smeReleaseCommand( pMac, pCommand );
16908 }
16909 else
16910 {
16911 smsLog(pMac, LOGE, FL( "no pending commands"));
16912 VOS_ASSERT(0);
16913 }
16914}
16915
Jeff Johnson295189b2012-06-20 16:38:30 -070016916//Return SUCCESS is the command is queued, failed
16917eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16918{
16919 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016920 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16921 {
16922 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16923 pCommand->u.scanCmd.reason);
16924 return eHAL_STATUS_CSR_WRONG_STATE;
16925 }
16926
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016927 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16928 {
16929 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16930 &pCommand->Link, LL_ACCESS_LOCK);
16931 // process the command queue...
16932 smeProcessPendingQueue(pMac);
16933 status = eHAL_STATUS_SUCCESS;
16934 goto end;
16935 }
16936
Jeff Johnson295189b2012-06-20 16:38:30 -070016937 //We can call request full power first before putting the command into pending Q
16938 //because we are holding SME lock at this point.
16939 status = csrRequestFullPower( pMac, pCommand );
16940 if( HAL_STATUS_SUCCESS( status ) )
16941 {
16942 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016943 //make sure roamCmdPendingList is not empty first
16944 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16945 if( fNoCmdPending )
16946 {
16947 smePushCommand( pMac, pCommand, fHighPriority );
16948 }
16949 else
16950 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016951 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016952 //no list lock is needed since SME lock is held
16953 if( !fHighPriority )
16954 {
16955 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16956 }
16957 else {
16958 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16959 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016960 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016961 }
16962 else if( eHAL_STATUS_PMC_PENDING == status )
16963 {
16964 //no list lock is needed since SME lock is held
16965 if( !fHighPriority )
16966 {
16967 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16968 }
16969 else {
16970 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16971 }
16972 //Let caller know the command is queue
16973 status = eHAL_STATUS_SUCCESS;
16974 }
16975 else
16976 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016977 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016978 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016979 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016980 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016981end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016982 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016983}
Jeff Johnson295189b2012-06-20 16:38:30 -070016984eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16985{
16986 eHalStatus status = eHAL_STATUS_SUCCESS;
16987 tSirUpdateAPWPSIEsReq *pMsg;
16988 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16989
16990 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16991 if (NULL == pSession)
16992 {
16993 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16994 return eHAL_STATUS_FAILURE;
16995 }
16996
Jeff Johnson295189b2012-06-20 16:38:30 -070016997 do
16998 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016999 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
17000 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17001 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017002 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
17003
17004 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070017005 VOS_ASSERT(pBuf);
17006
Jeff Johnson295189b2012-06-20 16:38:30 -070017007 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017008 // transactionId
17009 *pBuf = 0;
17010 *( pBuf + 1 ) = 0;
17011 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070017012 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017013 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17014 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017015 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017016 //sessionId
17017 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017018 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017019 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070017020 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070017021 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017022 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017023 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017024 return ( status );
17025}
Jeff Johnson295189b2012-06-20 16:38:30 -070017026eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
17027{
17028 eHalStatus status = eHAL_STATUS_SUCCESS;
17029 tSirUpdateAPWPARSNIEsReq *pMsg;
17030 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017031 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17032 if (NULL == pSession)
17033 {
17034 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17035 return eHAL_STATUS_FAILURE;
17036 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017037 do
17038 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017039 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
17040 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17041 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017042 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070017043 pBuf = (tANI_U8 *)&pMsg->transactionId;
17044 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017045 // transactionId
17046 *pBuf = 0;
17047 *( pBuf + 1 ) = 0;
17048 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070017049 VOS_ASSERT(pBuf);
17050
Jeff Johnson295189b2012-06-20 16:38:30 -070017051 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017052 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17053 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017054 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017055 // sessionId
17056 *pBuf++ = (tANI_U8)sessionId;
17057
17058 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017059 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070017060 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070017061 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017062 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017063 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017064 return ( status );
17065}
Jeff Johnson295189b2012-06-20 16:38:30 -070017066
17067#ifdef WLAN_FEATURE_VOWIFI_11R
17068//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
17069eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
17070{
17071 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17072 tpSirFTPreAuthReq pftPreAuthReq;
17073 tANI_U16 auth_req_len = 0;
17074 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017075 auth_req_len = sizeof(tSirFTPreAuthReq);
17076 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053017077 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070017078 {
17079 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
17080 return eHAL_STATUS_RESOURCES;
17081 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017082 // Save the SME Session ID here. We need it while processing the preauth response
17083 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017084 vos_mem_zero(pftPreAuthReq, auth_req_len);
17085
17086 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
17087 sizeof(pBssDescription->length) + pBssDescription->length);
17088
17089 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
17090
17091 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
17092
Kiet Lam64c1b492013-07-12 13:56:44 +053017093 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
17094 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
17095 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
17096 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017097
Jeff Johnson295189b2012-06-20 16:38:30 -070017098#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080017099 if (csrRoamIs11rAssoc(pMac) &&
17100 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070017101 {
17102 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053017103 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
17104 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070017105 }
17106 else
17107#endif
17108 {
17109 pftPreAuthReq->ft_ies_length = 0;
17110 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070017111 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
17112 sizeof(pBssDescription->length) + pBssDescription->length);
17113 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070017114 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
17115}
Jeff Johnson295189b2012-06-20 16:38:30 -070017116/*--------------------------------------------------------------------------
17117 * This will receive and process the FT Pre Auth Rsp from the current
17118 * associated ap.
17119 *
17120 * This will invoke the hdd call back. This is so that hdd can now
17121 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
17122 ------------------------------------------------------------------------*/
17123void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
17124{
17125 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17126 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017127#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017128 tCsrRoamInfo roamInfo;
17129#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017130 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070017131
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017132#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080017133 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017134 if (status != eHAL_STATUS_SUCCESS) {
17135 /*
17136 * Bail out if pre-auth was not even processed.
17137 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017138 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
17139 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017140 return;
17141 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017142#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017143 /* The below function calls/timers should be invoked only if the pre-auth is successful */
17144 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
17145 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070017146 // Implies a success
17147 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017148 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
17149 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053017150 /* No need to notify qos module if this is a non 11r & ESE roam*/
17151 if (csrRoamIs11rAssoc(pMac)
17152#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
17153 || csrRoamIsESEAssoc(pMac)
17154#endif
17155 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070017156 {
17157 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
17158 }
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053017159#ifdef DEBUG_ROAM_DELAY
17160 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
17161#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017162 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
17163 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017164 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
17165 60);
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053017166#ifdef DEBUG_ROAM_DELAY
17167 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
17168#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017169 if (eHAL_STATUS_SUCCESS != status)
17170 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017171 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017172 return;
17173 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017174 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017175 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
17176 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070017177 if (csrRoamIs11rAssoc(pMac))
17178 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
17179 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
17180
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017181#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17182 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017183 {
17184 /* read TSF */
17185 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
17186
17187 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017188 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017189 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
17190 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017191#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017192#ifdef FEATURE_WLAN_LFR
17193 // If Legacy Fast Roaming is enabled, signal the supplicant
17194 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053017195 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017196 {
17197 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017198 vos_mem_copy((void *)&roamInfo.bssid,
17199 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017200 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
17201 }
17202
17203#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017204
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017205 // If its an Open Auth, FT IEs are not provided by supplicant
17206 // Hence populate them here
17207 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
17208 pMac->ft.ftSmeContext.addMDIE = FALSE;
17209 if( csrRoamIs11rAssoc(pMac) &&
17210 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
17211 {
17212 tANI_U16 ft_ies_length;
17213 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
17214
17215 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
17216 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
17217 {
17218 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
17219 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
17220 }
17221
17222 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
17223 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
17224 {
17225 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
17226 }
17227 else
17228 {
17229 // Copy the RIC IEs to reassoc IEs
17230 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
17231 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
17232 pFTPreAuthRsp->ric_ies_length);
17233 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
17234 pMac->ft.ftSmeContext.addMDIE = TRUE;
17235 }
17236 }
17237
Jeff Johnson295189b2012-06-20 16:38:30 -070017238 // Done with it, init it.
17239 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
17240}
17241#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017242
Jeff Johnson295189b2012-06-20 16:38:30 -070017243#ifdef FEATURE_WLAN_BTAMP_UT_RF
17244void csrRoamJoinRetryTimerHandler(void *pv)
17245{
17246 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
17247 tpAniSirGlobal pMac = pInfo->pMac;
17248 tANI_U32 sessionId = pInfo->sessionId;
17249 tCsrRoamSession *pSession;
17250
17251 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17252 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017253 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017254 pSession = CSR_GET_SESSION( pMac, sessionId );
17255 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
17256 {
17257 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
17258 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017259 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017260 }
17261 }
17262 }
17263}
Jeff Johnson295189b2012-06-20 16:38:30 -070017264eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
17265{
17266 eHalStatus status = eHAL_STATUS_FAILURE;
17267 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17268
17269 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
17270 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017271 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070017272 pSession->maxRetryCount--;
17273 pSession->joinRetryTimerInfo.pMac = pMac;
17274 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017275 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
17276 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017277 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017278 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017279 }
17280 }
17281 else
17282 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017283 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070017284 pSession->maxRetryCount);
17285 }
17286
17287 return (status);
17288}
Jeff Johnson295189b2012-06-20 16:38:30 -070017289eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
17290{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017291 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070017292 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17293 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017294 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070017295 }
17296
17297 return eHAL_STATUS_SUCCESS;
17298}
17299#endif
17300
17301
17302/*
17303 pBuf points to the beginning of the message
17304 LIM packs disassoc rsp as below,
17305 messageType - 2 bytes
17306 messageLength - 2 bytes
17307 sessionId - 1 byte
17308 transactionId - 2 bytes (tANI_U16)
17309 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17310 peerMacAddr - 6 bytes
17311 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17312*/
17313static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17314{
17315 if(pBuf && pRsp)
17316 {
17317 pBuf += 4; //skip type and length
17318 pRsp->sessionId = *pBuf++;
17319 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17320 pBuf += 2;
17321 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17322 pBuf += 4;
17323 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17324 }
17325}
17326
Jeff Johnsond13512a2012-07-17 11:42:19 -070017327eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17328{
17329 static uNvTables nvTables;
17330 eHalStatus status = eHAL_STATUS_SUCCESS;
17331 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17332
17333 /* read the country code from NV and use it */
17334 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17335 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017336 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17337 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017338 return status;
17339 }
17340 else
17341 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017342 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017343 status = eHAL_STATUS_FAILURE;
17344 return status;
17345 }
17346}
17347
17348eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17349{
Kiet Lam64c1b492013-07-12 13:56:44 +053017350 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017351 return eHAL_STATUS_SUCCESS;
17352}
schang86c22c42013-03-13 18:41:24 -070017353
17354eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17355{
17356 tSirSetTxPowerReq *pMsg = NULL;
17357 eHalStatus status = eHAL_STATUS_SUCCESS;
17358 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17359
17360 if (!pSession)
17361 {
17362 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17363 return eHAL_STATUS_FAILURE;
17364 }
17365
Kiet Lam64c1b492013-07-12 13:56:44 +053017366 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17367 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17368 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17369 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17370 pMsg->length = sizeof(tSirSetTxPowerReq);
17371 pMsg->mwPower = mW;
17372 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17373 sizeof(tSirMacAddr));
17374 status = palSendMBMessage(pMac->hHdd, pMsg);
17375 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017376 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017377 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17378 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017379 }
17380 return status;
17381}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017382
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017383eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17384{
17385 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17386 eHalStatus status = eHAL_STATUS_SUCCESS;
17387 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17388
17389 if (!pSession)
17390 {
17391 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17392 return eHAL_STATUS_FAILURE;
17393 }
17394 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17395 {
17396 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053017397
17398 if( NULL == pMsg )
17399 {
17400 smsLog(pMac, LOGE, FL("PMsg is NULL "));
17401 return eHAL_STATUS_FAILURE;
17402 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017403 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17404 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17405 pMsg->length = sizeof(tANI_U8);
17406 pMsg->seesionId = sessionId;
17407 status = palSendMBMessage(pMac->hHdd, pMsg);
17408 if (!HAL_STATUS_SUCCESS(status))
17409 {
17410 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17411 //pMsg is freed by palSendMBMessage
17412 }
17413 }
17414 else
17415 {
17416 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17417 status = eHAL_STATUS_FAILURE;
17418 }
17419 return status;
17420}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017421/* Returns whether a session is in VOS_STA_MODE...or not */
17422tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17423{
17424 tCsrRoamSession *pSession = NULL;
17425 pSession = CSR_GET_SESSION ( pMac, sessionId );
17426 if(!pSession)
17427 {
17428 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17429 return eANI_BOOLEAN_FALSE;
17430 }
17431 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17432 {
17433 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17434 return eANI_BOOLEAN_FALSE;
17435 }
17436 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17437 {
17438 return eANI_BOOLEAN_FALSE;
17439 }
17440 /* There is a possibility that the above check may fail,because
17441 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17442 * when it is connected.So,we may sneak through the above check even
17443 * if we are not a STA mode INFRA station. So, if we sneak through
17444 * the above condition, we can use the following check if we are
17445 * really in STA Mode.*/
17446
17447 if ( NULL != pSession->pCurRoamProfile )
17448 {
17449 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17450 {
17451 return eANI_BOOLEAN_TRUE;
17452 } else {
17453 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17454 return eANI_BOOLEAN_FALSE;
17455 }
17456 }
17457
17458 return eANI_BOOLEAN_FALSE;
17459}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017460
17461#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17462eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17463 tCsrHandoffRequest *pHandoffInfo)
17464{
17465 eHalStatus status = eHAL_STATUS_SUCCESS;
17466 vos_msg_t msg;
17467
17468 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017469 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17470 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017471 {
17472 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017473 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017474 }
17475 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17476 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17477 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17478 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017479 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017480 pHandoffInfo->bssid,
17481 6);
17482 msg.type = eWNI_SME_HANDOFF_REQ;
17483 msg.bodyptr = pMsg;
17484 msg.reserved = 0;
17485 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17486 {
17487 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017488 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017489 status = eHAL_STATUS_FAILURE;
17490 }
17491 return status;
17492}
17493#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017494
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017495
17496#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017497/* ---------------------------------------------------------------------------
17498 \fn csrSetCCKMIe
17499 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17500 data structure and this IE will be packed inside reassociation request
17501 \param pMac - pMac global structure
17502 \param sessionId - Current session id
17503 \param pCckmIe - pointer to CCKM IE data
17504 \param ccKmIeLen - length of the CCKM IE
17505 \- return Success or failure
17506 -------------------------------------------------------------------------*/
17507VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17508 const tANI_U8 *pCckmIe,
17509 const tANI_U8 ccKmIeLen)
17510{
17511 eHalStatus status = eHAL_STATUS_SUCCESS;
17512 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17513
17514 if (!pSession)
17515 {
17516 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17517 return eHAL_STATUS_FAILURE;
17518 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017519 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017520 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17521 return status;
17522}
17523
17524/* ---------------------------------------------------------------------------
17525 \fn csrRoamReadTSF
17526 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17527 probe response reception from the hand off AP to arrive at the latest TSF value.
17528 \param pMac - pMac global structure
17529 \param pTimestamp - output TSF timestamp
17530 \- return Success or failure
17531 -------------------------------------------------------------------------*/
17532VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17533{
17534 eHalStatus status = eHAL_STATUS_SUCCESS;
17535 tCsrNeighborRoamBSSInfo handoffNode;
17536 tANI_U32 timer_diff = 0;
17537 tANI_U32 timeStamp[2];
17538 tpSirBssDescription pBssDescription = NULL;
17539
17540 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17541 pBssDescription = handoffNode.pBssDescription;
17542
17543 // Get the time diff in milli seconds
17544 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17545 // Convert msec to micro sec timer
17546 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17547
17548 timeStamp[0] = pBssDescription->timeStamp[0];
17549 timeStamp[1] = pBssDescription->timeStamp[1];
17550
17551 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17552
Kiet Lamf2f201e2013-11-16 21:24:16 +053017553 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017554 sizeof (tANI_U32) * 2);
17555 return status;
17556}
17557
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017558#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017559