blob: 927bafee72baa43778e193dfac30a1499680405b [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -08002* Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
3* All Rights Reserved.
4* Qualcomm Atheros Confidential and Proprietary.
5*/
Jeff Johnson295189b2012-06-20 16:38:30 -07006/** ------------------------------------------------------------------------- *
7 ------------------------------------------------------------------------- *
Jeff Johnsone7245742012-09-05 17:12:55 -07008
Jeff Johnson295189b2012-06-20 16:38:30 -07009
10 \file csrApiRoam.c
11
12 Implementation for the Common Roaming interfaces.
13
Kiet Lamaa8e15a2014-02-11 23:30:06 -080014 Copyright (C) 2008 Qualcomm, Incorporated
15
Jeff Johnson295189b2012-06-20 16:38:30 -070016
17 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070018/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070019 EDIT HISTORY FOR FILE
20
Jeff Johnson295189b2012-06-20 16:38:30 -070021 This section contains comments describing changes made to the module.
22 Notice that changes are listed in reverse chronological order.
23
Jeff Johnson295189b2012-06-20 16:38:30 -070024 when who what, where, why
25---------- --- --------------------------------------------------------
2606/03/10 js Added support to hostapd driven
27 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070028===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070029#include "aniGlobal.h" //for tpAniSirGlobal
30#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070031#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070032#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070033#include "palApi.h"
34#include "csrInsideApi.h"
35#include "smsDebug.h"
36#include "logDump.h"
37#include "smeQosInternal.h"
38#include "wlan_qct_tl.h"
39#include "smeInside.h"
40#include "vos_diag_core_event.h"
41#include "vos_diag_core_log.h"
42#include "csrApi.h"
43#include "pmc.h"
44#include "vos_nvitem.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070045#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
46#include "csrNeighborRoam.h"
47#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070048#if defined(FEATURE_WLAN_CCX) && !defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -070049#include "csrCcx.h"
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070050#endif /* FEATURE_WLAN_CCX && !FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070051#define CSR_NUM_IBSS_START_CHANNELS_50 4
52#define CSR_NUM_IBSS_START_CHANNELS_24 3
53#define CSR_DEF_IBSS_START_CHANNEL_50 36
54#define CSR_DEF_IBSS_START_CHANNEL_24 1
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080055#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 -070056#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
57/*---------------------------------------------------------------------------
58 OBIWAN recommends [8 10]% : pick 9%
59---------------------------------------------------------------------------*/
60#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070061/*---------------------------------------------------------------------------
62 OBIWAN recommends -85dBm
63---------------------------------------------------------------------------*/
64#define CSR_VCC_RSSI_THRESHOLD 80
65#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
66#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
67#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
68#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -070069//We use constatnt 4 here
70//This macro returns true when higher AC parameter is bigger than lower AC for a difference
71//The bigger the number, the less chance of TX
72//It must put lower AC as the first parameter.
73#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070074//Flag to send/do not send disassoc frame over the air
75#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -070076#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -070077#define MAX_CB_VALUE_IN_INI (2)
78
Srinivas Girigowda577ed652013-08-14 11:38:29 -070079#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
80static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
81#endif
82
Jeff Johnson295189b2012-06-20 16:38:30 -070083/*--------------------------------------------------------------------------
84 Static Type declarations
85 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -080086static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -080087
Jeff Johnson295189b2012-06-20 16:38:30 -070088/*--------------------------------------------------------------------------
89 Type declarations
90 ------------------------------------------------------------------------*/
91#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070092int diagAuthTypeFromCSRType(eCsrAuthType authType)
93{
94 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -070095 switch(authType)
96 {
97 case eCSR_AUTH_TYPE_SHARED_KEY:
98 n = AUTH_SHARED;
99 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700100 case eCSR_AUTH_TYPE_WPA:
101 n = AUTH_WPA_EAP;
102 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700103 case eCSR_AUTH_TYPE_WPA_PSK:
104 n = AUTH_WPA_PSK;
105 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700106 case eCSR_AUTH_TYPE_RSN:
107 n = AUTH_WPA2_EAP;
108 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700109 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700110#ifdef WLAN_FEATURE_11W
111 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
112#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700113 n = AUTH_WPA2_PSK;
114 break;
115#ifdef FEATURE_WLAN_WAPI
116 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
117 n = AUTH_WAPI_CERT;
118 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700119 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
120 n = AUTH_WAPI_PSK;
121 break;
122#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700123 default:
124 break;
125 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700126 return (n);
127}
Jeff Johnson295189b2012-06-20 16:38:30 -0700128int diagEncTypeFromCSRType(eCsrEncryptionType encType)
129{
130 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700131 switch(encType)
132 {
133 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
134 case eCSR_ENCRYPT_TYPE_WEP40:
135 n = ENC_MODE_WEP40;
136 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700137 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
138 case eCSR_ENCRYPT_TYPE_WEP104:
139 n = ENC_MODE_WEP104;
140 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700141 case eCSR_ENCRYPT_TYPE_TKIP:
142 n = ENC_MODE_TKIP;
143 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700144 case eCSR_ENCRYPT_TYPE_AES:
145 n = ENC_MODE_AES;
146 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700147#ifdef FEATURE_WLAN_WAPI
148 case eCSR_ENCRYPT_TYPE_WPI:
149 n = ENC_MODE_SMS4;
150 break;
151#endif /* FEATURE_WLAN_WAPI */
152 default:
153 break;
154 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 return (n);
156}
Jeff Johnson295189b2012-06-20 16:38:30 -0700157#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700158static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
159static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700160static void initConfigParam(tpAniSirGlobal pMac);
161static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
162 eCsrRoamCompleteResult Result, void *Context );
163static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
164 tCsrRoamProfile *pProfile,
165 tANI_BOOLEAN *pfSameIbss );
166static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
167static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700168 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
169static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700170eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
171static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
172eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
173eHalStatus csrRoamClose(tpAniSirGlobal pMac);
174void csrRoamMICErrorTimerHandler(void *pv);
175void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
176tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
177
178static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
179static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
180static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700181eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
182eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
183static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700184static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700185static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700186static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
187eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
188 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
189 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
190 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
191 tANI_U8 *pKeyRsc );
192static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
193 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
194 tCsrRoamProfile *pProfile );
195void csrRoamStatisticsTimerHandler(void *pv);
196void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700197static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
198VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
199 v_U8_t rssiNotification,
200 void * context);
201static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
202void csrRoamVccTrigger(tpAniSirGlobal pMac);
203eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
204/*
205 pStaEntry is no longer invalid upon the return of this function.
206*/
207static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700208static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700209static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700210tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
211 tDblLinkList *pStaList,
212 tCsrStatsClientReqInfo *pStaEntry);
213void csrRoamStatsClientTimerHandler(void *pv);
214tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
215 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
216void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
217 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700218void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700219void csrRoamTlStatsTimerHandler(void *pv);
220void csrRoamPeStatsTimerHandler(void *pv);
221tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
222void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
223tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
224eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
225static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
226static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
227static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
228static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
229 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
230//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
231static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
232void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
233#ifdef FEATURE_WLAN_BTAMP_UT_RF
234void csrRoamJoinRetryTimerHandler(void *pv);
235#endif
236extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700237extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700238static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700239void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700240
241//Initialize global variables
242static void csrRoamInitGlobals(tpAniSirGlobal pMac)
243{
244 if(pMac)
245 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800246 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
247 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700248 }
249 return;
250}
251
Jeff Johnson295189b2012-06-20 16:38:30 -0700252static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
253{
254 if(pMac)
255 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800256 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 }
258 return;
259}
Jeff Johnson295189b2012-06-20 16:38:30 -0700260eHalStatus csrOpen(tpAniSirGlobal pMac)
261{
262 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530263#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700264 static uNvTables nvTables;
265 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700266 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530267#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700268 tANI_U32 i;
269
270 do
271 {
272 /* Initialize CSR Roam Globals */
273 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
275 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
276
277 initConfigParam(pMac);
278 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
279 break;
280 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
281 break;
282 pMac->roam.nextRoamId = 1; //Must not be 0
283 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
284 break;
285 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
286 break;
287 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
288 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530289
290#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700291 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
292 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
293 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530294 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
295 WNI_CFG_COUNTRY_CODE_LEN);
296 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 }
298 else
299 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800300 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700301 //hardcoded for now
302 pMac->scan.countryCodeDefault[0] = 'U';
303 pMac->scan.countryCodeDefault[1] = 'S';
304 pMac->scan.countryCodeDefault[2] = 'I';
305 //status = eHAL_STATUS_SUCCESS;
306 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700307 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530308
309 if (!('0' == pMac->scan.countryCodeDefault[0] &&
310 '0' == pMac->scan.countryCodeDefault[1]))
311 {
312 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
313 &regId, COUNTRY_NV);
314 }
315 else
316 {
317 regId = REGDOMAIN_WORLD;
318 }
Abhishek Singha306a442013-11-07 18:39:01 +0530319 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700320 pMac->scan.domainIdDefault = regId;
321 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530322 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
323 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530325#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700326 }while(0);
327
328 return (status);
329}
330
Mihir Shetee1093ba2014-01-21 20:13:32 +0530331/* --------------------------------------------------------------------------
332 \fn csrInitChannels
333 \brief This function must be called to initialize CSR channel lists
334 \return eHalStatus
335 ----------------------------------------------------------------------------*/
336eHalStatus csrInitChannels(tpAniSirGlobal pMac)
337{
338 eHalStatus status = eHAL_STATUS_SUCCESS;
339 static uNvTables nvTables;
340 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
341 v_REGDOMAIN_t regId;
342
343 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
344 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
345 {
346 vos_mem_copy(pMac->scan.countryCodeDefault,
347 nvTables.defaultCountryTable.countryCode,
348 WNI_CFG_COUNTRY_CODE_LEN);
349 }
350 else
351 {
352 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
353 //hardcoded for now
354 pMac->scan.countryCodeDefault[0] = 'U';
355 pMac->scan.countryCodeDefault[1] = 'S';
356 pMac->scan.countryCodeDefault[2] = 'I';
357 }
358 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
359
360 if (!('0' == pMac->scan.countryCodeDefault[0] &&
361 '0' == pMac->scan.countryCodeDefault[1]))
362 {
363 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
364 &regId, COUNTRY_NV);
365 }
366 else
367 {
368 regId = REGDOMAIN_WORLD;
369 }
370
371 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
372 pMac->scan.domainIdDefault = regId;
373 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
374 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
375 WNI_CFG_COUNTRY_CODE_LEN);
376 status = csrInitGetChannels( pMac );
377
378 return status;
379}
380
Jeff Johnson295189b2012-06-20 16:38:30 -0700381eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
382{
383 eHalStatus status = eHAL_STATUS_SUCCESS;
384 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
385 v_REGDOMAIN_t regId;
386 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 if(NULL == apCntryCode)
388 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530389 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700390 return eHAL_STATUS_FAILURE;
391 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530392 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700393 /* To get correct Regulatory domain from NV table
394 * 2 character Country code should be used
395 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700396 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
397/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700398 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700399
400 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800402 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700403 return eHAL_STATUS_FAILURE;
404 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700405*/
Kiet Lam6c583332013-10-14 05:37:09 +0530406 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
407 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 if (status != eHAL_STATUS_SUCCESS)
409 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700410 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700411 return status;
412 }
Abhishek Singha306a442013-11-07 18:39:01 +0530413 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700414 if (status != eHAL_STATUS_SUCCESS)
415 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700416 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700417 return status;
418 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700419 pMac->scan.domainIdDefault = regId;
420 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700421 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530422 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
423
Jeff Johnson295189b2012-06-20 16:38:30 -0700424 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530425 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
426
Jeff Johnson295189b2012-06-20 16:38:30 -0700427 /* If 2 bytes country code, 3rd byte must be filled with space */
428 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
429 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530430 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700431 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530432 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
433 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700434 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700435 return status;
436}
Jeff Johnson295189b2012-06-20 16:38:30 -0700437eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
438{
439 eHalStatus status = eHAL_STATUS_SUCCESS;
440 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
441 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530442 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
443 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700444 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
445 {
446 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
447 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
448 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
449 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
450 }
451 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
452
453 return status;
454}
Jeff Johnson295189b2012-06-20 16:38:30 -0700455eHalStatus csrClose(tpAniSirGlobal pMac)
456{
457 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800458
Jeff Johnson295189b2012-06-20 16:38:30 -0700459 csrRoamClose(pMac);
460 csrScanClose(pMac);
461 csrLLClose(&pMac->roam.statsClientReqList);
462 csrLLClose(&pMac->roam.peStatsReqList);
463 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700464 /* DeInit Globals */
465 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700466 return (status);
467}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530468
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800469eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530470{
471 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800472 tCsrScanStruct *pScan = &pMac->scan;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530473 tANI_U8 numChan = pScan->base20MHzChannels.numChannels;
474 tANI_U32 bufLen = sizeof(tSirUpdateChanList) +
475 (sizeof(tSirUpdateChanParam) * (numChan - 1));
476 vos_msg_t msg;
477 tANI_U8 i;
478
479 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
480 if (!pChanList)
481 {
482 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
483 "Failed to allocate memory for tSirUpdateChanList");
484 return eHAL_STATUS_FAILED_ALLOC;
485 }
486
487 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
488 msg.reserved = 0;
489 msg.bodyptr = pChanList;
490 pChanList->numChan = numChan;
491 for (i = 0; i < pChanList->numChan; i++)
492 {
493 pChanList->chanParam[i].chanId = pScan->defaultPowerTable[i].chanId;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800494 pChanList->chanParam[i].pwr = cfgGetRegulatoryMaxTransmitPower(pMac,
495 pScan->defaultPowerTable[i].chanId);
496 if (vos_nv_getChannelEnabledState(pChanList->chanParam[i].chanId) ==
497 NV_CHANNEL_DFS)
498 pChanList->chanParam[i].dfsSet = VOS_TRUE;
499 else
500 pChanList->chanParam[i].dfsSet = VOS_FALSE;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530501 }
502
503 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
504 {
505 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
506 "%s: Failed to post msg to WDA", __func__);
507 vos_mem_free(pChanList);
508 return eHAL_STATUS_FAILURE;
509 }
510
511 return eHAL_STATUS_SUCCESS;
512}
513
Jeff Johnson295189b2012-06-20 16:38:30 -0700514eHalStatus csrStart(tpAniSirGlobal pMac)
515{
516 eHalStatus status = eHAL_STATUS_SUCCESS;
517 tANI_U32 i;
518
519 do
520 {
521 //save the global vos context
522 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
523 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
524 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
525
526 status = csrRoamStart(pMac);
527 if(!HAL_STATUS_SUCCESS(status)) break;
528 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
529 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
530 if(!HAL_STATUS_SUCCESS(status)) break;
531 pMac->roam.sPendingCommands = 0;
532 csrScanEnable(pMac);
533#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
534 status = csrNeighborRoamInit(pMac);
535#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
536 pMac->roam.tlStatsReqInfo.numClient = 0;
537 pMac->roam.tlStatsReqInfo.periodicity = 0;
538 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
539 //init the link quality indication also
540 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
541 if(!HAL_STATUS_SUCCESS(status))
542 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800543 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700544 break;
545 }
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800546#ifdef QCA_WIFI_2_0
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530547 if (pMac->fScanOffload)
548 {
549 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
550 "Scan offload is enabled, update default chan list");
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800551 status = csrUpdateChannelList(pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530552 }
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800553#else
554 status = csrUpdateChannelList(pMac);
555#endif
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530556
Jeff Johnson295189b2012-06-20 16:38:30 -0700557 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700558#if defined(ANI_LOGDUMP)
559 csrDumpInit(pMac);
560#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 return (status);
562}
563
Kiet Lama72a2322013-11-15 11:18:11 +0530564eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700565{
566 tANI_U32 sessionId;
567 tANI_U32 i;
568
569 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
570 {
571 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
572 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 csrScanDisable(pMac);
574 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
575 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700576 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
577
578#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
579 csrNeighborRoamClose(pMac);
580#endif
581 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700582 // deregister from PMC since we register during csrStart()
583 // (ignore status since there is nothing we can do if it fails)
584 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 //Reset the domain back to the deault
586 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800587 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700588
589 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
590 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530591 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700592 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
593 }
594
Kiet Lama72a2322013-11-15 11:18:11 +0530595#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
596 /* When HAL resets all the context information
597 * in HAL is lost, so we might need to send the
598 * scan offload request again when it comes
599 * out of reset for scan offload to be functional
600 */
601 if (HAL_STOP_TYPE_SYS_RESET == stopType)
602 {
603 bRoamScanOffloadStarted = VOS_FALSE;
604 }
605#endif
606
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 return (eHAL_STATUS_SUCCESS);
608}
609
Jeff Johnson295189b2012-06-20 16:38:30 -0700610eHalStatus csrReady(tpAniSirGlobal pMac)
611{
612 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700613 csrScanGetSupportedChannels( pMac );
614 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
615 //use it to init the background scan list
616 csrInitBGScanChannelList(pMac);
617 /* HDD issues the init scan */
618 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800619 /* If the gScanAgingTime is set to '0' then scan results aging timeout
620 based on timer feature is not enabled*/
621 if(0 != pMac->scan.scanResultCfgAgingTime )
622 {
623 csrScanStartResultCfgAgingTimer(pMac);
624 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 //Store the AC weights in TL for later use
626 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 status = csrInitChannelList( pMac );
628 if ( ! HAL_STATUS_SUCCESS( status ) )
629 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800630 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700631 status );
632 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 return (status);
634}
Jeff Johnson295189b2012-06-20 16:38:30 -0700635void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
636{
637 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
639 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
640}
Jeff Johnson295189b2012-06-20 16:38:30 -0700641void csrSetGlobalCfgs( tpAniSirGlobal pMac )
642{
Jeff Johnsone7245742012-09-05 17:12:55 -0700643
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
645 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
646 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
647 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
648 NULL, eANI_BOOLEAN_FALSE);
649 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700650 /* 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
651 * Once session is established we will use the session related params stored in PE session for CB mode
652 */
653 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
655
656 //Update the operating mode to configured value during initialization,
657 //So that client can advertise full capabilities in Probe request frame.
658 csrSetDefaultDot11Mode( pMac );
659}
660
Jeff Johnson295189b2012-06-20 16:38:30 -0700661eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
662{
663 eHalStatus status = eHAL_STATUS_SUCCESS;
664 tANI_U32 i;
665 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700666 do
667 {
668 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
669 {
670 pSession = CSR_GET_SESSION( pMac, i );
671 pSession->roamingTimerInfo.pMac = pMac;
672 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
673 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700674 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
675 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530676 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
677 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700678 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530679 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800681 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700682 break;
683 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530684 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
685 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
686 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700687 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800688 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700689 return eHAL_STATUS_FAILURE;
690 }
691 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 return (status);
693}
694
Jeff Johnson295189b2012-06-20 16:38:30 -0700695eHalStatus csrRoamClose(tpAniSirGlobal pMac)
696{
697 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
699 {
700 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
701 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530702 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
703 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
704 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
705 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700706 return (eHAL_STATUS_SUCCESS);
707}
708
Jeff Johnson295189b2012-06-20 16:38:30 -0700709eHalStatus csrRoamStart(tpAniSirGlobal pMac)
710{
711 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700712 return (eHAL_STATUS_SUCCESS);
713}
714
Jeff Johnson295189b2012-06-20 16:38:30 -0700715void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
716{
717 csrRoamStopRoamingTimer(pMac, sessionId);
718 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
719 csrRoamDeregStatisticsReq(pMac);
720}
Jeff Johnson295189b2012-06-20 16:38:30 -0700721eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
722{
723 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800724 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700725 {
726 status = eHAL_STATUS_SUCCESS;
727 *pState = pMac->roam.roamSession[sessionId].connectState;
728 }
729 return (status);
730}
731
Jeff Johnson295189b2012-06-20 16:38:30 -0700732eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
733{
734 eHalStatus status = eHAL_STATUS_FAILURE;
735 tANI_U32 size = 0;
736 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700737
738 if(!pSession)
739 {
740 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
741 return eHAL_STATUS_FAILURE;
742 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700743
744 if(pProfile)
745 {
746 if(pSession->pConnectBssDesc)
747 {
748 do
749 {
750 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
751 if(size)
752 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530753 pProfile->pBssDesc = vos_mem_malloc(size);
754 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700755 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530756 vos_mem_copy(pProfile->pBssDesc,
757 pSession->pConnectBssDesc, size);
758 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 }
760 else
761 break;
762 }
763 else
764 {
765 pProfile->pBssDesc = NULL;
766 }
767 pProfile->AuthType = pSession->connectedProfile.AuthType;
768 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
769 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
770 pProfile->BSSType = pSession->connectedProfile.BSSType;
771 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
772 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530773 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
774 sizeof(tCsrBssid));
775 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
776 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700777#ifdef WLAN_FEATURE_VOWIFI_11R
778 if (pSession->connectedProfile.MDID.mdiePresent)
779 {
780 pProfile->MDID.mdiePresent = 1;
781 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
782 }
783 else
784 {
785 pProfile->MDID.mdiePresent = 0;
786 pProfile->MDID.mobilityDomain = 0;
787 }
788#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700789#ifdef FEATURE_WLAN_CCX
790 pProfile->isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700791 if (csrIsAuthTypeCCX(pSession->connectedProfile.AuthType))
792 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530793 vos_mem_copy (pProfile->ccxCckmInfo.krk,
794 pSession->connectedProfile.ccxCckmInfo.krk,
795 CSR_KRK_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 pProfile->ccxCckmInfo.reassoc_req_num=
797 pSession->connectedProfile.ccxCckmInfo.reassoc_req_num;
798 pProfile->ccxCckmInfo.krk_plumbed =
799 pSession->connectedProfile.ccxCckmInfo.krk_plumbed;
800 }
801#endif
802 }while(0);
803 }
804 }
805
806 return (status);
807}
808
Jeff Johnson295189b2012-06-20 16:38:30 -0700809eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
810{
811 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700812
813 if((csrIsConnStateConnected(pMac, sessionId)) ||
814 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700815 {
816 if(pProfile)
817 {
818 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
819 }
820 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 return (status);
822}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700823
Jeff Johnson295189b2012-06-20 16:38:30 -0700824eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
825{
826 eHalStatus status = eHAL_STATUS_SUCCESS;
827
Kiet Lam64c1b492013-07-12 13:56:44 +0530828 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700829 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530830 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700831 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530832 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700833 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530834 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700835 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530836 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
837
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
839 return (status);
840}
841
Jeff Johnson295189b2012-06-20 16:38:30 -0700842static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
843{
844 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700845 if( pConnectedInfo->pbFrames )
846 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530847 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 pConnectedInfo->pbFrames = NULL;
849 }
850 pConnectedInfo->nBeaconLength = 0;
851 pConnectedInfo->nAssocReqLength = 0;
852 pConnectedInfo->nAssocRspLength = 0;
853 pConnectedInfo->staId = 0;
854#ifdef WLAN_FEATURE_VOWIFI_11R
855 pConnectedInfo->nRICRspLength = 0;
856#endif
857#ifdef FEATURE_WLAN_CCX
858 pConnectedInfo->nTspecIeLength = 0;
859#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 return ( status );
861}
862
Jeff Johnson295189b2012-06-20 16:38:30 -0700863
864
Jeff Johnsone7245742012-09-05 17:12:55 -0700865
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700866void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
867{
868 csrReinitPreauthCmd(pMac, pCommand);
869 csrReleaseCommand( pMac, pCommand );
870}
871
Jeff Johnson295189b2012-06-20 16:38:30 -0700872void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
873{
874 csrReinitRoamCmd(pMac, pCommand);
875 csrReleaseCommand( pMac, pCommand );
876}
877
Jeff Johnson295189b2012-06-20 16:38:30 -0700878void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
879{
880 csrReinitScanCmd(pMac, pCommand);
881 csrReleaseCommand( pMac, pCommand );
882}
883
Jeff Johnson295189b2012-06-20 16:38:30 -0700884void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
885{
886 csrReinitWmStatusChangeCmd(pMac, pCommand);
887 csrReleaseCommand( pMac, pCommand );
888}
889
Jeff Johnson295189b2012-06-20 16:38:30 -0700890void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
891{
Kiet Lam64c1b492013-07-12 13:56:44 +0530892 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700893}
894
Jeff Johnson295189b2012-06-20 16:38:30 -0700895void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
896{
Kiet Lam64c1b492013-07-12 13:56:44 +0530897 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700898}
899
Jeff Johnson295189b2012-06-20 16:38:30 -0700900void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
901{
902 csrReinitSetKeyCmd(pMac, pCommand);
903 csrReleaseCommand( pMac, pCommand );
904}
Jeff Johnson295189b2012-06-20 16:38:30 -0700905void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
906{
907 csrReinitRemoveKeyCmd(pMac, pCommand);
908 csrReleaseCommand( pMac, pCommand );
909}
Jeff Johnson295189b2012-06-20 16:38:30 -0700910void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
911{
912
913 if( eSmeCsrCommandMask & pCommand->command )
914 {
915 switch (pCommand->command)
916 {
917 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800918 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -0800919 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
920 __func__, pCommand->u.scanCmd.reason,
921 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700922 if (NULL != pCommand->u.scanCmd.callback)
923 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800924 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700925 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
926 }
927 csrReleaseCommandScan( pMac, pCommand );
928 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700929 case eSmeCommandRoam:
930 csrReleaseCommandRoam( pMac, pCommand );
931 break;
932
933 case eSmeCommandWmStatusChange:
934 csrReleaseCommandWmStatusChange( pMac, pCommand );
935 break;
936
937 case eSmeCommandSetKey:
938 csrReleaseCommandSetKey( pMac, pCommand );
939 break;
940
941 case eSmeCommandRemoveKey:
942 csrReleaseCommandRemoveKey( pMac, pCommand );
943 break;
944
945 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800946 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 csrReleaseCommand( pMac, pCommand );
948 break;
949 }
950 }
951}
952
Jeff Johnson295189b2012-06-20 16:38:30 -0700953void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
954{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800955 smsLog( pMac, LOG1, " CSR RoamSubstate: [ %d <== %d ]", NewSubstate, pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700956
Jeff Johnson295189b2012-06-20 16:38:30 -0700957 if(pMac->roam.curSubState[sessionId] == NewSubstate)
958 {
959 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700960 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 pMac->roam.curSubState[sessionId] = NewSubstate;
962}
963
Jeff Johnson295189b2012-06-20 16:38:30 -0700964eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
965{
966 eCsrRoamState PreviousState;
967
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +0530968 smsLog( pMac, LOG1, "CSR RoamState[%hu]: [ %d <== %d ]", sessionId,
969 NewRoamState, pMac->roam.curState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700970
971 PreviousState = pMac->roam.curState[sessionId];
972
973 if ( NewRoamState != pMac->roam.curState[sessionId] )
974 {
975 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
976 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
977 {
978 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
979 }
980
981 pMac->roam.curState[sessionId] = NewRoamState;
982 }
983 return( PreviousState );
984}
985
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -0700986void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -0700987{
988 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700989 if(catOffset)
990 {
991 pMac->roam.configParam.bCatRssiOffset = catOffset;
992 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
993 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -0700994 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 -0700995 }
996 }
997}
998
Jeff Johnson295189b2012-06-20 16:38:30 -0700999static void initConfigParam(tpAniSirGlobal pMac)
1000{
1001 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001002 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301003 pMac->roam.configParam.channelBondingMode24GHz =
1004 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1005 pMac->roam.configParam.channelBondingMode5GHz =
1006 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1008 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1009 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1010 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1011 pMac->roam.configParam.HeartbeatThresh24 = 40;
1012 pMac->roam.configParam.HeartbeatThresh50 = 40;
1013 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1014 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1015 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001016 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001017 pMac->roam.configParam.RTSThreshold = 2346;
1018 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1019 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1020 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1021 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1022 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1023 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1024 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1025 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1026 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1027 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1028 {
1029 pMac->roam.configParam.BssPreferValue[i] = i;
1030 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001031 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1033 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1034 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001035 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1036 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
1037 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1038 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1039 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1040 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001041 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1042 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001043 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001044#ifdef WLAN_AP_STA_CONCURRENCY
1045 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1046 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1047 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1048 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1049 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001050 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1051 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001052#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001053 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1054 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1055 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1056 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001057#ifdef WLAN_FEATURE_VOWIFI_11R
1058 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1059#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001060#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1061 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1062 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1063 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1064 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1065 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1066 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1067 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1068 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1069 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1070 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1071 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001072 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001073#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001074#ifdef WLAN_FEATURE_11AC
1075 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1076#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001077
1078 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1079 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001080
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001081 //Remove this code once SLM_Sessionization is supported
1082 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001083 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001084
Jeff Johnsone7245742012-09-05 17:12:55 -07001085}
Jeff Johnson295189b2012-06-20 16:38:30 -07001086eCsrBand csrGetCurrentBand(tHalHandle hHal)
1087{
1088 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1089 return pMac->roam.configParam.bandCapability;
1090}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001091
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001092
1093#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
1094/*
1095 This function flushes the roam scan cache
1096*/
1097eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1098{
1099 eHalStatus status = eHAL_STATUS_SUCCESS;
1100 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1101
1102 /* Free up the memory first (if required) */
1103 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1104 {
1105 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1106 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1107 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1108 }
1109 return status;
1110}
1111#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
1112
1113
Srinivas Girigowdade697412013-02-14 16:31:48 -08001114#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001115/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001116 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001117*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001118eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001119{
1120 eHalStatus status = eHAL_STATUS_SUCCESS;
1121 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1122
1123 /* Free up the memory first (if required) */
1124 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1125 {
1126 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1127 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001128 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001129 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001130 return status;
1131}
1132
1133
1134
1135/*
1136 This function flushes the roam scan cache and creates fresh cache
1137 based on the input channel list
1138*/
1139eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1140 const tANI_U8 *pChannelList,
1141 const tANI_U8 numChannels)
1142{
1143 eHalStatus status = eHAL_STATUS_SUCCESS;
1144 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1145
Srinivas Girigowdade697412013-02-14 16:31:48 -08001146 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1147
1148 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1149 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1150
1151 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1152 {
1153 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1154 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1155 return eHAL_STATUS_RESOURCES;
1156 }
1157
1158 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301159 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1160 pChannelList,
1161 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001162 return status;
1163}
1164
1165/* This function modifies the bgscan channel list set via config ini or
1166 runtime, whenever the band changes.
1167 if the band is auto, then no operation is performed on the channel list
1168 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1169 if the band is 5G, then make sure channel list contains only 5G valid channels
1170*/
1171eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1172 eCsrBand eBand)
1173{
1174 eHalStatus status = eHAL_STATUS_SUCCESS;
1175 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1176 tANI_U8 outNumChannels = 0;
1177 tANI_U8 inNumChannels = 0;
1178 tANI_U8 *inPtr = NULL;
1179 tANI_U8 i = 0;
1180 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1181
1182 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1183
1184 {
1185 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1186 "No update required for channel list "
1187 "either cfg.ini channel list is not set up or "
1188 "auto band (Band %d)", eBand);
1189 return status;
1190 }
1191
1192 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1193 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1194 if (eCSR_BAND_24 == eBand)
1195 {
1196 for (i = 0; i < inNumChannels; i++)
1197 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001198 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001199 {
1200 ChannelList[outNumChannels++] = inPtr[i];
1201 }
1202 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001203 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001204 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001205 }
1206 else if (eCSR_BAND_5G == eBand)
1207 {
1208 for (i = 0; i < inNumChannels; i++)
1209 {
1210 /* Add 5G Non-DFS channel */
1211 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001212 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001213 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1214 {
1215 ChannelList[outNumChannels++] = inPtr[i];
1216 }
1217 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001218 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001219 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001220 }
1221 else if (eCSR_BAND_ALL == eBand)
1222 {
1223 for (i = 0; i < inNumChannels; i++)
1224 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001225 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001226 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1227 {
1228 ChannelList[outNumChannels++] = inPtr[i];
1229 }
1230 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001231 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001232 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001233 }
1234 else
1235 {
1236 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1237 "Invalid band, No operation carried out (Band %d)", eBand);
1238 status = eHAL_STATUS_INVALID_PARAMETER;
1239 }
1240
1241 return status;
1242}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001243#endif
1244
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001245#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
1246/* This function modifies the roam scan channel list as per AP neighbor
1247 report; AP neighbor report may be empty or may include only other AP
1248 channels; in any case, we merge the channel list with the learned occupied
1249 channels list.
1250 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1251 if the band is 5G, then make sure channel list contains only 5G valid channels
1252*/
1253eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1254 tANI_U8 *pChannelList,
1255 tANI_U8 numChannels,
1256 const eCsrBand eBand)
1257{
1258 eHalStatus status = eHAL_STATUS_SUCCESS;
1259 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1260 tANI_U8 outNumChannels = 0;
1261 tANI_U8 inNumChannels = numChannels;
1262 tANI_U8 *inPtr = pChannelList;
1263 tANI_U8 i = 0;
1264 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1265 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1266 tANI_U8 mergedOutputNumOfChannels = 0;
1267 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1268
1269 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1270 * report Channels. This increases the chances of the DUT to get a candidate AP while
1271 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1272 if (pMac->scan.occupiedChannels.numChannels)
1273 {
1274 csrNeighborRoamMergeChannelLists(pMac,
1275 &pMac->scan.occupiedChannels.channelList[0],
1276 pMac->scan.occupiedChannels.numChannels,
1277 inPtr,
1278 inNumChannels,
1279 &mergedOutputNumOfChannels);
1280 inNumChannels = mergedOutputNumOfChannels;
1281 }
1282
1283 if (eCSR_BAND_24 == eBand)
1284 {
1285 for (i = 0; i < inNumChannels; i++)
1286 {
1287 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1288 {
1289 ChannelList[outNumChannels++] = inPtr[i];
1290 }
1291 }
1292 }
1293 else if (eCSR_BAND_5G == eBand)
1294 {
1295 for (i = 0; i < inNumChannels; i++)
1296 {
1297 /* Add 5G Non-DFS channel */
1298 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1299 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1300 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1301 {
1302 ChannelList[outNumChannels++] = inPtr[i];
1303 }
1304 }
1305 }
1306 else if (eCSR_BAND_ALL == eBand)
1307 {
1308 for (i = 0; i < inNumChannels; i++)
1309 {
1310 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1311 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1312 {
1313 ChannelList[outNumChannels++] = inPtr[i];
1314 }
1315 }
1316 }
1317 else
1318 {
1319 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1320 "Invalid band, No operation carried out (Band %d)", eBand);
1321 return eHAL_STATUS_INVALID_PARAMETER;
1322 }
1323
1324 /* if roaming within band is enabled, then select only the
1325 in band channels .
1326 This is required only if the band capability is set to ALL,
1327 E.g., if band capability is only 2.4G then all the channels in the
1328 list are already filtered for 2.4G channels, hence ignore this check*/
1329
1330 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1331 {
1332 csrNeighborRoamChannelsFilterByCurrentBand(
1333 pMac,
1334 ChannelList,
1335 outNumChannels,
1336 tmpChannelList,
1337 &outNumChannels);
Kiet Lamf2f201e2013-11-16 21:24:16 +05301338 vos_mem_copy(ChannelList,
1339 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001340 }
1341
1342 /* Prepare final roam scan channel list */
1343 if(outNumChannels)
1344 {
1345 /* Clear the channel list first */
1346 if (NULL != currChannelListInfo->ChannelList)
1347 {
1348 vos_mem_free(currChannelListInfo->ChannelList);
1349 currChannelListInfo->ChannelList = NULL;
1350 currChannelListInfo->numOfChannels = 0;
1351 }
1352
1353 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1354 if (NULL == currChannelListInfo->ChannelList)
1355 {
1356 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1357 "Failed to allocate memory for roam scan channel list");
1358 currChannelListInfo->numOfChannels = 0;
1359 return VOS_STATUS_E_RESOURCES;
1360 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301361 vos_mem_copy(currChannelListInfo->ChannelList,
1362 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001363 }
1364 return status;
1365}
1366#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
1367
Jeff Johnson295189b2012-06-20 16:38:30 -07001368eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1369{
1370 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1371 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1373 (eBand == eCSR_BAND_24))
1374 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001375 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001376 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001377 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001378 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001379 pMac->roam.configParam.uCfgDot11Mode, eBand);
1380 return eHAL_STATUS_INVALID_PARAMETER;
1381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001382 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1383 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1384 (eBand == eCSR_BAND_5G))
1385 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001386 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001387 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001388 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001389 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 pMac->roam.configParam.uCfgDot11Mode, eBand);
1391 return eHAL_STATUS_INVALID_PARAMETER;
1392 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001393 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001394 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001395 pMac->roam.configParam.eBand = eBand;
1396 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001397 csrScanGetSupportedChannels( pMac );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001398#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001399 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1400 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001401#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001402 status = csrInitGetChannels( pMac );
1403 if (eHAL_STATUS_SUCCESS == status)
1404 csrInitChannelList( hHal );
1405 return status;
1406}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001407
1408
Jeff Johnsone7245742012-09-05 17:12:55 -07001409/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1410 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1411 * Ideally we should have kept the ini value and enum value same and representing the same
1412 * cb values as in 11n standard i.e.
1413 * Set to 1 (SCA) if the secondary channel is above the primary channel
1414 * Set to 3 (SCB) if the secondary channel is below the primary channel
1415 * Set to 0 (SCN) if no secondary channel is present
1416 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1417 * 0 - secondary none
1418 * 1 - secondary LOW
1419 * 2 - secondary HIGH
1420 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1421 * The enum values are as follows:
1422 * PHY_SINGLE_CHANNEL_CENTERED = 0
1423 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1424 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1425 */
1426ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1427{
1428
1429 ePhyChanBondState phyCbState;
1430 switch (cbIniValue) {
1431 // secondary none
1432 case 0:
1433 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1434 break;
1435 // secondary LOW
1436 case 1:
1437 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1438 break;
1439 // secondary HIGH
1440 case 2:
1441 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1442 break;
1443#ifdef WLAN_FEATURE_11AC
1444 case 3:
1445 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1446 break;
1447 case 4:
1448 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1449 break;
1450 case 5:
1451 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1452 break;
1453 case 6:
1454 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1455 break;
1456 case 7:
1457 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1458 break;
1459 case 8:
1460 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1461 break;
1462 case 9:
1463 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1464 break;
1465#endif
1466 default:
1467 // If an invalid value is passed, disable CHANNEL BONDING
1468 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1469 break;
1470 }
1471 return phyCbState;
1472}
1473
1474v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1475{
1476
1477 v_U32_t cbIniValue;
1478 switch (phyCbState) {
1479 // secondary none
1480 case PHY_SINGLE_CHANNEL_CENTERED:
1481 cbIniValue = 0;
1482 break;
1483 // secondary LOW
1484 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1485 cbIniValue = 1;
1486 break;
1487 // secondary HIGH
1488 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1489 cbIniValue = 2;
1490 break;
1491#ifdef WLAN_FEATURE_11AC
1492 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1493 cbIniValue = 3;
1494 break;
1495 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1496 cbIniValue = 4;
1497 break;
1498 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1499 cbIniValue = 5;
1500 break;
1501 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1502 cbIniValue = 6;
1503 break;
1504 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1505 cbIniValue = 7;
1506 break;
1507 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1508 cbIniValue = 8;
1509 break;
1510 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1511 cbIniValue = 9;
1512 break;
1513#endif
1514 default:
1515 // return some invalid value
1516 cbIniValue = 10;
1517 break;
1518 }
1519 return cbIniValue;
1520}
Jeff Johnson295189b2012-06-20 16:38:30 -07001521
1522eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1523{
1524 eHalStatus status = eHAL_STATUS_SUCCESS;
1525
1526 if(pParam)
1527 {
1528 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1529 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1530 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1531 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1532 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1533 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1534
1535 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001536 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1537
Jeff Johnsone7245742012-09-05 17:12:55 -07001538 /* channelBondingMode5GHz plays a dual role right now
1539 * 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
1540 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1541 */
1542 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1543 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001544 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001545 }
1546 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1547 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1548 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001549 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001550 }
1551 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001552 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1553 pMac->roam.configParam.phyMode = pParam->phyMode;
1554 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1555 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1556 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1557 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1558 pMac->roam.configParam.TxRate = pParam->TxRate;
1559 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1560 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1561 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1562 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1563 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001564 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 //if HDD passed down non zero values then only update,
1566 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001567 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 {
1569 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1570 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001571 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001572 {
1573 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1574 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001575 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 {
1577 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1578 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001579 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001580 {
1581 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1582 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001583 if (pParam->nActiveMaxChnTimeBtc)
1584 {
1585 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1586 }
1587 if (pParam->nActiveMinChnTimeBtc)
1588 {
1589 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1590 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001591#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001592 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001593 {
1594 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1595 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001596 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001597 {
1598 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1599 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001600 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001601 {
1602 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1603 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001604 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001605 {
1606 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1607 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001608 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001609 {
1610 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1611 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001612 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001613 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001614 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1615 }
1616 if (pParam->nNumP2PChanCombinedConc)
1617 {
1618 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001619 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001620#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001622 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 {
1624 //Change the unit from second to microsecond
1625 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1627 {
1628 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1629 }
1630 else
1631 {
1632 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1633 }
1634 }
1635 else
1636 {
1637 pMac->roam.configParam.impsSleepTime = 0;
1638 }
1639 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001640 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1641 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001642 //if HDD passed down non zero values for age params, then only update,
1643 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001644 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001645 {
1646 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 if(pParam->scanAgeTimeNCNPS)
1649 {
1650 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1651 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001652 if(pParam->scanAgeTimeNCPS)
1653 {
1654 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 if(pParam->scanAgeTimeCNPS)
1657 {
1658 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1659 }
1660 if(pParam->scanAgeTimeCPS)
1661 {
1662 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1663 }
1664
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001665 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1667 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1668 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1669 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1670 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1672 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1674 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1675 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1676 //Assign this before calling CsrInit11dInfo
1677 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 if( csrIs11dSupported( pMac ) )
1679 {
1680 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1681 }
1682 else
1683 {
1684 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1685 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001686
1687 /* Initialize the power + channel information if 11h is enabled.
1688 If 11d is enabled this information has already been initialized */
1689 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1690 {
1691 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1692 }
1693
1694
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301695#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301696 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1697 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001698 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001699#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001700#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001701 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001702 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001703 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001704 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001705 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001706 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001707 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001708 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001709 pMac->roam.configParam.nProbes = pParam->nProbes;
1710 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001711#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001712#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1713 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001714 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001715#endif
1716#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001717 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001718 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001719#endif
1720
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301721#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1723#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001724#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301725 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1726 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001727 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1728 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1729 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1730 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1731 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1732 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1733 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1734 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001735 {
1736 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001737 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 -07001738 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1739 {
1740 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1741 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 }
1743#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001744 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1745 pMac->scan.fValidateList = pParam->fValidateList;
1746 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1747 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001748 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001749 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001750 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1751 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1752 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1753 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1754 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1755 * single session
1756 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001757 //Remove this code once SLM_Sessionization is supported
1758 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001759 pMac->roam.configParam.doBMPSWorkaround = 0;
1760
Jeff Johnsone7245742012-09-05 17:12:55 -07001761#ifdef WLAN_FEATURE_11AC
1762 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001763 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001764 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001765 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001766#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001767 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001768
1769 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001770 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001771 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1772 pParam->isCoalesingInIBSSAllowed;
Jeff Johnson295189b2012-06-20 16:38:30 -07001773 }
1774
1775 return status;
1776}
1777
Jeff Johnson295189b2012-06-20 16:38:30 -07001778eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1779{
1780 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001781 if(pParam)
1782 {
1783 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1784 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1785 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1786 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1787 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1788 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001789 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1790 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001791 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1792 pParam->phyMode = pMac->roam.configParam.phyMode;
1793 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1794 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1795 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1796 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1797 pParam->TxRate = pMac->roam.configParam.TxRate;
1798 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1799 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1800 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1801 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1802 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1804 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1805 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1806 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001807 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1808 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1809 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001810#ifdef WLAN_AP_STA_CONCURRENCY
1811 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1812 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1813 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1814 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1815 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001816 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1817 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001818#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001819 //Change the unit from microsecond to second
1820 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1821 pParam->eBand = pMac->roam.configParam.eBand;
1822 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1823 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1824 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1825 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1826 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1827 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1828 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1829 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1830 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1831 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1832 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1833 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1834 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1836 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1837 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1838 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1840 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1841 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1842 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1843 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001844 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001845 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001846 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001847 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001848
1849#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301850 vos_mem_copy(&pParam->neighborRoamConfig,
1851 &pMac->roam.configParam.neighborRoamConfig,
1852 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001853#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001854#ifdef WLAN_FEATURE_11AC
1855 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001856 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001857 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001858 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001859#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001860#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301861 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1862 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001863#endif
1864#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1865 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1866 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1867 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1868 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1869 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001870 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001871 pParam->nProbes = pMac->roam.configParam.nProbes;
1872 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001873#endif
1874#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1875 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1876 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1877#endif
1878#ifdef FEATURE_WLAN_LFR
1879 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1880#endif
1881
1882#ifdef FEATURE_WLAN_CCX
1883 pParam->isCcxIniFeatureEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
1884#endif
1885#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301886 vos_mem_copy(&pParam->neighborRoamConfig,
1887 &pMac->roam.configParam.neighborRoamConfig,
1888 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001889 {
1890 int i;
1891 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1892 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1893 {
1894 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1895 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001896 }
1897#endif
1898
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001899 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001900
krunal soni5afa96c2013-09-06 22:19:02 -07001901 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001902 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07001903
krunal sonie9002db2013-11-25 14:24:17 -08001904 pParam->isCoalesingInIBSSAllowed =
1905 pMac->roam.configParam.isCoalesingInIBSSAllowed;
1906
Jeff Johnson295189b2012-06-20 16:38:30 -07001907 csrSetChannels(pMac, pParam);
1908
1909 status = eHAL_STATUS_SUCCESS;
1910 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001911 return (status);
1912}
1913
Jeff Johnson295189b2012-06-20 16:38:30 -07001914eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1915{
1916 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1917 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1918 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1919 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 do
1921 {
1922 if(eCSR_BAND_24 == eBand)
1923 {
1924 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1925 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1926 }
1927 if(eCSR_BAND_5G == eBand)
1928 {
1929 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1930 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1931 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1932 )
1933 {
1934 break;
1935 }
1936 }
1937 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1938 {
1939 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1940 }
1941 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1942 {
1943 newPhyMode = eCSR_DOT11_MODE_AUTO;
1944 }
1945 else
1946 {
1947 //Check for dual band and higher capability first
1948 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1949 {
1950 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1951 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1952 }
1953 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1954 {
1955 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1956 if(eCSR_BAND_24 == eBand) break;
1957 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1958 eBand = eCSR_BAND_5G;
1959 }
1960 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1961 {
1962 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1963 if(eCSR_BAND_5G == eBand) break;
1964 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1965 eBand = eCSR_BAND_24;
1966 }
1967 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1968 {
1969 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1970 if(eCSR_BAND_5G == eBand) break;
1971 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1972 eBand = eCSR_BAND_24;
1973 }
1974 else if(eCSR_DOT11_MODE_11n & phyMode)
1975 {
1976 newPhyMode = eCSR_DOT11_MODE_11n;
1977 }
1978 else if(eCSR_DOT11_MODE_abg & phyMode)
1979 {
1980 newPhyMode = eCSR_DOT11_MODE_abg;
1981 }
1982 else if(eCSR_DOT11_MODE_11a & phyMode)
1983 {
1984 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1985 {
1986 if(eCSR_BAND_ALL == eBand)
1987 {
1988 newPhyMode = eCSR_DOT11_MODE_abg;
1989 }
1990 else
1991 {
1992 //bad setting
1993 break;
1994 }
1995 }
1996 else
1997 {
1998 newPhyMode = eCSR_DOT11_MODE_11a;
1999 eBand = eCSR_BAND_5G;
2000 }
2001 }
2002 else if(eCSR_DOT11_MODE_11g & phyMode)
2003 {
2004 newPhyMode = eCSR_DOT11_MODE_11g;
2005 eBand = eCSR_BAND_24;
2006 }
2007 else if(eCSR_DOT11_MODE_11b & phyMode)
2008 {
2009 newPhyMode = eCSR_DOT11_MODE_11b;
2010 eBand = eCSR_BAND_24;
2011 }
2012 else
2013 {
2014 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002015 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002016 newPhyMode = eCSR_DOT11_MODE_AUTO;
2017 }
2018 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002019 //Done validating
2020 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 //Now we need to check whether a restart is needed.
2022 if(eBand != pMac->roam.configParam.eBand)
2023 {
2024 fRestartNeeded = eANI_BOOLEAN_TRUE;
2025 break;
2026 }
2027 if(newPhyMode != pMac->roam.configParam.phyMode)
2028 {
2029 fRestartNeeded = eANI_BOOLEAN_TRUE;
2030 break;
2031 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002032 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002033 if(HAL_STATUS_SUCCESS(status))
2034 {
2035 pMac->roam.configParam.eBand = eBand;
2036 pMac->roam.configParam.phyMode = newPhyMode;
2037 if(pfRestartNeeded)
2038 {
2039 *pfRestartNeeded = fRestartNeeded;
2040 }
2041 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002042 return (status);
2043}
2044
Jeff Johnson295189b2012-06-20 16:38:30 -07002045void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2046{
2047 tANI_U8 Index;
2048 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 // for dual band NICs, don't need to trim the channel list....
2050 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2051 {
2052 // 2.4 GHz band operation requires the channel list to be trimmed to
2053 // the 2.4 GHz channels only...
2054 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2055 {
2056 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2057 Index++ )
2058 {
2059 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2060 {
2061 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2062 cChannels++;
2063 }
2064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2066 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2067 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2068 // only if we need to.
2069 //
2070 // The amount of memory to clear is the number of channesl that we trimmed
2071 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2072
2073 if ( pChannelList->numChannels > cChannels )
2074 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302075 vos_mem_set(&pChannelList->channelList[ cChannels ],
2076 sizeof( pChannelList->channelList[ 0 ] ) *
2077 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 }
2079
2080 pChannelList->numChannels = cChannels;
2081 }
2082 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2083 {
2084 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2085 {
2086 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2087 {
2088 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2089 cChannels++;
2090 }
2091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2093 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2094 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2095 // only if we need to.
2096 //
2097 // The amount of memory to clear is the number of channesl that we trimmed
2098 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2099 if ( pChannelList->numChannels > cChannels )
2100 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302101 vos_mem_set(&pChannelList->channelList[ cChannels ],
2102 sizeof( pChannelList->channelList[ 0 ] ) *
2103 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 }
2105
2106 pChannelList->numChannels = cChannels;
2107 }
2108 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002109}
Jeff Johnson295189b2012-06-20 16:38:30 -07002110#define INFRA_AP_DEFAULT_CHANNEL 6
2111eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2112{
2113 tANI_U8 index= 0;
2114 eHalStatus status = eHAL_STATUS_FAILURE;
2115 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2116 {
2117 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2118 status = eHAL_STATUS_SUCCESS;
2119 break;
2120 }
2121 }
2122 return status;
2123}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002124
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002125
Jeff Johnson295189b2012-06-20 16:38:30 -07002126eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2127{
2128 eHalStatus status = eHAL_STATUS_SUCCESS;
2129 tANI_U8 num20MHzChannelsFound = 0;
2130 VOS_STATUS vosStatus;
2131 tANI_U8 Index = 0;
2132 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002133
Jeff Johnson295189b2012-06-20 16:38:30 -07002134
2135 //TODO: this interface changed to include the 40MHz channel list
2136 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2137 // Read the scan channel list (including the power limit) from EEPROM
2138 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2139 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2140 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2141 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002142 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002143 status = eHAL_STATUS_FAILURE;
2144 }
2145 else
2146 {
2147 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2148 {
2149 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2150 }
2151 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2152 // Move the channel list to the global data
2153 // structure -- this will be used as the scan list
2154 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2155 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002157 }
2158 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2159 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2160 {
2161 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2162 }
2163 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2164 {
2165 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2166 }
2167 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2168 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 return (status);
2170}
2171
Jeff Johnson295189b2012-06-20 16:38:30 -07002172eHalStatus csrInitChannelList( tHalHandle hHal )
2173{
2174 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2175 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2177 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002178 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2179 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002180 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002181 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002182
2183 return (status);
2184}
Jeff Johnson295189b2012-06-20 16:38:30 -07002185eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2186 tCsrUpdateConfigParam *pUpdateConfigParam)
2187{
2188 eHalStatus status = eHAL_STATUS_FAILURE;
2189 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2191 status = CsrInit11dInfo(pMac, ps11dinfo);
2192 return status;
2193}
2194
Jeff Johnson295189b2012-06-20 16:38:30 -07002195static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2196{
2197 eHalStatus status = eHAL_STATUS_FAILURE;
2198 tANI_U8 index;
2199 tANI_U32 count=0;
2200 tSirMacChanInfo *pChanInfo;
2201 tSirMacChanInfo *pChanInfoStart;
2202 tANI_BOOLEAN applyConfig = TRUE;
2203
Mihir Shetebc866f62014-02-13 16:08:53 +05302204 pMac->scan.currentCountryRSSI = -128;
2205
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 if(!ps11dinfo)
2207 {
2208 return (status);
2209 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2211 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302212 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2213 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2214 ps11dinfo->Channels.channelList,
2215 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002216 }
2217 else
2218 {
2219 //No change
2220 return (eHAL_STATUS_SUCCESS);
2221 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002222 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302223
2224 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2225 WNI_CFG_COUNTRY_CODE_LEN);
2226
2227
Jeff Johnson295189b2012-06-20 16:38:30 -07002228 //Tush: at csropen get this initialized with default, during csr reset if this
2229 // already set with some value no need initilaize with default again
2230 if(0 == pMac->scan.countryCodeCurrent[0])
2231 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302232 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2233 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302236 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2237 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302239 vos_mem_set(pChanInfo,
2240 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2241 0);
2242
Jeff Johnson295189b2012-06-20 16:38:30 -07002243 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002244 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2245 {
2246 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2247 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2248 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2249 pChanInfo++;
2250 count++;
2251 }
2252 if(count)
2253 {
2254 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2255 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302256 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002257 }
2258 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2259 if( HAL_STATUS_SUCCESS(status) )
2260 {
2261 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2262 {
2263 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2264 {
2265 applyConfig = FALSE;
2266 }
2267 }
2268
2269 if(TRUE == applyConfig)
2270 {
2271 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002272 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002273 }
2274
2275 }
2276 return (status);
2277}
2278/* Initialize the Channel + Power List in the local cache and in the CFG */
2279eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2280{
2281 tANI_U8 index;
2282 tANI_U32 count=0;
2283 tSirMacChanInfo *pChanInfo;
2284 tSirMacChanInfo *pChanInfoStart;
2285
2286 if(!ps11dinfo || !pMac)
2287 {
2288 return eHAL_STATUS_FAILURE;
2289 }
2290
Kiet Lam64c1b492013-07-12 13:56:44 +05302291 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2292 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002293 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302294 vos_mem_set(pChanInfo,
2295 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2296 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002297 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002298
2299 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2300 {
2301 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2302 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2303 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2304 pChanInfo++;
2305 count++;
2306 }
2307 if(count)
2308 {
2309 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2310 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302311 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 }
2313
Jeff Johnsone7245742012-09-05 17:12:55 -07002314 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002315}
2316
2317//pCommand may be NULL
2318//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2319void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2320{
2321 tListElem *pEntry, *pNextEntry;
2322 tSmeCmd *pDupCommand;
2323 tDblLinkList localList;
2324
2325 vos_mem_zero(&localList, sizeof(tDblLinkList));
2326 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2327 {
2328 smsLog(pMac, LOGE, FL(" failed to open list"));
2329 return;
2330 }
2331 csrLLLock( &pMac->sme.smeCmdPendingList );
2332 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2333 while( pEntry )
2334 {
2335 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2336 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 // Remove the previous command if..
2338 // - the new roam command is for the same RoamReason...
2339 // - the new roam command is a NewProfileList.
2340 // - the new roam command is a Forced Dissoc
2341 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2342 if (
2343 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2344 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002345 /* This peermac check is requried for Softap/GO scenarios
2346 * For STA scenario below OR check will suffice as pCommand will
2347 * always be NULL for STA scenarios
2348 */
2349 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2351 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2352 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2353 ||
2354 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002355 ( (sessionId == pDupCommand->sessionId) &&
2356 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002357 ((eCsrForcedDisassoc == eRoamReason) ||
2358 (eCsrHddIssued == eRoamReason))
2359 )
2360 )
2361 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002362 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002363 // Remove the 'stale' roam command from the pending list...
2364 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2365 {
2366 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2367 }
2368 }
2369 pEntry = pNextEntry;
2370 }
2371 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2372
2373 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2374 {
2375 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2376 //Tell caller that the command is cancelled
2377 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2378 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2379 csrReleaseCommandRoam(pMac, pDupCommand);
2380 }
2381 csrLLClose(&localList);
2382}
Jeff Johnson295189b2012-06-20 16:38:30 -07002383eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2384 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2385{
2386 eHalStatus status = eHAL_STATUS_SUCCESS;
2387#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2388 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2389#endif
2390 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002391 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2392 {
2393 pSession = CSR_GET_SESSION( pMac, sessionId );
2394 }
2395 else
2396 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002397 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002398 VOS_ASSERT(0);
2399 return eHAL_STATUS_FAILURE;
2400 }
krunal soni587bf012014-02-04 12:35:11 -08002401
2402 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2403 {
2404 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2405 return eHAL_STATUS_FAILURE;
2406 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002407
krunal soni587bf012014-02-04 12:35:11 -08002408 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2409
krunal soni7f7d2c92014-02-06 15:08:43 -08002410 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002412 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002413 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002414 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2415 /*
2416 * Decrement bRefAssocStartCnt for FT reassoc failure.
2417 * Reason: For FT reassoc failures, we first call
2418 * csrRoamCallCallback before notifying a failed roam
2419 * completion through csrRoamComplete. The latter in
2420 * turn calls csrRoamProcessResults which tries to
2421 * once again call csrRoamCallCallback if bRefAssocStartCnt
2422 * is non-zero. Since this is redundant for FT reassoc
2423 * failure, decrement bRefAssocStartCnt.
2424 */
2425 pSession->bRefAssocStartCnt--;
2426 }
2427
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 if(NULL != pSession->callback)
2429 {
2430 if( pRoamInfo )
2431 {
2432 pRoamInfo->sessionId = (tANI_U8)sessionId;
2433 }
2434
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302435 /* avoid holding the global lock when making the roaming callback, original change came
2436 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2437 is possible on other OS ports where the callback may need to take locks to protect
2438 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2440 that may actually depend on the lock being held */
2441 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2442 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2443 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2444 }
2445 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2446 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2447#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302448 vos_mem_set(&connectionStatus,
2449 sizeof(vos_event_wlan_status_payload_type), 0);
2450
krunal soni7f7d2c92014-02-06 15:08:43 -08002451 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 {
2453 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2454 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2455 if(NULL != pRoamInfo->pBssDesc)
2456 {
2457 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2458 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2461 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2462 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302463 vos_mem_copy(connectionStatus.ssid,
2464 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2465
Jeff Johnson295189b2012-06-20 16:38:30 -07002466 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2467 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2468 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002469 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2470 {
2471 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2472 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2473 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002475 if(eCSR_ROAM_RESULT_FORCED == u2)
2476 {
2477 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2478 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2479 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002481 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2482 {
2483 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2484 connectionStatus.reason = eCSR_REASON_DISASSOC;
2485 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2488 {
2489 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2490 connectionStatus.reason = eCSR_REASON_DEAUTH;
2491 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002493#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2494
2495 return (status);
2496}
Jeff Johnson295189b2012-06-20 16:38:30 -07002497// Returns whether handoff is currently in progress or not
2498tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2499{
2500#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2501 return csrNeighborRoamIsHandoffInProgress(pMac);
2502#else
2503 return eANI_BOOLEAN_FALSE;
2504#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002505}
Jeff Johnson295189b2012-06-20 16:38:30 -07002506eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2507 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2508{
2509 eHalStatus status = eHAL_STATUS_SUCCESS;
2510 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2511 tANI_U16 reasonCode;
2512 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002513
2514 if(!pSession)
2515 {
2516 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2517 return eHAL_STATUS_FAILURE;
2518 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002519
2520 //Restore AC weight in case we change it
2521 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2522 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002523 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 -07002524 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2525 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2526 }
2527
2528 if ( fMICFailure )
2529 {
2530 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2531 }
2532 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2533 {
2534 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002535 }
2536 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002537 {
2538 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002540#ifdef WLAN_FEATURE_VOWIFI_11R
2541 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2542 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2543 {
2544 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302545 vos_mem_copy(&bssId,
2546 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2547 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002548 }
2549 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002550#endif
2551 if(pSession->pConnectBssDesc)
2552 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302553 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002554 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002555
Jeff Johnson295189b2012-06-20 16:38:30 -07002556
Arif Hussain24bafea2013-11-15 15:10:03 -08002557 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2558 " subState = %d reason=%d",
2559 MAC_ADDR_ARRAY(bssId), NewSubstate, reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002560
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2562
2563 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2564
2565 if(HAL_STATUS_SUCCESS(status))
2566 {
2567 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002568#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2569 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2570 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2571 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002572 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002573 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2574 }
2575#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002576 }
2577 else
2578 {
2579 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2580 }
2581
Jeff Johnson295189b2012-06-20 16:38:30 -07002582 return (status);
2583}
Jeff Johnson295189b2012-06-20 16:38:30 -07002584
Jeff Johnson295189b2012-06-20 16:38:30 -07002585/* ---------------------------------------------------------------------------
2586 \fn csrRoamIssueDisassociateStaCmd
2587 \brief csr function that HDD calls to disassociate a associated station
2588 \param sessionId - session Id for Soft AP
2589 \param pPeerMacAddr - MAC of associated station to delete
2590 \param reason - reason code, be one of the tSirMacReasonCodes
2591 \return eHalStatus
2592 ---------------------------------------------------------------------------*/
2593eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2594 tANI_U32 sessionId,
2595 tANI_U8 *pPeerMacAddr,
2596 tANI_U32 reason)
2597{
2598 eHalStatus status = eHAL_STATUS_SUCCESS;
2599 tSmeCmd *pCommand;
2600
2601 do
2602 {
2603 pCommand = csrGetCommandBuffer( pMac );
2604 if ( !pCommand )
2605 {
2606 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2607 status = eHAL_STATUS_RESOURCES;
2608 break;
2609 }
2610 pCommand->command = eSmeCommandRoam;
2611 pCommand->sessionId = (tANI_U8)sessionId;
2612 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2613 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2614 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2615 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2616 if( !HAL_STATUS_SUCCESS( status ) )
2617 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002618 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 csrReleaseCommandRoam( pMac, pCommand );
2620 }
2621 }while(0);
2622
2623 return status;
2624}
2625
2626
Jeff Johnson295189b2012-06-20 16:38:30 -07002627/* ---------------------------------------------------------------------------
2628 \fn csrRoamIssueDeauthSta
2629 \brief csr function that HDD calls to delete a associated station
2630 \param sessionId - session Id for Soft AP
2631 \param pPeerMacAddr - MAC of associated station to delete
2632 \param reason - reason code, be one of the tSirMacReasonCodes
2633 \return eHalStatus
2634 ---------------------------------------------------------------------------*/
2635eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2636 tANI_U32 sessionId,
2637 tANI_U8 *pPeerMacAddr,
2638 tANI_U32 reason)
2639{
2640 eHalStatus status = eHAL_STATUS_SUCCESS;
2641 tSmeCmd *pCommand;
2642
2643 do
2644 {
2645 pCommand = csrGetCommandBuffer( pMac );
2646 if ( !pCommand )
2647 {
2648 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2649 status = eHAL_STATUS_RESOURCES;
2650 break;
2651 }
2652 pCommand->command = eSmeCommandRoam;
2653 pCommand->sessionId = (tANI_U8)sessionId;
2654 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2655 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2656 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2657 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2658 if( !HAL_STATUS_SUCCESS( status ) )
2659 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002660 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 csrReleaseCommandRoam( pMac, pCommand );
2662 }
2663 }while(0);
2664
2665 return status;
2666}
Jeff Johnson295189b2012-06-20 16:38:30 -07002667eHalStatus
2668csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2669 tANI_BOOLEAN bEnable )
2670{
2671 eHalStatus status = eHAL_STATUS_FAILURE;
2672 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2673 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 if (!pSession)
2675 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002676 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002677 return (status);
2678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 if (pSession->pConnectBssDesc)
2680 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302681 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002682 }
2683 else
2684 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002685 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 return (status);
2687 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002688 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2689 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002690 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2691 return (status);
2692}
Jeff Johnson295189b2012-06-20 16:38:30 -07002693eHalStatus
2694csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2695 VOS_MODULE_ID modId, void *pUsrContext,
2696 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2697{
2698 eHalStatus status = eHAL_STATUS_SUCCESS;
2699 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2700 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 if (!pSession)
2702 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002703 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 return (status);
2705 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002706 if(pSession->pConnectBssDesc)
2707 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302708 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002709 }
2710 else
2711 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002712 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 return (status);
2714 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002715 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2716 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002717 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2718 return (status);
2719}
Jeff Johnson295189b2012-06-20 16:38:30 -07002720eHalStatus
2721csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2722 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2723{
2724 eHalStatus status = eHAL_STATUS_SUCCESS;
2725 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2726 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2727
2728 if (!pSession)
2729 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002730 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002731 return (status);
2732 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 if(pSession->pConnectBssDesc)
2734 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302735 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 }
2737 else
2738 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002739 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 return (status);
2741 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002742 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2743 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002744
2745 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2746
2747 return (status);
2748}
Jeff Johnson295189b2012-06-20 16:38:30 -07002749eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2750{
2751 eHalStatus status = eHAL_STATUS_SUCCESS;
2752 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2753 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002754
2755 if (!pSession)
2756 {
2757 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2758 return eHAL_STATUS_FAILURE;
2759 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002760
2761 if(pSession->pConnectBssDesc)
2762 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302763 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002764 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002765 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2766 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2768
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302769 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002770 if(!HAL_STATUS_SUCCESS(status))
2771 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302772 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2773 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002774 }
2775
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 return (status);
2777}
2778
Jeff Johnson295189b2012-06-20 16:38:30 -07002779eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2780{
2781 eHalStatus status = eHAL_STATUS_SUCCESS;
2782 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2783 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002784
2785 if(!pSession)
2786 {
2787 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2788 return eHAL_STATUS_FAILURE;
2789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002790
2791 // If no BSS description was found in this connection (happens with start IBSS), then
2792 // nix the BSS description that we keep around for the connected BSS) and get out...
2793 if(NULL == pBssDesc)
2794 {
2795 csrFreeConnectBssDesc(pMac, sessionId);
2796 }
2797 else
2798 {
2799 size = pBssDesc->length + sizeof( pBssDesc->length );
2800 if(NULL != pSession->pConnectBssDesc)
2801 {
2802 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2803 {
2804 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2805 csrFreeConnectBssDesc(pMac, sessionId);
2806 }
2807 }
2808 if(NULL == pSession->pConnectBssDesc)
2809 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302810 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302812 if (NULL == pSession->pConnectBssDesc)
2813 status = eHAL_STATUS_FAILURE;
2814 else
2815 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2816 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 return (status);
2818}
2819
Jeff Johnson295189b2012-06-20 16:38:30 -07002820eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2821 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2822 tDot11fBeaconIEs *pIes)
2823{
2824 eHalStatus status = eHAL_STATUS_SUCCESS;
2825 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302827 if (pIes == NULL)
2828 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002829
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 do
2831 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302832 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2833 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002834 //get qos
2835 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2836 //get SSID
2837 if(pIes->SSID.present)
2838 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302839 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2841 }
2842 else
2843 pBssConfig->SSID.length = 0;
2844 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2845 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002846 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 //Return failed if profile doesn't have an SSID either.
2848 if(pProfile->SSIDs.numOfSSIDs == 0)
2849 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002850 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 status = eHAL_STATUS_FAILURE;
2852 break;
2853 }
2854 }
2855 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2856 {
2857 pBssConfig->eBand = eCSR_BAND_5G;
2858 }
2859 else
2860 {
2861 pBssConfig->eBand = eCSR_BAND_24;
2862 }
2863 //phymode
2864 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2865 {
2866 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2867 }
2868 else
2869 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002870 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 //force it
2872 if(eCSR_BAND_24 == pBssConfig->eBand)
2873 {
2874 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2875 }
2876 else
2877 {
2878 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2879 }
2880 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002881 //Qos
2882 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2883 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2884 {
2885 //Joining BSS is not 11n capable and WMM is disabled on client.
2886 //Disable QoS and WMM
2887 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2888 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302889
2890 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302891 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302892 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2893 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2894 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2895 {
2896 //Joining BSS is 11n capable and WMM is disabled on AP.
2897 //Assume all HT AP's are QOS AP's and enable WMM
2898 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2899 }
2900
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 //auth type
2902 switch( pProfile->negotiatedAuthType )
2903 {
2904 default:
2905 case eCSR_AUTH_TYPE_WPA:
2906 case eCSR_AUTH_TYPE_WPA_PSK:
2907 case eCSR_AUTH_TYPE_WPA_NONE:
2908 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2909 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2910 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 case eCSR_AUTH_TYPE_SHARED_KEY:
2912 pBssConfig->authType = eSIR_SHARED_KEY;
2913 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 case eCSR_AUTH_TYPE_AUTOSWITCH:
2915 pBssConfig->authType = eSIR_AUTO_SWITCH;
2916 break;
2917 }
2918 //short slot time
2919 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2920 {
2921 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2922 }
2923 else
2924 {
2925 pBssConfig->uShortSlotTime = 0;
2926 }
2927 if(pBssConfig->BssCap.ibss)
2928 {
2929 //We don't support 11h on IBSS
2930 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2931 }
2932 else
2933 {
2934 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2935 }
2936 //power constraint
2937 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2938 //heartbeat
2939 if ( CSR_IS_11A_BSS( pBssDesc ) )
2940 {
2941 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2942 }
2943 else
2944 {
2945 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2946 }
2947 //Join timeout
2948 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002949 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 if ( pBssDesc->beaconInterval )
2951 {
2952 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002953 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002954 }
2955 else
2956 {
2957 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2958 }
2959 //validate CB
2960 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sandeep Puligilla60342762014-01-30 21:05:37 +05302961
Jeff Johnson295189b2012-06-20 16:38:30 -07002962 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002963 return (status);
2964}
2965
Jeff Johnson295189b2012-06-20 16:38:30 -07002966static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2967 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2968{
2969 eHalStatus status = eHAL_STATUS_SUCCESS;
2970 tANI_U8 operationChannel = 0;
2971 tANI_U8 qAPisEnabled = FALSE;
2972 //SSID
2973 pBssConfig->SSID.length = 0;
2974 if(pProfile->SSIDs.numOfSSIDs)
2975 {
2976 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05302977 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
2978 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002979 }
2980 else
2981 {
2982 //SSID must present
2983 return eHAL_STATUS_FAILURE;
2984 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002985 //Settomg up the capabilities
2986 if( csrIsBssTypeIBSS(pProfile->BSSType) )
2987 {
2988 pBssConfig->BssCap.ibss = 1;
2989 }
2990 else
2991 {
2992 pBssConfig->BssCap.ess = 1;
2993 }
2994 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
2995 {
2996 pBssConfig->BssCap.privacy = 1;
2997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 pBssConfig->eBand = pMac->roam.configParam.eBand;
2999 //phymode
3000 if(pProfile->ChannelInfo.ChannelList)
3001 {
3002 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003004 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3005 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 //QOS
3007 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 if ( pBssConfig->BssCap.ess == 1 )
3009 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003010 /*For Softap case enable WMM*/
3011 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3012 qAPisEnabled = TRUE;
3013 }
3014 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003015 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3016 qAPisEnabled = TRUE;
3017 } else {
3018 qAPisEnabled = FALSE;
3019 }
3020 } else {
3021 qAPisEnabled = TRUE;
3022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3024 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3025 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3026 )
3027 {
3028 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3029 } else {
3030 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3031 }
3032
3033 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003034 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 {
3036 default:
3037 case eCSR_AUTH_TYPE_WPA:
3038 case eCSR_AUTH_TYPE_WPA_PSK:
3039 case eCSR_AUTH_TYPE_WPA_NONE:
3040 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3041 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3042 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 case eCSR_AUTH_TYPE_SHARED_KEY:
3044 pBssConfig->authType = eSIR_SHARED_KEY;
3045 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003046 case eCSR_AUTH_TYPE_AUTOSWITCH:
3047 pBssConfig->authType = eSIR_AUTO_SWITCH;
3048 break;
3049 }
3050 //short slot time
3051 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3052 {
3053 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3054 }
3055 else
3056 {
3057 pBssConfig->uShortSlotTime = 0;
3058 }
3059 //power constraint. We don't support 11h on IBSS
3060 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3061 pBssConfig->uPowerLimit = 0;
3062 //heartbeat
3063 if ( eCSR_BAND_5G == pBssConfig->eBand )
3064 {
3065 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3066 }
3067 else
3068 {
3069 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3070 }
3071 //Join timeout
3072 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003073
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 return (status);
3075}
Jeff Johnson295189b2012-06-20 16:38:30 -07003076static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3077{
3078 eHalStatus status = eHAL_STATUS_FAILURE;
3079 tDot11fBeaconIEs *pIes = NULL;
3080
3081 do
3082 {
3083 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3084 {
3085 //err msg
3086 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003087 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 break;
3089 }
3090 //check if the AP is QAP & it supports APSD
3091 if( CSR_IS_QOS_BSS(pIes) )
3092 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303093 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003094 }
3095 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303096
3097 if (NULL != pIes)
3098 {
3099 vos_mem_free(pIes);
3100 }
3101
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 return status;
3103}
3104
Jeff Johnson295189b2012-06-20 16:38:30 -07003105void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3106{
Jeff Johnson295189b2012-06-20 16:38:30 -07003107 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3108 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3109 // See !!Note: below in this function...
3110 tANI_U32 PrivacyEnabled = 0;
3111 tANI_U32 RsnEnabled = 0;
3112 tANI_U32 WepDefaultKeyId = 0;
3113 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3114 tANI_U32 Key0Length = 0;
3115 tANI_U32 Key1Length = 0;
3116 tANI_U32 Key2Length = 0;
3117 tANI_U32 Key3Length = 0;
3118
3119 // Reserve for the biggest key
3120 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3121 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3122 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3123 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3124
3125 switch ( pProfile->negotiatedUCEncryptionType )
3126 {
3127 case eCSR_ENCRYPT_TYPE_NONE:
3128
3129 // for NO encryption, turn off Privacy and Rsn.
3130 PrivacyEnabled = 0;
3131 RsnEnabled = 0;
3132
3133 // WEP key length and Wep Default Key ID don't matter in this case....
3134
3135 // clear out the WEP keys that may be hanging around.
3136 Key0Length = 0;
3137 Key1Length = 0;
3138 Key2Length = 0;
3139 Key3Length = 0;
3140
3141 break;
3142
3143 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303144 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003145
3146 // Privacy is ON. NO RSN for Wep40 static key.
3147 PrivacyEnabled = 1;
3148 RsnEnabled = 0;
3149
3150 // Set the Wep default key ID.
3151 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 // Wep key size if 5 bytes (40 bits).
3153 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3154
3155 // set encryption keys in the CFG database or clear those that are not present in this profile.
3156 if ( pProfile->Keys.KeyLength[0] )
3157 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303158 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3159 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3161 }
3162 else
3163 {
3164 Key0Length = 0;
3165 }
3166
3167 if ( pProfile->Keys.KeyLength[1] )
3168 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303169 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3170 WNI_CFG_WEP_KEY_LENGTH_5);
3171 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003172 }
3173 else
3174 {
3175 Key1Length = 0;
3176 }
3177
3178 if ( pProfile->Keys.KeyLength[2] )
3179 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303180 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3181 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3183 }
3184 else
3185 {
3186 Key2Length = 0;
3187 }
3188
3189 if ( pProfile->Keys.KeyLength[3] )
3190 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303191 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3192 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3194 }
3195 else
3196 {
3197 Key3Length = 0;
3198 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003199 break;
3200
3201 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303202 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003203
3204 // Privacy is ON. NO RSN for Wep40 static key.
3205 PrivacyEnabled = 1;
3206 RsnEnabled = 0;
3207
3208 // Set the Wep default key ID.
3209 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3210
3211 // Wep key size if 13 bytes (104 bits).
3212 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3213
3214 // set encryption keys in the CFG database or clear those that are not present in this profile.
3215 if ( pProfile->Keys.KeyLength[0] )
3216 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303217 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3218 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3220 }
3221 else
3222 {
3223 Key0Length = 0;
3224 }
3225
3226 if ( pProfile->Keys.KeyLength[1] )
3227 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303228 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3229 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3231 }
3232 else
3233 {
3234 Key1Length = 0;
3235 }
3236
3237 if ( pProfile->Keys.KeyLength[2] )
3238 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303239 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3240 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003241 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3242 }
3243 else
3244 {
3245 Key2Length = 0;
3246 }
3247
3248 if ( pProfile->Keys.KeyLength[3] )
3249 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303250 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3251 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3253 }
3254 else
3255 {
3256 Key3Length = 0;
3257 }
3258
3259 break;
3260
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 case eCSR_ENCRYPT_TYPE_TKIP:
3262 case eCSR_ENCRYPT_TYPE_AES:
3263#ifdef FEATURE_WLAN_WAPI
3264 case eCSR_ENCRYPT_TYPE_WPI:
3265#endif /* FEATURE_WLAN_WAPI */
3266 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3267 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3268 PrivacyEnabled = (0 != fPrivacy);
3269
3270 // turn on RSN enabled for WPA associations
3271 RsnEnabled = 1;
3272
3273 // WEP key length and Wep Default Key ID don't matter in this case....
3274
3275 // clear out the static WEP keys that may be hanging around.
3276 Key0Length = 0;
3277 Key1Length = 0;
3278 Key2Length = 0;
3279 Key3Length = 0;
3280
3281 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 default:
3283 PrivacyEnabled = 0;
3284 RsnEnabled = 0;
3285 break;
3286 }
3287
3288 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3289 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3290 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3291 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3292 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3293 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3294 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3295 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3296}
3297
Jeff Johnson295189b2012-06-20 16:38:30 -07003298static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3299{
3300 tANI_U32 len = 0;
3301 if(pSSID->length <= WNI_CFG_SSID_LEN)
3302 {
3303 len = pSSID->length;
3304 }
3305 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3306}
3307
Jeff Johnson295189b2012-06-20 16:38:30 -07003308eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3309{
3310 eHalStatus status = eHAL_STATUS_SUCCESS;
3311 tANI_U32 QoSEnabled;
3312 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003313 // set the CFG enable/disable variables based on the qosType being configured...
3314 switch( qosType )
3315 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3317 QoSEnabled = FALSE;
3318 WmeEnabled = TRUE;
3319 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003320 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3321 QoSEnabled = FALSE;
3322 WmeEnabled = TRUE;
3323 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3325 QoSEnabled = FALSE;
3326 WmeEnabled = TRUE;
3327 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3329 QoSEnabled = TRUE;
3330 WmeEnabled = FALSE;
3331 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003332 case eCSR_MEDIUM_ACCESS_11e_HCF:
3333 QoSEnabled = TRUE;
3334 WmeEnabled = FALSE;
3335 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003336 default:
3337 case eCSR_MEDIUM_ACCESS_DCF:
3338 QoSEnabled = FALSE;
3339 WmeEnabled = FALSE;
3340 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 }
3342 //save the WMM setting for later use
3343 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303344 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 return (status);
3346}
Jeff Johnson295189b2012-06-20 16:38:30 -07003347static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3348 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3349{
3350 eHalStatus status = eHAL_STATUS_FAILURE;
3351 int i;
3352 eCsrCfgDot11Mode cfgDot11Mode;
3353 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303354 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3355 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003356 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003357
3358 if( NULL != pIes )
3359 {
3360 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003361 // Originally, we thought that for 11a networks, the 11a rates are always
3362 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3363 // appear in the Operational Rate set. Consequently, in either case, we
3364 // would blindly put the rates we support into our Operational Rate set
3365 // (including the basic rates, which we have already verified are
3366 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 // However, it turns out that this is not always the case. Some AP's
3368 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3369 // too. Now, we're a little more careful:
3370 pDstRate = pOpRateSet->rate;
3371 if(pIes->SuppRates.present)
3372 {
3373 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3374 {
3375 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3376 {
3377 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003378 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 }
3380 }
3381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003382 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3383 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3384 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3385 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3386 {
3387 // If there are Extended Rates in the beacon, we will reflect those
3388 // extended rates that we support in out Extended Operational Rate
3389 // set:
3390 pDstRate = pExRateSet->rate;
3391 if(pIes->ExtSuppRates.present)
3392 {
3393 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3394 {
3395 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3396 {
3397 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3398 pExRateSet->numRates++;
3399 }
3400 }
3401 }
3402 }
3403 }//Parsing BSSDesc
3404 else
3405 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003406 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003407 }
3408 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3409 return status;
3410}
3411
3412static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3413 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3414{
3415 int i;
3416 tANI_U8 *pDstRate;
3417 eCsrCfgDot11Mode cfgDot11Mode;
3418 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3419 tANI_U32 OperationalRatesLength = 0;
3420 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3421 tANI_U32 ExtendedOperationalRatesLength = 0;
3422 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3423 tANI_U32 ProprietaryOperationalRatesLength = 0;
3424 tANI_U32 PropRatesEnable = 0;
3425 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3426 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003427 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 if( NULL != pIes )
3429 {
3430 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003431 // Originally, we thought that for 11a networks, the 11a rates are always
3432 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3433 // appear in the Operational Rate set. Consequently, in either case, we
3434 // would blindly put the rates we support into our Operational Rate set
3435 // (including the basic rates, which we have already verified are
3436 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003437 // However, it turns out that this is not always the case. Some AP's
3438 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3439 // too. Now, we're a little more careful:
3440 pDstRate = OperationalRates;
3441 if(pIes->SuppRates.present)
3442 {
3443 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3444 {
3445 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3446 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3447 {
3448 *pDstRate++ = pIes->SuppRates.rates[ i ];
3449 OperationalRatesLength++;
3450 }
3451 }
3452 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003453 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3454 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3455 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3456 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3457 {
3458 // If there are Extended Rates in the beacon, we will reflect those
3459 // extended rates that we support in out Extended Operational Rate
3460 // set:
3461 pDstRate = ExtendedOperationalRates;
3462 if(pIes->ExtSuppRates.present)
3463 {
3464 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3465 {
3466 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3467 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3468 {
3469 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3470 ExtendedOperationalRatesLength++;
3471 }
3472 }
3473 }
3474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 // Enable proprietary MAC features if peer node is Airgo node and STA
3476 // user wants to use them
3477 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3478 {
3479 PropRatesEnable = 1;
3480 }
3481 else
3482 {
3483 PropRatesEnable = 0;
3484 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 // For ANI network companions, we need to populate the proprietary rate
3486 // set with any proprietary rates we found in the beacon, only if user
3487 // allows them...
3488 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3489 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3490 {
3491 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3492 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3493 {
3494 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3495 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303496 vos_mem_copy(ProprietaryOperationalRates,
3497 pIes->Airgo.PropSuppRates.rates,
3498 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 }
3500 else {
3501 // No proprietary modes...
3502 ProprietaryOperationalRatesLength = 0;
3503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 /* Get MCS Rate */
3505 pDstRate = MCSRateIdxSet;
3506 if ( pIes->HTCaps.present )
3507 {
3508 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3509 {
3510 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3511 {
3512 MCSRateLength++;
3513 *pDstRate++ = i;
3514 }
3515 }
3516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003517 // Set the operational rate set CFG variables...
3518 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3519 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3520 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3521 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3522 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3523 ProprietaryOperationalRates,
3524 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3525 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3526 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3527 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3528 }//Parsing BSSDesc
3529 else
3530 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003531 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 }
3533}
3534
Jeff Johnson295189b2012-06-20 16:38:30 -07003535static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3536 tCsrRoamProfile *pProfile )
3537{
3538 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3539 { 8,
3540 { SIR_MAC_RATE_6,
3541 SIR_MAC_RATE_9,
3542 SIR_MAC_RATE_12,
3543 SIR_MAC_RATE_18,
3544 SIR_MAC_RATE_24,
3545 SIR_MAC_RATE_36,
3546 SIR_MAC_RATE_48,
3547 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3549 { 4,
3550 { SIR_MAC_RATE_1,
3551 SIR_MAC_RATE_2,
3552 SIR_MAC_RATE_5_5,
3553 SIR_MAC_RATE_11 } } };
3554
3555
3556 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3557 { SIR_MAC_RATE_72,
3558 SIR_MAC_RATE_96,
3559 SIR_MAC_RATE_108 } };
3560 eCsrCfgDot11Mode cfgDot11Mode;
3561 eCsrBand eBand;
3562 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3563 tANI_U32 OperationalRatesLength = 0;
3564 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3565 tANI_U32 ExtendedOperationalRatesLength = 0;
3566 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3567 tANI_U32 ProprietaryOperationalRatesLength = 0;
3568 tANI_U32 PropRatesEnable = 0;
3569 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003570 if(pProfile->ChannelInfo.ChannelList)
3571 {
3572 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003574 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003575 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3576 // networks, the 11b rates appear in the Operational Rate set. In either case,
3577 // we can blindly put the rates we support into our Operational Rate set
3578 // (including the basic rates, which we have already verified are supported
3579 // earlier in the roaming decision).
3580 if ( eCSR_BAND_5G == eBand )
3581 {
3582 // 11a rates into the Operational Rate Set.
3583 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3584 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303585 vos_mem_copy(OperationalRates,
3586 DefaultSupportedRates11a.supportedRateSet.rate,
3587 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003588
3589 // Nothing in the Extended rate set.
3590 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003591 // populate proprietary rates if user allows them
3592 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3593 {
3594 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3595 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303596 vos_mem_copy(ProprietaryOperationalRates,
3597 DefaultSupportedPropRates.propRate,
3598 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 }
3600 else
3601 {
3602 // No proprietary modes
3603 ProprietaryOperationalRatesLength = 0;
3604 }
3605 }
3606 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3607 {
3608 // 11b rates into the Operational Rate Set.
3609 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3610 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303611 vos_mem_copy(OperationalRates,
3612 DefaultSupportedRates11b.supportedRateSet.rate,
3613 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 // Nothing in the Extended rate set.
3615 ExtendedOperationalRatesLength = 0;
3616 // No proprietary modes
3617 ProprietaryOperationalRatesLength = 0;
3618 }
3619 else
3620 {
3621 // 11G
3622
3623 // 11b rates into the Operational Rate Set.
3624 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3625 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303626 vos_mem_copy(OperationalRates,
3627 DefaultSupportedRates11b.supportedRateSet.rate,
3628 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003629
3630 // 11a rates go in the Extended rate set.
3631 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3632 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303633 vos_mem_copy(ExtendedOperationalRates,
3634 DefaultSupportedRates11a.supportedRateSet.rate,
3635 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003636
3637 // populate proprietary rates if user allows them
3638 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3639 {
3640 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3641 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303642 vos_mem_copy(ProprietaryOperationalRates,
3643 DefaultSupportedPropRates.propRate,
3644 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 }
3646 else
3647 {
3648 // No proprietary modes
3649 ProprietaryOperationalRatesLength = 0;
3650 }
3651 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003652 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3653 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3654 {
3655 PropRatesEnable = 1;
3656 }
3657 else
3658 {
3659 PropRatesEnable = 0;
3660 }
3661
3662 // Set the operational rate set CFG variables...
3663 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3664 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3665 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3666 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3667 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3668 ProprietaryOperationalRates,
3669 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3670 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003671}
Jeff Johnson295189b2012-06-20 16:38:30 -07003672void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3673{
3674 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003675
Jeff Johnson295189b2012-06-20 16:38:30 -07003676 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3677 tANI_U32 sessionId;
3678 tSmeCmd *pCommand = NULL;
3679
3680 if(NULL == pEntry)
3681 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003682 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 return;
3684 }
3685 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3686 sessionId = pCommand->sessionId;
3687
3688 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3689 {
3690 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3691 }
3692}
3693
Jeff Johnson295189b2012-06-20 16:38:30 -07003694//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3695tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3696{
3697 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3698 {
3699 return (WNI_CFG_PHY_MODE_11B);
3700 }
3701 else
3702 {
3703 if(eCSR_BAND_24 == band)
3704 return (WNI_CFG_PHY_MODE_11G);
3705 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 return (WNI_CFG_PHY_MODE_11A);
3707}
Jeff Johnson295189b2012-06-20 16:38:30 -07003708
Jeff Johnsone7245742012-09-05 17:12:55 -07003709
3710#ifdef WLAN_FEATURE_11AC
3711ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3712{
3713 switch ( aniCBMode )
3714 {
3715 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3716 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3717 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3718 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3719 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3720 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3721 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3722 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3723 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003724 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003725 return PHY_SINGLE_CHANNEL_CENTERED;
3726 }
3727}
3728#endif
3729
Jeff Johnson295189b2012-06-20 16:38:30 -07003730//pIes may be NULL
3731eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3732 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303733 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003734{
3735 eHalStatus status = eHAL_STATUS_SUCCESS;
3736 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3737 tANI_U8 channel = 0;
3738 //Make sure we have the domain info for the BSS we try to connect to.
3739 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303740 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303742 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 {
3744 //Make sure the 11d info from this BSSDesc can be applied
3745 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303746 if (VOS_TRUE == resetCountry)
3747 {
3748 csrApplyCountryInformation(pMac, FALSE);
3749 }
3750 else
3751 {
3752 csrApplyCountryInformation(pMac, TRUE);
3753 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003754 }
Kiran4a17ebe2013-01-31 10:43:43 -08003755 if ((csrIs11dSupported (pMac)) && pIes)
3756 {
3757 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003758 {
Kiran4a17ebe2013-01-31 10:43:43 -08003759 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003760 }
3761 else
3762 {
3763 //Let's also update the below to make sure we don't update CC while
3764 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303765 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003766 pBssDesc->bssId, sizeof(tSirMacAddr));
3767 }
Kiran4a17ebe2013-01-31 10:43:43 -08003768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 //Qos
3771 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3772 //SSID
3773 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3774 //fragment threshold
3775 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3776 //RTS threshold
3777 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3778
3779 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003780 //Auth type
3781 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3782 //encryption type
3783 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3784 //short slot time
3785 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003786 //11d
3787 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3788 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3789 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 /*//11h
3791 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3792 */
3793 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3794 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003795
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003796 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003797 {
3798 channel = pProfile->operationChannel;
3799 }
3800 else
3801 {
3802 if(pBssDesc)
3803 {
3804 channel = pBssDesc->channelId;
3805 }
3806 }
3807 if(0 != channel)
3808 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05303809 if(CSR_IS_CHANNEL_24GHZ(channel) &&
3810 !pMac->roam.configParam.channelBondingMode24GHz &&
3811 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
3812 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05303814 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
3815 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
3816 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07003817 }
3818 else
3819 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003820 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 }
3822 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003823#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003824 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3825 // in function csrConvertCBIniValueToPhyCBState()
3826 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3827 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003828 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003829 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003830 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003831 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05303832 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003833 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003834 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003835 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003836 }
3837 else
3838#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003839 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3840 //Rate
3841 //Fixed Rate
3842 if(pBssDesc)
3843 {
3844 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3845 }
3846 else
3847 {
3848 csrSetCfgRateSetFromProfile(pMac, pProfile);
3849 }
3850 //Make this the last CFG to set. The callback will trigger a join_req
3851 //Join time out
3852 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3853
3854 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 return (status);
3856}
3857
Jeff Johnson295189b2012-06-20 16:38:30 -07003858eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3859 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3860{
3861 eHalStatus status;
3862 tBssConfigParam *pBssConfig;
3863 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003864
3865 if(!pSession)
3866 {
3867 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3868 return eHAL_STATUS_FAILURE;
3869 }
3870
Kiet Lam64c1b492013-07-12 13:56:44 +05303871 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
3872 if ( NULL == pBssConfig )
3873 status = eHAL_STATUS_FAILURE;
3874 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303876 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3878 if(HAL_STATUS_SUCCESS(status))
3879 {
3880 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003881 /* This will allow to pass cbMode during join req */
3882 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003883 //For IBSS, we need to prepare some more information
3884 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 )
3887 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003888 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003889 }
3890 // If we are in an IBSS, then stop the IBSS...
3891 ////Not worry about WDS connection for now
3892 if ( csrIsConnStateIbss( pMac, sessionId ) )
3893 {
3894 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3895 }
3896 else
3897 {
3898 // if we are in an Infrastructure association....
3899 if ( csrIsConnStateInfra( pMac, sessionId ) )
3900 {
3901 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3902 // across SSIDs (roaming to a new SSID)... //
3903 //Not worry about WDS connection for now
3904 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303905 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 {
3907 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303908 status = csrRoamIssueDisassociate( pMac, sessionId,
3909 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003910 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303911 else
3912 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3914 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303915 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303917 // Set parameters for this Bss.
3918 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3919 pBssDesc, pBssConfig,
3920 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303922 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303924 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003925 {
3926 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3927 // Nothing to stop.
3928 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303930 )
3931 {
3932 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3933 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3934 // Set parameters for this Bss.
3935 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3936 pBssDesc, pBssConfig,
3937 pIes, is11rRoamingFlag);
3938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003939 }
3940 }
3941 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05303942 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07003943 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 return (status);
3945}
3946
Jeff Johnson295189b2012-06-20 16:38:30 -07003947eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3948 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3949{
3950 eCsrJoinState eRoamState = eCsrContinueRoaming;
3951 eHalStatus status;
3952 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3953 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3954 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003955
3956 if(!pSession)
3957 {
3958 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3959 return (eCsrStopRoaming);
3960 }
3961
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 if( CSR_IS_WDS_STA( pProfile ) )
3963 {
3964 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3965 if( !HAL_STATUS_SUCCESS( status ) )
3966 {
3967 eRoamState = eCsrStopRoaming;
3968 }
3969 }
3970 else
3971 {
3972 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3973 {
3974 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
3975 return (eCsrStopRoaming);
3976 }
3977 if ( csrIsInfraBssDesc( pBssDesc ) )
3978 {
3979 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
3980 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
3981 // have changed and handle the changes (without disturbing the current association).
3982
3983 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
3984 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
3985 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
3986 )
3987 {
3988 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
3989 // with Authenticating first. To force this, stop the current association (Disassociate) and
3990 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
3991 // a new Association.
3992 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
3993 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07003994 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003995 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
3996 {
3997 eRoamState = eCsrReassocToSelfNoCapChange;
3998 }
3999 else
4000 {
4001 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304003 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4005 if(HAL_STATUS_SUCCESS(status))
4006 {
4007 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004008 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304010 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4011 pBssDesc, &bssConfig,
4012 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 if(!HAL_STATUS_SUCCESS(status))
4014 {
4015 eRoamState = eCsrStopRoaming;
4016 }
4017 }
4018 else
4019 {
4020 eRoamState = eCsrStopRoaming;
4021 }
4022 }//same profile
4023 }
4024 else
4025 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304026 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4028 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304029 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4030 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004031 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304032 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304034 }
4035 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004036 {
4037 // 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 +05304038 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 // work much better.
4040 //
4041 //
4042 // stop the existing network before attempting to join the new network...
4043 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4044 {
4045 eRoamState = eCsrStopRoaming;
4046 }
4047 }
4048 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304049 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 {
4051 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4052 {
4053 eRoamState = eCsrStopRoaming;
4054 }
4055 }
4056 if( pIesLocal && !pScanResult->pvIes )
4057 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304058 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 }
4060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004061 return( eRoamState );
4062}
4063
Jeff Johnson295189b2012-06-20 16:38:30 -07004064eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4065 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4066{
4067 eHalStatus status = eHAL_STATUS_SUCCESS;
4068 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304069 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 roamInfo.pBssDesc = pBssDesc;
4071 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4072 return (status);
4073}
Jeff Johnson295189b2012-06-20 16:38:30 -07004074//In case no matching BSS is found, use whatever default we can find
4075static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4076{
4077 //Need to get all negotiated types in place first
4078 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004079 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 {
4081 default:
4082 case eCSR_AUTH_TYPE_WPA:
4083 case eCSR_AUTH_TYPE_WPA_PSK:
4084 case eCSR_AUTH_TYPE_WPA_NONE:
4085 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4086 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4087 break;
4088
4089 case eCSR_AUTH_TYPE_SHARED_KEY:
4090 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4091 break;
4092
4093 case eCSR_AUTH_TYPE_AUTOSWITCH:
4094 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4095 break;
4096 }
4097 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4098 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4099 //In this case, the multicast encryption needs to follow the uncast ones.
4100 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4101 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4102}
4103
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004104
4105static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4106{
4107 switch(pCommand->u.roamCmd.roamReason)
4108 {
4109 case eCsrLostLink1:
4110 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4111 break;
4112 case eCsrLostLink2:
4113 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4114 break;
4115 case eCsrLostLink3:
4116 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4117 break;
4118 default:
4119 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4120 pCommand->u.roamCmd.roamReason);
4121 break;
4122 }
4123}
4124
Jeff Johnson295189b2012-06-20 16:38:30 -07004125static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4126{
4127 eHalStatus status;
4128 tCsrScanResult *pScanResult = NULL;
4129 eCsrJoinState eRoamState = eCsrStopRoaming;
4130 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4131 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4132 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4133#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4134 v_U8_t acm_mask = 0;
4135#endif
4136 tANI_U32 sessionId = pCommand->sessionId;
4137 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4138 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4139 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004140
4141 if(!pSession)
4142 {
4143 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4144 return (eCsrStopRoaming);
4145 }
4146
Jeff Johnson295189b2012-06-20 16:38:30 -07004147 do
4148 {
4149 // Check for Cardbus eject condition, before trying to Roam to any BSS
4150 //***if( !balIsCardPresent(pAdapter) ) break;
4151
Kiet Lam64c1b492013-07-12 13:56:44 +05304152 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004153 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004154 if(NULL != pBSSList)
4155 {
4156 // When handling AP's capability change, continue to associate to
4157 // same BSS and make sure pRoamBssEntry is not Null.
4158 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4159 {
4160 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4161 {
4162 //Try the first BSS
4163 pCommand->u.roamCmd.pLastRoamBss = NULL;
4164 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4165 }
4166 else
4167 {
4168 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4169 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4170 {
4171 //Done with all the BSSs
4172 //In this case, will tell HDD the completion
4173 break;
4174 }
4175 else
4176 {
4177 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304178 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4180 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4181 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4182 pRoamInfo = &roamInfo;
4183 }
4184 }
4185 while(pCommand->u.roamCmd.pRoamBssEntry)
4186 {
4187 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004188 /*If concurrency enabled take the concurrent connected channel first. */
4189 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004190 if (vos_concurrent_sessions_running() &&
4191 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 {
4193 concurrentChannel =
4194 csrGetConcurrentOperationChannel(pMac);
4195 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004196 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004197 if ((concurrentChannel) &&
4198 (concurrentChannel ==
4199 pScanResult->Result.BssDescriptor.channelId))
4200 {
4201 //make this 0 because we do not want the
4202 //below check to pass as we don't want to
4203 //connect on other channel
4204 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4205 FL("Concurrent channel match =%d"),
4206 concurrentChannel);
4207 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 }
4209 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004210
4211 if (!concurrentChannel)
4212 {
4213
4214 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4215 sessionId, &pScanResult->Result.BssDescriptor,
4216 pCommand->u.roamCmd.roamId)))
4217 {
4218 //Ok to roam this
4219 break;
4220 }
4221 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004222 else
4223 {
4224 eRoamState = eCsrStopRoamingDueToConcurrency;
4225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004226 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4227 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4228 {
4229 //Done with all the BSSs
4230 fDone = eANI_BOOLEAN_TRUE;
4231 break;
4232 }
4233 }
4234 if(fDone)
4235 {
4236 break;
4237 }
4238 }
4239 }
4240 //We have something to roam, tell HDD when it is infra.
4241 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4242 //For WDS, the indication is eCSR_ROAM_WDS_IND
4243 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4244 {
4245 if(pRoamInfo)
4246 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004247 if(pSession->bRefAssocStartCnt)
4248 {
4249 pSession->bRefAssocStartCnt--;
4250 //Complete the last association attemp because a new one is about to be tried
4251 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4252 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004254 }
4255 }
4256 /* If the roaming has stopped, not to continue the roaming command*/
4257 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4258 {
4259 //No need to complete roaming here as it already completes
4260 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4261 pCommand->u.roamCmd.roamReason);
4262 eRoamState = eCsrStopRoaming;
4263 csrSetAbortRoamingCommand(pMac, pCommand);
4264 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304266 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 if(pScanResult)
4268 {
4269 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4271 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004272 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004273 fDone = eANI_BOOLEAN_TRUE;
4274 eRoamState = eCsrStopRoaming;
4275 break;
4276 }
4277 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4278 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4279 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4280 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4281 CSR_IS_QOS_BSS(pIesLocal) &&
4282 CSR_IS_UAPSD_BSS(pIesLocal) )
4283 {
4284#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004285 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4286 pIesLocal);
4287 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4288#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 }
4290 else
4291 {
4292 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4293 }
4294 if( pIesLocal && !pScanResult->Result.pvIes)
4295 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304296 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 }
4298 }
4299 else
4300 {
4301 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4302 }
4303 roamInfo.pProfile = pProfile;
4304 pSession->bRefAssocStartCnt++;
4305 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4306 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4307 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4309 {
4310 // If this is a start IBSS profile, then we need to start the IBSS.
4311 if ( CSR_IS_START_IBSS(pProfile) )
4312 {
4313 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 // Attempt to start this IBSS...
4315 csrRoamAssignDefaultParam( pMac, pCommand );
4316 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4317 if(HAL_STATUS_SUCCESS(status))
4318 {
4319 if ( fSameIbss )
4320 {
4321 eRoamState = eCsrStartIbssSameIbss;
4322 }
4323 else
4324 {
4325 eRoamState = eCsrContinueRoaming;
4326 }
4327 }
4328 else
4329 {
4330 //it somehow fail need to stop
4331 eRoamState = eCsrStopRoaming;
4332 }
4333 break;
4334 }
4335 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004336 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004337 )
4338 {
4339 // Attempt to start this WDS...
4340 csrRoamAssignDefaultParam( pMac, pCommand );
4341 /* For AP WDS, we dont have any BSSDescription */
4342 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4343 if(HAL_STATUS_SUCCESS(status))
4344 {
4345 eRoamState = eCsrContinueRoaming;
4346 }
4347 else
4348 {
4349 //it somehow fail need to stop
4350 eRoamState = eCsrStopRoaming;
4351 }
4352 }
4353 else
4354 {
4355 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004356 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 eRoamState = eCsrStopRoaming;
4358 break;
4359 }
4360 }
4361 else //We have BSS
4362 {
4363 //Need to assign these value because they are used in csrIsSameProfile
4364 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4365 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4366 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4367 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4368 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4369 {
4370 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4371 {
4372 eRoamState = eCsrStartIbssSameIbss;
4373 break;
4374 }
4375 }
4376 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4377 {
4378 //trying to connect to the one already connected
4379 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4380 eRoamState = eCsrReassocToSelfNoCapChange;
4381 break;
4382 }
4383 // Attempt to Join this Bss...
4384 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4385 break;
4386 }
4387
4388 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4390 {
4391 //Need to indicate association_completion if association_start has been done
4392 if(pSession->bRefAssocStartCnt > 0)
4393 {
4394 pSession->bRefAssocStartCnt--;
4395 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004396 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004397 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4398 eCSR_ROAM_ASSOCIATION_COMPLETION,
4399 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4400 }
4401 }
4402
4403 return( eRoamState );
4404}
4405
Jeff Johnson295189b2012-06-20 16:38:30 -07004406static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4407{
4408 eHalStatus status = eHAL_STATUS_SUCCESS;
4409 eCsrJoinState RoamState;
4410 tANI_U32 sessionId = pCommand->sessionId;
4411
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 //***if( hddIsRadioStateOn( pAdapter ) )
4413 {
4414 // Attept to join a Bss...
4415 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004416
Jeff Johnson295189b2012-06-20 16:38:30 -07004417 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004418 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004419 {
4420 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004421 // and if connected in Infrastructure mode...
4422 if ( csrIsConnStateInfra(pMac, sessionId) )
4423 {
4424 //... then we need to issue a disassociation
4425 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4426 if(!HAL_STATUS_SUCCESS(status))
4427 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004428 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 //roam command is completed by caller in the failed case
4430 fComplete = eANI_BOOLEAN_TRUE;
4431 }
4432 }
4433 else if( csrIsConnStateIbss(pMac, sessionId) )
4434 {
4435 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4436 if(!HAL_STATUS_SUCCESS(status))
4437 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004438 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 //roam command is completed by caller in the failed case
4440 fComplete = eANI_BOOLEAN_TRUE;
4441 }
4442 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4444 {
4445 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4446 if(!HAL_STATUS_SUCCESS(status))
4447 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004448 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004449 //roam command is completed by caller in the failed case
4450 fComplete = eANI_BOOLEAN_TRUE;
4451 }
4452 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004453 else
4454 {
4455 fComplete = eANI_BOOLEAN_TRUE;
4456 }
4457 if(fComplete)
4458 {
4459 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004460 if(eCsrStopRoamingDueToConcurrency == RoamState)
4461 {
4462 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4463 }
4464 else
4465 {
4466 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004468 }
4469 }
4470 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4471 {
4472 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4473 }
4474 else if ( eCsrStartIbssSameIbss == RoamState )
4475 {
4476 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4477 }
4478 }//hddIsRadioStateOn
4479
4480 return status;
4481}
Jeff Johnson295189b2012-06-20 16:38:30 -07004482eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4483{
4484 tANI_U32 sessionId;
4485 tCsrRoamSession *pSession;
4486 tCsrScanResult *pScanResult = NULL;
4487 tSirBssDescription *pBssDesc = NULL;
4488 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004489 sessionId = pCommand->sessionId;
4490 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004491
4492 if(!pSession)
4493 {
4494 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4495 return eHAL_STATUS_FAILURE;
4496 }
4497
Jeff Johnson295189b2012-06-20 16:38:30 -07004498 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4499 {
4500 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004501 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4503 return eHAL_STATUS_FAILURE;
4504 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 if (pCommand->u.roamCmd.pRoamBssEntry)
4506 {
4507 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4508 pBssDesc = &pScanResult->Result.BssDescriptor;
4509 }
4510 else
4511 {
4512 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004513 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4515 return eHAL_STATUS_FAILURE;
4516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4518 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4519 return status;
4520}
4521
Jeff Johnson295189b2012-06-20 16:38:30 -07004522eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4523{
4524 eHalStatus status = eHAL_STATUS_SUCCESS;
4525 tCsrRoamInfo roamInfo;
4526 tANI_U32 sessionId = pCommand->sessionId;
4527 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004528
4529 if(!pSession)
4530 {
4531 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4532 return eHAL_STATUS_FAILURE;
4533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004534
4535 switch ( pCommand->u.roamCmd.roamReason )
4536 {
4537 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004539 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 case eCsrSmeIssuedDisassocForHandoff:
4542 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4543#if 0 // TODO : Confirm this change
4544 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4545#else
4546 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4547#endif
4548
4549 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004550 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004552 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004554 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004556 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 case eCsrHddIssuedReassocToSameAP:
4559 case eCsrSmeIssuedReassocToSameAP:
4560 {
4561 tDot11fBeaconIEs *pIes = NULL;
4562
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 if( pSession->pConnectBssDesc )
4564 {
4565 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4566 if(!HAL_STATUS_SUCCESS(status) )
4567 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004568 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 }
4570 else
4571 {
4572 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4573 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4574 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4576 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4577 pSession->bRefAssocStartCnt++;
4578 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4579 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4580
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004581 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004582 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4583 &pCommand->u.roamCmd.roamProfile );
4584 if(!HAL_STATUS_SUCCESS(status))
4585 {
4586 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004587 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004588 }
4589
Kiet Lam64c1b492013-07-12 13:56:44 +05304590 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004591 pIes = NULL;
4592 }
4593 }
4594 break;
4595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004596 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004597 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4599 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4600 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004601 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004602 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4604 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004605
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 case eCsrStopBss:
4607 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4608 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4609 break;
4610
4611 case eCsrForcedDisassocSta:
4612 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4613 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4614 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4615 pCommand->u.roamCmd.reason);
4616 break;
4617
4618 case eCsrForcedDeauthSta:
4619 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4620 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4621 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4622 pCommand->u.roamCmd.reason);
4623 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004624
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004625 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004626 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004627 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4628 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004629 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004630
4631 default:
4632 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4633
4634 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4635 {
4636 //Remember the roaming profile
4637 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304638 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4639 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004640 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304641 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004642 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4643 }
4644 }
4645
4646 //At this point, original uapsd_mask is saved in pCurRoamProfile
4647 //uapsd_mask in the pCommand may change from this point on.
4648
4649 // Attempt to roam with the new scan results (if we need to..)
4650 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004651 if(!HAL_STATUS_SUCCESS(status))
4652 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004653 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004655 break;
4656 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004657 return (status);
4658}
4659
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004660void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4661{
4662 pCommand->u.roamCmd.pLastRoamBss = NULL;
4663 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4664 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304665 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004666}
4667
Jeff Johnson295189b2012-06-20 16:38:30 -07004668void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4669{
4670 if(pCommand->u.roamCmd.fReleaseBssList)
4671 {
4672 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4673 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4674 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4675 }
4676 if(pCommand->u.roamCmd.fReleaseProfile)
4677 {
4678 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4679 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4680 }
4681 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4682 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304683 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004684}
4685
Jeff Johnson295189b2012-06-20 16:38:30 -07004686void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4687{
Kiet Lam64c1b492013-07-12 13:56:44 +05304688 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004689}
Jeff Johnson295189b2012-06-20 16:38:30 -07004690void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4691{
4692 tListElem *pEntry;
4693 tSmeCmd *pCommand;
4694 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004695 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4697 if ( pEntry )
4698 {
4699 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 // If the head of the queue is Active and it is a ROAM command, remove
4701 // and put this on the Free queue.
4702 if ( eSmeCommandRoam == pCommand->command )
4703 {
4704 //we need to process the result first before removing it from active list because state changes
4705 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4706 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4707 if( fReleaseCommand )
4708 {
4709 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4710 {
4711 csrReleaseCommandRoam( pMac, pCommand );
4712 }
4713 else
4714 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004715 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004716 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004717 }
4718 }
4719 else
4720 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004721 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004722 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 }
4724 }
4725 else
4726 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004727 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004728 }
4729 }
4730 else
4731 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004732 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004733 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004734 if( fReleaseCommand )
4735 {
4736 smeProcessPendingQueue( pMac );
4737 }
4738}
4739
Jeff Johnson295189b2012-06-20 16:38:30 -07004740void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4741{
4742 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004743 if(!pSession)
4744 {
4745 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4746 return;
4747 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304748 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4749 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004750 pSession->NumPmkidCandidate = 0;
4751}
Jeff Johnson295189b2012-06-20 16:38:30 -07004752#ifdef FEATURE_WLAN_WAPI
4753void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4754{
4755 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004756 if(!pSession)
4757 {
4758 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4759 return;
4760 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304761 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4762 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 pSession->NumBkidCandidate = 0;
4764}
4765#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004766extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4767
Jeff Johnson295189b2012-06-20 16:38:30 -07004768static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4769 tSirBssDescription *pSirBssDesc,
4770 tDot11fBeaconIEs *pIes)
4771{
4772 eHalStatus status = eHAL_STATUS_SUCCESS;
4773 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4774 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004775
4776 if(!pSession)
4777 {
4778 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4779 return eHAL_STATUS_FAILURE;
4780 }
4781
Jeff Johnson295189b2012-06-20 16:38:30 -07004782 if((eCSR_AUTH_TYPE_WPA == authType) ||
4783 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4784 (eCSR_AUTH_TYPE_RSN == authType) ||
4785 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4786#if defined WLAN_FEATURE_VOWIFI_11R
4787 ||
4788 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4789 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4790#endif /* FEATURE_WLAN_WAPI */
4791#ifdef FEATURE_WLAN_WAPI
4792 ||
4793 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4794 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4795#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004796#ifdef WLAN_FEATURE_11W
4797 ||
4798 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4799#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004800 )
4801 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4803 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004804 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 }
4806 if( pIesLocal )
4807 {
4808 tANI_U32 nIeLen;
4809 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 if((eCSR_AUTH_TYPE_RSN == authType) ||
4811#if defined WLAN_FEATURE_VOWIFI_11R
4812 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4813 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4814#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004815#if defined WLAN_FEATURE_11W
4816 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4817#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004818 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4819 {
4820 if(pIesLocal->RSN.present)
4821 {
4822 //Calculate the actual length
4823 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4824 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4825 + 2 //akm_suite_count
4826 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4827 + 2; //reserved
4828 if( pIesLocal->RSN.pmkid_count )
4829 {
4830 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4831 }
4832 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304833 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4834 if (NULL == pSession->pWpaRsnRspIE)
4835 status = eHAL_STATUS_FAILURE;
4836 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004837 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304838 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4840 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4841 //copy upto akm_suites
4842 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304843 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4844 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004845 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304846 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4847 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004848 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304849 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4850 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004851 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004852 if( pIesLocal->RSN.pwise_cipher_suite_count )
4853 {
4854 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304855 vos_mem_copy(pIeBuf,
4856 pIesLocal->RSN.pwise_cipher_suites,
4857 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4859 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304860 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004861 pIeBuf += 2;
4862 if( pIesLocal->RSN.akm_suite_count )
4863 {
4864 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304865 vos_mem_copy(pIeBuf,
4866 pIesLocal->RSN.akm_suites,
4867 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4869 }
4870 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05304871 vos_mem_copy(pIeBuf,
4872 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
4873 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004874 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4875 }
4876 }
4877 }
4878 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4879 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4880 {
4881 if(pIesLocal->WPA.present)
4882 {
4883 //Calculate the actual length
4884 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4885 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4886 + 2 //auth_suite_count
4887 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4888 // The WPA capabilities follows the Auth Suite (two octects)--
4889 // this field is optional, and we always "send" zero, so just
4890 // remove it. This is consistent with our assumptions in the
4891 // frames compiler; c.f. bug 15234:
4892 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304893
4894 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4895 if ( NULL == pSession->pWpaRsnRspIE )
4896 status = eHAL_STATUS_FAILURE;
4897 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004898 {
4899 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4900 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4901 pIeBuf = pSession->pWpaRsnRspIE + 2;
4902 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05304903 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304905 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
4906 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304908 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
4909 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004910 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4911 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4912 }
4913 }
4914 }
4915#ifdef FEATURE_WLAN_WAPI
4916 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4917 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4918 {
4919 if(pIesLocal->WAPI.present)
4920 {
4921 //Calculate the actual length
4922 nIeLen = 4 //version + akm_suite_count
4923 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4924 + 2 //pwise_cipher_suite_count
4925 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4926 + 6; //gp_cipher_suite + preauth + reserved
4927 if( pIesLocal->WAPI.bkid_count )
4928 {
4929 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4930 }
4931
4932 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304933 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
4934 if ( NULL == pSession->pWapiRspIE )
4935 status = eHAL_STATUS_FAILURE;
4936 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 {
4938 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4939 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4940 pIeBuf = pSession->pWapiRspIE + 2;
4941 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05304942 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004943 pIeBuf += 4;
4944 if( pIesLocal->WAPI.akm_suite_count )
4945 {
4946 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304947 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
4948 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004949 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304950 }
4951 vos_mem_copy(pIeBuf,
4952 &pIesLocal->WAPI.unicast_cipher_suite_count,
4953 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004954 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4956 {
4957 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304958 vos_mem_copy( pIeBuf,
4959 pIesLocal->WAPI.unicast_cipher_suites,
4960 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4962 }
lukez3c809222013-05-03 10:23:02 -07004963 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05304964 vos_mem_copy(pIeBuf,
4965 pIesLocal->WAPI.multicast_cipher_suite,
4966 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07004967 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304968 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05304969 vos_mem_copy(pIeBuf,
4970 pIesLocal->WAPI.multicast_cipher_suite + 4,
4971 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07004972 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304973 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05304974 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
4975
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07004976 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 if( pIesLocal->WAPI.bkid_count )
4978 {
4979 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304980 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
4981 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
4983 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304984 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 }
4987 }
4988#endif /* FEATURE_WLAN_WAPI */
4989 if( !pIes )
4990 {
4991 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05304992 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004993 }
4994 }
4995 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004996 return (status);
4997}
4998
Jeff Johnson295189b2012-06-20 16:38:30 -07004999static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5000{
5001 v_U8_t bACWeights[WLANTL_MAX_AC];
5002 v_U8_t paramBk, paramBe, paramVi, paramVo;
5003 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5005 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5006 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5007 //This doesn't address the case where the lower AC needs a real higher weight
5008 if( pIEs->WMMParams.present )
5009 {
5010 //no change to the lowest ones
5011 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5012 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5013 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5014 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5015 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5016 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5017 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5018 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5019 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5020 {
5021 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5022 fWeightChange = VOS_TRUE;
5023 }
5024 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5025 {
5026 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5027 fWeightChange = VOS_TRUE;
5028 }
5029 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5030 {
5031 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5032 fWeightChange = VOS_TRUE;
5033 }
5034 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5035 {
5036 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5037 fWeightChange = VOS_TRUE;
5038 }
5039 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5040 {
5041 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5042 fWeightChange = VOS_TRUE;
5043 }
5044 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5045 {
5046 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5047 fWeightChange = VOS_TRUE;
5048 }
5049 if(fWeightChange)
5050 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005051 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005052 bACWeights[2], bACWeights[3]);
5053 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5054 }
5055 }
5056}
Jeff Johnson295189b2012-06-20 16:38:30 -07005057#ifdef WLAN_FEATURE_VOWIFI_11R
5058//Returns whether the current association is a 11r assoc or not
5059tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5060{
5061#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5062 return csrNeighborRoamIs11rAssoc(pMac);
5063#else
5064 return eANI_BOOLEAN_FALSE;
5065#endif
5066}
5067#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005068#ifdef FEATURE_WLAN_CCX
5069//Returns whether the current association is a CCX assoc or not
5070tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
5071{
5072#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5073 return csrNeighborRoamIsCCXAssoc(pMac);
5074#else
5075 return eANI_BOOLEAN_FALSE;
5076#endif
5077}
5078#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005079#ifdef FEATURE_WLAN_LFR
5080//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305081tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005082{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305083 tCsrRoamSession *pSession = NULL;
5084
5085 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5086 {
5087 pSession = CSR_GET_SESSION( pMac, sessionId );
5088 if (NULL != pSession->pCurRoamProfile)
5089 {
5090 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5091 {
5092 return eANI_BOOLEAN_FALSE;
5093 }
5094 }
5095 }
5096
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005097#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5098 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5099 {
5100 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5101 }
5102 else
5103#endif
5104 {
5105 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005106 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005107 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005108}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005109
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005110#ifdef FEATURE_WLAN_CCX
5111/* ---------------------------------------------------------------------------
5112
5113 \fn csrNeighborRoamIsCCXAssoc
5114
5115 \brief This function returns whether the current association is a CCX assoc or not
5116
5117 \param pMac - The handle returned by macOpen.
5118
5119 \return eANI_BOOLEAN_TRUE if current assoc is CCX, eANI_BOOLEAN_FALSE otherwise
5120
5121---------------------------------------------------------------------------*/
5122tANI_BOOLEAN csrNeighborRoamIsCCXAssoc(tpAniSirGlobal pMac)
5123{
5124 return pMac->roam.neighborRoamInfo.isCCXAssoc;
5125}
5126#endif /* FEATURE_WLAN_CCX */
5127
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005128#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5129//Returns whether "FW based BG scan" is currently enabled...or not
5130tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5131{
5132 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5133}
5134#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005135#endif
5136
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005137#if defined(FEATURE_WLAN_CCX)
5138tANI_BOOLEAN csrRoamIsCcxIniFeatureEnabled(tpAniSirGlobal pMac)
5139{
5140 return pMac->roam.configParam.isCcxIniFeatureEnabled;
5141}
5142#endif /*FEATURE_WLAN_CCX*/
5143
Jeff Johnson295189b2012-06-20 16:38:30 -07005144//Return true means the command can be release, else not
5145static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5146 eCsrRoamCompleteResult Result, void *Context )
5147{
5148 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5149 tSirBssDescription *pSirBssDesc = NULL;
5150 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5151 tCsrScanResult *pScanResult = NULL;
5152 tCsrRoamInfo roamInfo;
5153 sme_QosAssocInfo assocInfo;
5154 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5155 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5156 tDot11fBeaconIEs *pIes = NULL;
5157 tANI_U32 sessionId = pCommand->sessionId;
5158 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5159 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5160 eRoamCmdStatus roamStatus;
5161 eCsrRoamResult roamResult;
5162 eHalStatus status;
5163 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005164 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005165
Jeff Johnson32d95a32012-09-10 13:15:23 -07005166 if(!pSession)
5167 {
5168 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5169 return eANI_BOOLEAN_FALSE;
5170 }
5171
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005172 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005173 switch( Result )
5174 {
5175 case eCsrJoinSuccess:
5176 // reset the IDLE timer
5177 // !!
5178 // !! fall through to the next CASE statement here is intentional !!
5179 // !!
5180 case eCsrReassocSuccess:
5181 if(eCsrReassocSuccess == Result)
5182 {
5183 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5184 }
5185 else
5186 {
5187 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5188 }
5189 // Success Join Response from LIM. Tell NDIS we are connected and save the
5190 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005191 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305192 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005193 //always free the memory here
5194 if(pSession->pWpaRsnRspIE)
5195 {
5196 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305197 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005198 pSession->pWpaRsnRspIE = NULL;
5199 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005200#ifdef FEATURE_WLAN_WAPI
5201 if(pSession->pWapiRspIE)
5202 {
5203 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305204 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 pSession->pWapiRspIE = NULL;
5206 }
5207#endif /* FEATURE_WLAN_WAPI */
5208#ifdef FEATURE_WLAN_BTAMP_UT_RF
5209 //Reset counter so no join retry is needed.
5210 pSession->maxRetryCount = 0;
5211 csrRoamStopJoinRetryTimer(pMac, sessionId);
5212#endif
5213 /* This creates problem since we have not saved the connected profile.
5214 So moving this after saving the profile
5215 */
5216 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
5217 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5218 {
5219 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5220 }
5221 else
5222 {
5223 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5224 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005225 //Use the last connected bssdesc for reassoc-ing to the same AP.
5226 //NOTE: What to do when reassoc to a different AP???
5227 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5228 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5229 {
5230 pSirBssDesc = pSession->pConnectBssDesc;
5231 if(pSirBssDesc)
5232 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305233 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5234 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 }
5236 }
5237 else
5238 {
5239
5240 if(pCommand->u.roamCmd.pRoamBssEntry)
5241 {
5242 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5243 if(pScanResult != NULL)
5244 {
5245 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5246 //this can be NULL
5247 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305248 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5249 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005250 }
5251 }
5252 }
5253 if( pSirBssDesc )
5254 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005255 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5257 //Save WPA/RSN IE
5258 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5259#ifdef FEATURE_WLAN_CCX
5260 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5261#endif
5262
5263 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5264 // substate change.
5265 // Moving even save profile above so that below mentioned conditon is also met.
5266 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5267 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005268 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5269 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5270 // will be dropped for the security context may not be set properly.
5271 //
5272 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5273 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5274 //
5275 // this reordering was done on titan_prod_usb branch and is being replicated here.
5276 //
5277
5278 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5279 !pProfile->bWPSAssociation)
5280 {
5281 // Issue the set Context request to LIM to establish the Unicast STA context
5282 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5283 pProfile->negotiatedUCEncryptionType,
5284 pSirBssDesc, &(pSirBssDesc->bssId),
5285 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5286 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005287 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005288 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5289 }
5290 // Issue the set Context request to LIM to establish the Broadcast STA context
5291 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5292 pSirBssDesc, &BroadcastMac,
5293 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5294 }
5295 else
5296 {
5297 //Need to wait for supplicant authtication
5298 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 //Set the subestate to WaitForKey in case authentiation is needed
5300 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5301
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 if(pProfile->bWPSAssociation)
5303 {
5304 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5305 }
5306 else
5307 {
5308 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5309 }
5310
5311 //Save sessionId in case of timeout
5312 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5313 //This time should be long enough for the rest of the process plus setting key
5314 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5315 {
5316 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005317 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005318 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5319 }
5320 }
5321
5322 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5323 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005324 if(Context)
5325 {
5326 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5327 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005328 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5329 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5330#ifdef WLAN_FEATURE_VOWIFI_11R
5331 len += pJoinRsp->parsedRicRspLen;
5332#endif /* WLAN_FEATURE_VOWIFI_11R */
5333#ifdef FEATURE_WLAN_CCX
5334 len += pJoinRsp->tspecIeLen;
5335#endif
5336 if(len)
5337 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305338 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5339 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005340 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305341 vos_mem_copy(pSession->connectedInfo.pbFrames,
5342 pJoinRsp->frames, len);
5343 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5344 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5345 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005346#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305347 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005348#endif /* WLAN_FEATURE_VOWIFI_11R */
5349#ifdef FEATURE_WLAN_CCX
Kiet Lam64c1b492013-07-12 13:56:44 +05305350 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005351#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305352 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5353 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5354 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5355 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005356 }
5357 }
5358 if(pCommand->u.roamCmd.fReassoc)
5359 {
5360 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5361 }
5362 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5363 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5364 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5365 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5366 }
5367 else
5368 {
5369 if(pCommand->u.roamCmd.fReassoc)
5370 {
5371 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5372 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5373 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5374 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5375 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5376 }
5377 }
5378#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5379 // Indicate SME-QOS with reassoc success event, only after
5380 // copying the frames
5381 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5382#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005383 roamInfo.pBssDesc = pSirBssDesc;
5384 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5385 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5386#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5387 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5388#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5389 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5391 //It may be better to let QoS do this????
5392 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5393 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005394 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005395 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5396 pmcStartUapsd( pMac, NULL, NULL );
5397 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305398 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5400 if( pSession->bRefAssocStartCnt > 0 )
5401 {
5402 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005403 //Remove this code once SLM_Sessionization is supported
5404 //BMPS_WORKAROUND_NOT_NEEDED
5405 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005406 {
5407 pMac->roam.configParam.doBMPSWorkaround = 1;
5408 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005409 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5410 }
5411
5412 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005413 // reset the PMKID candidate list
5414 csrResetPMKIDCandidateList( pMac, sessionId );
5415 //Update TL's AC weight base on the current EDCA parameters
5416 //These parameters may change in the course of the connection, that sictuation
5417 //is not taken care here. This change is mainly to address a WIFI WMM test where
5418 //BE has a equal or higher TX priority than VI.
5419 //We only do this for infra link
5420 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5421 {
5422 csrCheckAndUpdateACWeight(pMac, pIes);
5423 }
5424#ifdef FEATURE_WLAN_WAPI
5425 // reset the BKID candidate list
5426 csrResetBKIDCandidateList( pMac, sessionId );
5427#endif /* FEATURE_WLAN_WAPI */
5428 }
5429 else
5430 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005431 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 csrScanCancelIdleScan(pMac);
5434 //Not to signal link up because keys are yet to be set.
5435 //The linkup function will overwrite the sub-state that we need to keep at this point.
5436 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5437 {
5438 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5441 //enough to let security and DHCP handshake succeed before entry into BMPS
5442 if (pmcShouldBmpsTimerRun(pMac))
5443 {
5444 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5445 != eHAL_STATUS_SUCCESS)
5446 {
5447 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5448 }
5449 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 break;
5452
Jeff Johnson295189b2012-06-20 16:38:30 -07005453 case eCsrStartBssSuccess:
5454 // on the StartBss Response, LIM is returning the Bss Description that we
5455 // are beaconing. Add this Bss Description to our scan results and
5456 // chain the Profile to this Bss Description. On a Start BSS, there was no
5457 // detected Bss description (no partner) so we issued the Start Bss to
5458 // start the Ibss without any Bss description. Lim was kind enough to return
5459 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005460 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305463 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 if( CSR_IS_IBSS( pProfile ) )
5465 {
5466 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005468 else if (CSR_IS_INFRA_AP(pProfile))
5469 {
5470 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005472 else
5473 {
5474 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5475 }
5476 if( !CSR_IS_WDS_STA( pProfile ) )
5477 {
5478 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005479 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005480 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5481 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305482 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 roamInfo.pBssDesc = pSirBssDesc;
5484 //We need to associate_complete it first, becasue Associate_start already indicated.
5485 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5486 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5487 break;
5488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005490 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005491 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 }
5493 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5494 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5495 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5496 if(pSirBssDesc)
5497 {
5498 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305499 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5500 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005501 }
5502 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305503 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005504#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5505 {
5506 vos_log_ibss_pkt_type *pIbssLog;
5507 tANI_U32 bi;
5508
5509 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5510 if(pIbssLog)
5511 {
5512 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5513 {
5514 //We start the IBSS (didn't find any matched IBSS out there)
5515 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5516 }
5517 else
5518 {
5519 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5520 }
5521 if(pSirBssDesc)
5522 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305523 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005524 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5525 }
5526 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5527 {
5528 //***U8 is not enough for beacon interval
5529 pIbssLog->beaconInterval = (v_U8_t)bi;
5530 }
5531 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5532 }
5533 }
5534#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5535 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5536 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5538 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5540 csrRoamIssueSetContextReq( pMac, sessionId,
5541 pProfile->negotiatedMCEncryptionType,
5542 pSirBssDesc, &BroadcastMac,
5543 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5544 }
5545 }
5546 else
5547 {
5548 //Keep the state to eCSR_ROAMING_STATE_JOINING
5549 //Need to send join_req.
5550 if(pCommand->u.roamCmd.pRoamBssEntry)
5551 {
5552 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5553 {
5554 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5555 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5556 // Set the roaming substate to 'join attempt'...
5557 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005558 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005559 }
5560 }
5561 else
5562 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005563 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005564 VOS_ASSERT( 0 );
5565 }
5566 }
5567 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5568 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5569 //trigger the connection start indication in Vista
5570 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5571 {
5572 roamStatus = eCSR_ROAM_IBSS_IND;
5573 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5574 if( CSR_IS_WDS( pProfile ) )
5575 {
5576 roamStatus = eCSR_ROAM_WDS_IND;
5577 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005579 if( CSR_IS_INFRA_AP( pProfile ) )
5580 {
5581 roamStatus = eCSR_ROAM_INFRA_IND;
5582 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5583 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005584
5585 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5586 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5587 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305588 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005589 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5590 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005591 //We start the IBSS (didn't find any matched IBSS out there)
5592 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005593 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305594 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5595 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005596 //Remove this code once SLM_Sessionization is supported
5597 //BMPS_WORKAROUND_NOT_NEEDED
5598 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005599 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005600 {
5601 pMac->roam.configParam.doBMPSWorkaround = 1;
5602 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005603
Jeff Johnson295189b2012-06-20 16:38:30 -07005604 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5605 }
5606
5607 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005608
5609 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 {
5611 //need to send stop BSS because we fail to send join_req
5612 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5613 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5614 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005616 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005617 case eCsrStartBssFailure:
5618#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5619 {
5620 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005621 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5622 if(pIbssLog)
5623 {
5624 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5625 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5626 }
5627 }
5628#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005629 roamStatus = eCSR_ROAM_IBSS_IND;
5630 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5631 if( CSR_IS_WDS( pProfile ) )
5632 {
5633 roamStatus = eCSR_ROAM_WDS_IND;
5634 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005636 if( CSR_IS_INFRA_AP( pProfile ) )
5637 {
5638 roamStatus = eCSR_ROAM_INFRA_IND;
5639 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5640 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005641 if(Context)
5642 {
5643 pSirBssDesc = (tSirBssDescription *)Context;
5644 }
5645 else
5646 {
5647 pSirBssDesc = NULL;
5648 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305649 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 roamInfo.pBssDesc = pSirBssDesc;
5651 //We need to associate_complete it first, becasue Associate_start already indicated.
5652 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5653 csrSetDefaultDot11Mode( pMac );
5654 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 case eCsrSilentlyStopRoaming:
5656 // We are here because we try to start the same IBSS
5657 //No message to PE
5658 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005659 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5661 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305662 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005663 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5664 if( roamInfo.pBssDesc )
5665 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305666 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5667 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005668 }
5669 //Since there is no change in the current state, simply pass back no result otherwise
5670 //HDD may be mistakenly mark to disconnected state.
5671 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5672 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005673 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005674 case eCsrSilentlyStopRoamingSaveState:
5675 //We are here because we try to connect to the same AP
5676 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005677 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305678 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005679
5680 //to aviod resetting the substate to NONE
5681 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5682 //No need to change substate to wai_for_key because there is no state change
5683 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5684 if( roamInfo.pBssDesc )
5685 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305686 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5687 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005688 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5690 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5691 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5692 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5693 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5694 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5695 roamInfo.staId = pSession->connectedInfo.staId;
5696 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005697 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005698 pSession->bRefAssocStartCnt--;
5699 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5700 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5701 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5702 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005703 case eCsrReassocFailure:
5704#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5705 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5706#endif
5707 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005708 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 csrFreeConnectBssDesc(pMac, sessionId);
5710 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5711 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305712 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5714 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5715 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5716 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5717 eCSR_ROAM_WDS_IND,
5718 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5719 //Need to issue stop_bss
5720 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005721 case eCsrJoinFailure:
5722 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005723 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 default:
5725 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005726 smsLog(pMac, LOGW, FL("receives no association indication"));
5727 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005728 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005729 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5730 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5731 {
5732 //do not free for the other profiles as we need to send down stop BSS later
5733 csrFreeConnectBssDesc(pMac, sessionId);
5734 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5735 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5736 csrSetDefaultDot11Mode( pMac );
5737 }
5738
5739 switch( pCommand->u.roamCmd.roamReason )
5740 {
5741 // If this transition is because of an 802.11 OID, then we transition
5742 // back to INIT state so we sit waiting for more OIDs to be issued and
5743 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005744 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005745 case eCsrSmeIssuedAssocToSimilarAP:
5746 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005747 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305749 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005750 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5751 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5752 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305753 vos_mem_copy(&roamInfo.bssid,
5754 &pSession->joinFailStatusCode.bssId,
5755 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005756
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 /* Defeaturize this later if needed */
5758#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5759 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5760 if (csrRoamIsHandoffInProgress(pMac))
5761 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005762 /* Should indicate neighbor roam algorithm about the connect failure here */
5763 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5764 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005765#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 if(pSession->bRefAssocStartCnt > 0)
5767 {
5768 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005769 if(eCsrJoinFailureDueToConcurrency == Result)
5770 {
5771 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5772 eCSR_ROAM_ASSOCIATION_COMPLETION,
5773 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5774 }
5775 else
5776 {
5777 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005778 eCSR_ROAM_ASSOCIATION_COMPLETION,
5779 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005780 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005782 else
5783 {
5784 /* bRefAssocStartCnt is not incremented when
5785 * eRoamState == eCsrStopRoamingDueToConcurrency
5786 * in csrRoamJoinNextBss API. so handle this in
5787 * else case by sending assoc failure
5788 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005789 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005790 pCommand->u.scanCmd.roamId,
5791 eCSR_ROAM_ASSOCIATION_FAILURE,
5792 eCSR_ROAM_RESULT_FAILURE);
5793 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005794 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005795#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05305796 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005797 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5798#endif
5799 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5800 csrScanStartIdleScan(pMac);
5801#ifdef FEATURE_WLAN_BTAMP_UT_RF
5802 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5803 //BT activity and not able to recevie WLAN traffic. Retry the join
5804 if( CSR_IS_WDS_STA(pProfile) )
5805 {
5806 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5807 }
5808#endif
5809 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 case eCsrHddIssuedReassocToSameAP:
5811 case eCsrSmeIssuedReassocToSameAP:
5812 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5813
5814 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5815#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5816 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5817#endif
5818 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5819 csrScanStartIdleScan(pMac);
5820 break;
5821 case eCsrForcedDisassoc:
5822 case eCsrForcedDeauth:
5823 case eCsrSmeIssuedIbssJoinFailure:
5824 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5825
5826 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5827 {
5828 // Notify HDD that IBSS join failed
5829 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5830 }
5831 else
5832 {
5833 csrRoamCallCallback(pMac, sessionId, NULL,
5834 pCommand->u.roamCmd.roamId,
5835 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5836 }
5837#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5838 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5839#endif
5840 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08005841 /*
5842 *DelSta not done FW still in conneced state so dont
5843 *issue IMPS req
5844 */
5845 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
5846 {
5847 smsLog(pMac, LOGW, FL("FW still in connected state "));
5848 break;
5849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005850 csrScanStartIdleScan(pMac);
5851 break;
5852 case eCsrForcedIbssLeave:
5853 csrRoamCallCallback(pMac, sessionId, NULL,
5854 pCommand->u.roamCmd.roamId,
5855 eCSR_ROAM_IBSS_LEAVE,
5856 eCSR_ROAM_RESULT_IBSS_STOP);
5857 break;
5858 case eCsrForcedDisassocMICFailure:
5859 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5860
5861 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5862#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5863 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5864#endif
5865 csrScanStartIdleScan(pMac);
5866 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005867 case eCsrStopBss:
5868 csrRoamCallCallback(pMac, sessionId, NULL,
5869 pCommand->u.roamCmd.roamId,
5870 eCSR_ROAM_INFRA_IND,
5871 eCSR_ROAM_RESULT_INFRA_STOPPED);
5872 break;
5873 case eCsrForcedDisassocSta:
5874 case eCsrForcedDeauthSta:
5875 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5876 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5877 {
5878 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005879
5880 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5881 {
5882 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05305883 vos_mem_copy(roamInfo.peerMac,
5884 pCommand->u.roamCmd.peerMac,
5885 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5887 roamInfo.statusCode = eSIR_SME_SUCCESS;
5888 status = csrRoamCallCallback(pMac, sessionId,
5889 &roamInfo, pCommand->u.roamCmd.roamId,
5890 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5891 }
5892 }
5893 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005894 case eCsrLostLink1:
5895 // if lost link roam1 failed, then issue lost link Scan2 ...
5896 csrScanRequestLostLink2(pMac, sessionId);
5897 break;
5898 case eCsrLostLink2:
5899 // if lost link roam2 failed, then issue lost link scan3 ...
5900 csrScanRequestLostLink3(pMac, sessionId);
5901 break;
5902 case eCsrLostLink3:
5903 default:
5904 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5905
5906 //We are done with one round of lostlink roaming here
5907 csrScanHandleFailedLostlink3(pMac, sessionId);
5908 break;
5909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 break;
5911 }
5912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005913 return ( fReleaseCommand );
5914}
5915
Jeff Johnson295189b2012-06-20 16:38:30 -07005916eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5917{
5918 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 return (status);
5920}
5921
Jeff Johnson295189b2012-06-20 16:38:30 -07005922eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5923{
5924 eHalStatus status = eHAL_STATUS_SUCCESS;
5925 tANI_U32 size = 0;
5926
5927 do
5928 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305929 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005930 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5931 {
5932 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305933 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
5934 if ( NULL == pDstProfile->BSSIDs.bssid )
5935 status = eHAL_STATUS_FAILURE;
5936 else
5937 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 if(!HAL_STATUS_SUCCESS(status))
5939 {
5940 break;
5941 }
5942 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305943 vos_mem_copy(pDstProfile->BSSIDs.bssid,
5944 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 }
5946 if(pSrcProfile->SSIDs.numOfSSIDs)
5947 {
5948 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305949 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
5950 if ( NULL == pDstProfile->SSIDs.SSIDList )
5951 status = eHAL_STATUS_FAILURE;
5952 else
5953 status = eHAL_STATUS_SUCCESS;
5954 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005955 {
5956 break;
5957 }
5958 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305959 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
5960 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 }
5962 if(pSrcProfile->nWPAReqIELength)
5963 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305964 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
5965 if ( NULL == pDstProfile->pWPAReqIE )
5966 status = eHAL_STATUS_FAILURE;
5967 else
5968 status = eHAL_STATUS_SUCCESS;
5969
5970 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 {
5972 break;
5973 }
5974 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05305975 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
5976 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07005977 }
5978 if(pSrcProfile->nRSNReqIELength)
5979 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305980 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
5981 if ( NULL == pDstProfile->pRSNReqIE )
5982 status = eHAL_STATUS_FAILURE;
5983 else
5984 status = eHAL_STATUS_SUCCESS;
5985
5986 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 {
5988 break;
5989 }
5990 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05305991 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
5992 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 }
5994#ifdef FEATURE_WLAN_WAPI
5995 if(pSrcProfile->nWAPIReqIELength)
5996 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305997 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
5998 if ( NULL == pDstProfile->pWAPIReqIE )
5999 status = eHAL_STATUS_FAILURE;
6000 else
6001 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 if(!HAL_STATUS_SUCCESS(status))
6003 {
6004 break;
6005 }
6006 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306007 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6008 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006009 }
6010#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 if(pSrcProfile->nAddIEScanLength)
6012 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306013 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6014 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306016 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306017 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306018 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6019 }
6020 else
6021 {
6022 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6023 FL(" AddIEScanLength is not valid %u"),
6024 pSrcProfile->nAddIEScanLength);
6025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 if(pSrcProfile->nAddIEAssocLength)
6028 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306029 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6030 if ( NULL == pDstProfile->pAddIEAssoc )
6031 status = eHAL_STATUS_FAILURE;
6032 else
6033 status = eHAL_STATUS_SUCCESS;
6034
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 if(!HAL_STATUS_SUCCESS(status))
6036 {
6037 break;
6038 }
6039 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306040 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6041 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006043 if(pSrcProfile->ChannelInfo.ChannelList)
6044 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306045 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6046 pSrcProfile->ChannelInfo.numOfChannels);
6047 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6048 status = eHAL_STATUS_FAILURE;
6049 else
6050 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 if(!HAL_STATUS_SUCCESS(status))
6052 {
6053 break;
6054 }
6055 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306056 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6057 pSrcProfile->ChannelInfo.ChannelList,
6058 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006060 pDstProfile->AuthType = pSrcProfile->AuthType;
6061 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6062 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6063 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6064 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6065 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006066#ifdef WLAN_FEATURE_11W
6067 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6068 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6069 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6070#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 pDstProfile->BSSType = pSrcProfile->BSSType;
6072 pDstProfile->phyMode = pSrcProfile->phyMode;
6073 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6074
6075#ifdef FEATURE_WLAN_WAPI
6076 if(csrIsProfileWapi(pSrcProfile))
6077 {
6078 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6079 {
6080 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6081 }
6082 }
6083#endif /* FEATURE_WLAN_WAPI */
6084 pDstProfile->CBMode = pSrcProfile->CBMode;
6085 /*Save the WPS info*/
6086 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
6087 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006088 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006089 pDstProfile->privacy = pSrcProfile->privacy;
6090 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6091 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6092 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6093 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6094 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6095 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6096 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6097 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6098 pDstProfile->wps_state = pSrcProfile->wps_state;
6099 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306100 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6101 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006102#ifdef WLAN_FEATURE_VOWIFI_11R
6103 if (pSrcProfile->MDID.mdiePresent)
6104 {
6105 pDstProfile->MDID.mdiePresent = 1;
6106 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6107 }
6108#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 }while(0);
6110
6111 if(!HAL_STATUS_SUCCESS(status))
6112 {
6113 csrReleaseProfile(pMac, pDstProfile);
6114 pDstProfile = NULL;
6115 }
6116
6117 return (status);
6118}
Jeff Johnson295189b2012-06-20 16:38:30 -07006119eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6120{
6121 eHalStatus status = eHAL_STATUS_SUCCESS;
6122 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6123 do
6124 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306125 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 if(pSrcProfile->bssid)
6127 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306128 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6129 if ( NULL == pDstProfile->BSSIDs.bssid )
6130 status = eHAL_STATUS_FAILURE;
6131 else
6132 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006133 if(!HAL_STATUS_SUCCESS(status))
6134 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306135 smsLog( pMac, LOGE,
6136 FL("failed to allocate memory for BSSID"
6137 "%02x:%02x:%02x:%02x:%02x:%02x"),
6138 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6139 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 break;
6141 }
6142 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306143 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6144 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 }
6146 if(pSrcProfile->SSID.ssId)
6147 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306148 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6149 if ( NULL == pDstProfile->SSIDs.SSIDList )
6150 status = eHAL_STATUS_FAILURE;
6151 else
6152 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 if(!HAL_STATUS_SUCCESS(status))
6154 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306155 smsLog( pMac, LOGE,
6156 FL("failed to allocate memory for SSIDList"
6157 "%02x:%02x:%02x:%02x:%02x:%02x"),
6158 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6159 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006160 break;
6161 }
6162 pDstProfile->SSIDs.numOfSSIDs = 1;
6163 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6164 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306165 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6166 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006167 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006168 if(pSrcProfile->nAddIEAssocLength)
6169 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306170 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6171 if ( NULL == pDstProfile->pAddIEAssoc)
6172 status = eHAL_STATUS_FAILURE;
6173 else
6174 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006175 if(!HAL_STATUS_SUCCESS(status))
6176 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006177 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006178 break;
6179 }
6180 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306181 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6182 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006183 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306184 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6185 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6186 status = eHAL_STATUS_FAILURE;
6187 else
6188 status = eHAL_STATUS_SUCCESS;
6189
Jeff Johnson295189b2012-06-20 16:38:30 -07006190 if(!HAL_STATUS_SUCCESS(status))
6191 {
6192 break;
6193 }
6194 pDstProfile->ChannelInfo.numOfChannels = 1;
6195 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006196 pDstProfile->AuthType.numEntries = 1;
6197 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6198 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6199 pDstProfile->EncryptionType.numEntries = 1;
6200 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6201 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6202 pDstProfile->mcEncryptionType.numEntries = 1;
6203 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6204 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6205 pDstProfile->BSSType = pSrcProfile->BSSType;
6206 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306207 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6208 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006209#ifdef WLAN_FEATURE_VOWIFI_11R
6210 if (pSrcProfile->MDID.mdiePresent)
6211 {
6212 pDstProfile->MDID.mdiePresent = 1;
6213 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6214 }
6215#endif
6216
6217 }while(0);
6218
6219 if(!HAL_STATUS_SUCCESS(status))
6220 {
6221 csrReleaseProfile(pMac, pDstProfile);
6222 pDstProfile = NULL;
6223 }
6224
6225 return (status);
6226}
6227
Jeff Johnson295189b2012-06-20 16:38:30 -07006228eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6229 tScanResultHandle hBSSList,
6230 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6231 tANI_BOOLEAN fClearScan)
6232{
6233 eHalStatus status = eHAL_STATUS_SUCCESS;
6234 tSmeCmd *pCommand;
6235
6236 pCommand = csrGetCommandBuffer(pMac);
6237 if(NULL == pCommand)
6238 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006239 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006240 status = eHAL_STATUS_RESOURCES;
6241 }
6242 else
6243 {
6244 if( fClearScan )
6245 {
6246 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306247 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006248 }
6249 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6250 if(NULL == pProfile)
6251 {
6252 //We can roam now
6253 //Since pProfile is NULL, we need to build our own profile, set everything to default
6254 //We can only support open and no encryption
6255 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6256 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6257 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6258 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6259 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6260 }
6261 else
6262 {
6263 //make a copy of the profile
6264 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6265 if(HAL_STATUS_SUCCESS(status))
6266 {
6267 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6268 }
6269 }
6270 pCommand->command = eSmeCommandRoam;
6271 pCommand->sessionId = (tANI_U8)sessionId;
6272 pCommand->u.roamCmd.hBSSList = hBSSList;
6273 pCommand->u.roamCmd.roamId = roamId;
6274 pCommand->u.roamCmd.roamReason = reason;
6275 //We need to free the BssList when the command is done
6276 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6277 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006278 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6279 FL("CSR PERSONA=%d"),
6280 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006281 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6282 if( !HAL_STATUS_SUCCESS( status ) )
6283 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006284 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 csrReleaseCommandRoam( pMac, pCommand );
6286 }
6287 }
6288
6289 return (status);
6290}
Jeff Johnson295189b2012-06-20 16:38:30 -07006291eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6292 tCsrRoamModifyProfileFields *pMmodProfileFields,
6293 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6294{
6295 eHalStatus status = eHAL_STATUS_SUCCESS;
6296 tSmeCmd *pCommand;
6297
6298 pCommand = csrGetCommandBuffer(pMac);
6299 if(NULL == pCommand)
6300 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006301 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 status = eHAL_STATUS_RESOURCES;
6303 }
6304 else
6305 {
6306 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306307 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006308 if(pProfile)
6309 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006310 //This is likely trying to reassoc to different profile
6311 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6312 //make a copy of the profile
6313 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6314 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006315 }
6316 else
6317 {
6318 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6319 //how to update WPA/WPA2 info in roamProfile??
6320 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006321 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006322 if(HAL_STATUS_SUCCESS(status))
6323 {
6324 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6325 }
6326 pCommand->command = eSmeCommandRoam;
6327 pCommand->sessionId = (tANI_U8)sessionId;
6328 pCommand->u.roamCmd.roamId = roamId;
6329 pCommand->u.roamCmd.roamReason = reason;
6330 //We need to free the BssList when the command is done
6331 //For reassoc there is no BSS list, so the boolean set to false
6332 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6333 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6334 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006335 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6336 if( !HAL_STATUS_SUCCESS( status ) )
6337 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006338 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6340 csrReleaseCommandRoam( pMac, pCommand );
6341 }
6342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 return (status);
6344}
6345
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006346eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6347 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306348// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006349{
6350 eHalStatus status = eHAL_STATUS_SUCCESS;
6351 tSmeCmd *pCommand;
6352
6353 pCommand = csrGetCommandBuffer(pMac);
6354 if(NULL == pCommand)
6355 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006356 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006357 status = eHAL_STATUS_RESOURCES;
6358 }
6359 else
6360 {
6361 if(pBssDescription)
6362 {
6363 //copy over the parameters we need later
6364 pCommand->command = eSmeCommandRoam;
6365 pCommand->sessionId = (tANI_U8)sessionId;
6366 pCommand->u.roamCmd.roamReason = reason;
6367 //this is the important parameter
6368 //in this case we are using this field for the "next" BSS
6369 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6370 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6371 if( !HAL_STATUS_SUCCESS( status ) )
6372 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006373 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006374 csrReleaseCommandPreauth( pMac, pCommand );
6375 }
6376 }
6377 else
6378 {
6379 //Return failure
6380 status = eHAL_STATUS_RESOURCES;
6381 }
6382 }
6383 return (status);
6384}
6385
6386eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6387{
6388 tListElem *pEntry;
6389 tSmeCmd *pCommand;
6390 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6391 if ( pEntry )
6392 {
6393 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6394 if ( (eSmeCommandRoam == pCommand->command) &&
6395 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6396 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006397 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006398 pCommand->command, pCommand->u.roamCmd.roamReason);
6399 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6400 csrReleaseCommandPreauth( pMac, pCommand );
6401 }
6402 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006403 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006404 pCommand->command, pCommand->u.roamCmd.roamReason);
6405 }
6406 }
6407 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006408 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006409 }
6410 smeProcessPendingQueue( pMac );
6411 return eHAL_STATUS_SUCCESS;
6412}
6413
Jeff Johnson295189b2012-06-20 16:38:30 -07006414eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6415 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6416{
6417 eHalStatus status = eHAL_STATUS_FAILURE;
6418 tScanResultHandle hBSSList;
6419 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006420 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6421 if(HAL_STATUS_SUCCESS(status))
6422 {
6423 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6424 if(pRoamId)
6425 {
6426 *pRoamId = roamId;
6427 }
6428 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6429 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6430 if(!HAL_STATUS_SUCCESS(status))
6431 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006432 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006433 csrScanResultPurge(pMac, hBSSList);
6434 }
6435 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006436 return (status);
6437}
6438
Jeff Johnson295189b2012-06-20 16:38:30 -07006439eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6440 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6441{
6442 eHalStatus status = eHAL_STATUS_SUCCESS;
6443 tScanResultHandle hBSSList;
6444 tCsrScanResultFilter *pScanFilter;
6445 tANI_U32 roamId = 0;
6446 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6447 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006448 if (NULL == pProfile)
6449 {
6450 smsLog(pMac, LOGP, FL("No profile specified"));
6451 return eHAL_STATUS_FAILURE;
6452 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006453 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006455 if( CSR_IS_WDS( pProfile ) &&
6456 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6457 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006458 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006459 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006460 return status;
6461 }
6462 csrRoamCancelRoaming(pMac, sessionId);
6463 csrScanRemoveFreshScanCommand(pMac, sessionId);
6464 csrScanCancelIdleScan(pMac);
6465 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306466 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006467 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6468 {
6469 csrScanDisable(pMac);
6470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006471 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6472 //Check whether ssid changes
6473 if(csrIsConnStateConnected(pMac, sessionId))
6474 {
6475 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6476 {
6477 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6478 }
6479 }
6480#ifdef FEATURE_WLAN_BTAMP_UT_RF
6481 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6482#endif
6483 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6484 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006485 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6487 if(pRoamId)
6488 {
6489 roamId = *pRoamId;
6490 }
6491 if(!HAL_STATUS_SUCCESS(status))
6492 {
6493 fCallCallback = eANI_BOOLEAN_TRUE;
6494 }
6495 }
6496 else
6497 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306498 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6499 if ( NULL == pScanFilter )
6500 status = eHAL_STATUS_FAILURE;
6501 else
6502 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006503 if(HAL_STATUS_SUCCESS(status))
6504 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306505 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006506 //Try to connect to any BSS
6507 if(NULL == pProfile)
6508 {
6509 //No encryption
6510 pScanFilter->EncryptionType.numEntries = 1;
6511 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6512 }//we don't have a profile
6513 else
6514 {
6515 //Here is the profile we need to connect to
6516 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6517 }//We have a profile
6518 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6519 if(pRoamId)
6520 {
6521 *pRoamId = roamId;
6522 }
6523
6524 if(HAL_STATUS_SUCCESS(status))
6525 {
6526 /*Save the WPS info*/
6527 if(NULL != pProfile)
6528 {
6529 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6530 }
6531 else
6532 {
6533 pScanFilter->bWPSAssociation = 0;
6534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006535 do
6536 {
6537 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006538 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006539 )
6540 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006541 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006542 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6543 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6544 if(!HAL_STATUS_SUCCESS(status))
6545 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006546 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006547 fCallCallback = eANI_BOOLEAN_TRUE;
6548 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006549 else
6550 {
6551 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6552 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006553 break;
6554 }
6555 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006556 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006557 if(HAL_STATUS_SUCCESS(status))
6558 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006559 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(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006564 csrScanResultPurge(pMac, hBSSList);
6565 fCallCallback = eANI_BOOLEAN_TRUE;
6566 }
6567 }//Have scan result
6568 else if(NULL != pProfile)
6569 {
6570 //Check whether it is for start ibss
6571 if(CSR_IS_START_IBSS(pProfile))
6572 {
6573 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6574 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6575 if(!HAL_STATUS_SUCCESS(status))
6576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006577 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006578 fCallCallback = eANI_BOOLEAN_TRUE;
6579 }
6580 }
6581 else
6582 {
6583 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006584 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006585 if(!HAL_STATUS_SUCCESS(status))
6586 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006587 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 fCallCallback = eANI_BOOLEAN_TRUE;
6589 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006590 else
6591 {
6592 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6593 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006594 }
6595 }
6596 else
6597 {
6598 fCallCallback = eANI_BOOLEAN_TRUE;
6599 }
6600 } while (0);
6601 if(NULL != pProfile)
6602 {
6603 //we need to free memory for filter if profile exists
6604 csrFreeScanFilter(pMac, pScanFilter);
6605 }
6606 }//Got the scan filter from profile
6607
Kiet Lam64c1b492013-07-12 13:56:44 +05306608 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 }//allocated memory for pScanFilter
6610 }//No Bsslist coming in
6611 //tell the caller if we fail to trigger a join request
6612 if( fCallCallback )
6613 {
6614 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6615 }
6616
6617 return (status);
6618}
Jeff Johnson295189b2012-06-20 16:38:30 -07006619eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6620 tCsrRoamModifyProfileFields modProfileFields,
6621 tANI_U32 *pRoamId)
6622{
6623 eHalStatus status = eHAL_STATUS_SUCCESS;
6624 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6625 tANI_U32 roamId = 0;
6626 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006627 if (NULL == pProfile)
6628 {
6629 smsLog(pMac, LOGP, FL("No profile specified"));
6630 return eHAL_STATUS_FAILURE;
6631 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006632 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"), pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006633 csrRoamCancelRoaming(pMac, sessionId);
6634 csrScanRemoveFreshScanCommand(pMac, sessionId);
6635 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306636 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006637 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006638 if(csrIsConnStateConnected(pMac, sessionId))
6639 {
6640 if(pProfile)
6641 {
6642 if(pProfile->SSIDs.numOfSSIDs &&
6643 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6644 {
6645 fCallCallback = eANI_BOOLEAN_FALSE;
6646 }
6647 else
6648 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006649 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006650 }
6651 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306652 else if (!vos_mem_compare(&modProfileFields,
6653 &pSession->connectedProfile.modifyProfileFields,
6654 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 {
6656 fCallCallback = eANI_BOOLEAN_FALSE;
6657 }
6658 else
6659 {
6660 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006661 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 }
6663 }
6664 else
6665 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006666 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006668 if(!fCallCallback)
6669 {
6670 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6671 if(pRoamId)
6672 {
6673 *pRoamId = roamId;
6674 }
6675
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6677 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006678 }
6679 else
6680 {
6681 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6682 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006684 return status;
6685}
Jeff Johnson295189b2012-06-20 16:38:30 -07006686eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6687{
6688 eHalStatus status = eHAL_STATUS_FAILURE;
6689 tScanResultHandle hBSSList = NULL;
6690 tCsrScanResultFilter *pScanFilter = NULL;
6691 tANI_U32 roamId;
6692 tCsrRoamProfile *pProfile = NULL;
6693 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006694
6695 if(!pSession)
6696 {
6697 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6698 return eHAL_STATUS_FAILURE;
6699 }
6700
Jeff Johnson295189b2012-06-20 16:38:30 -07006701 do
6702 {
6703 if(pSession->pCurRoamProfile)
6704 {
6705 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306706 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006707 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306708 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6709 if ( NULL == pProfile )
6710 status = eHAL_STATUS_FAILURE;
6711 else
6712 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006713 if(!HAL_STATUS_SUCCESS(status))
6714 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306715 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006716 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306717 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306719 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6720 if ( NULL == pScanFilter )
6721 status = eHAL_STATUS_FAILURE;
6722 else
6723 status = eHAL_STATUS_SUCCESS;
6724
Jeff Johnson295189b2012-06-20 16:38:30 -07006725 if(!HAL_STATUS_SUCCESS(status))
6726 {
6727 break;
6728 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306729 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6731 if(!HAL_STATUS_SUCCESS(status))
6732 {
6733 break;
6734 }
6735 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6736 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6737 if(HAL_STATUS_SUCCESS(status))
6738 {
6739 //we want to put the last connected BSS to the very beginning, if possible
6740 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6741 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6742 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6743 if(!HAL_STATUS_SUCCESS(status))
6744 {
6745 csrScanResultPurge(pMac, hBSSList);
6746 break;
6747 }
6748 }
6749 else
6750 {
6751 //Do a scan on this profile
6752 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006753 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006754 if(!HAL_STATUS_SUCCESS(status))
6755 {
6756 break;
6757 }
6758 }
6759 }//We have a profile
6760 else
6761 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006762 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006763 break;
6764 }
6765 }while(0);
6766 if(pScanFilter)
6767 {
6768 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306769 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006770 }
6771 if(NULL != pProfile)
6772 {
6773 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306774 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006775 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006776 return (status);
6777}
Jeff Johnson295189b2012-06-20 16:38:30 -07006778eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6779{
6780 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006781 if(csrIsConnStateConnected(pMac, sessionId))
6782 {
6783 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6784 if(HAL_STATUS_SUCCESS(status))
6785 {
6786 status = csrRoamJoinLastProfile(pMac, sessionId);
6787 }
6788 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006789 return (status);
6790}
6791
Jeff Johnson295189b2012-06-20 16:38:30 -07006792eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6793{
6794 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006795 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006796 csrRoamCancelRoaming(pMac, sessionId);
6797 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6798 if(csrIsConnStateDisconnected(pMac, sessionId))
6799 {
6800 status = csrRoamJoinLastProfile(pMac, sessionId);
6801 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006802 return (status);
6803}
6804
Jeff Johnson295189b2012-06-20 16:38:30 -07006805eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6806{
6807 eHalStatus status = eHAL_STATUS_SUCCESS;
6808 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6809 eCsrRoamSubState NewSubstate;
6810 tANI_U32 sessionId = pCommand->sessionId;
6811
6812 // change state to 'Roaming'...
6813 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6814
6815 if ( csrIsConnStateIbss( pMac, sessionId ) )
6816 {
6817 // If we are in an IBSS, then stop the IBSS...
6818 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6819 fComplete = (!HAL_STATUS_SUCCESS(status));
6820 }
6821 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6822 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006823 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 -07006824 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6825 //Restore AC weight in case we change it
6826 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6827 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6828 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6829 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6830 {
6831 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6832 }
6833 if( fDisassoc )
6834 {
6835 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6836 }
6837 else
6838 {
6839 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6840 }
6841 fComplete = (!HAL_STATUS_SUCCESS(status));
6842 }
6843 else if ( csrIsConnStateWds( pMac, sessionId ) )
6844 {
6845 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6846 {
6847 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6848 fComplete = (!HAL_STATUS_SUCCESS(status));
6849 }
6850 //This has to be WDS station
6851 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6852 {
6853
6854 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6855 if( fDisassoc )
6856 {
6857 status = csrRoamIssueDisassociate( pMac, sessionId,
6858 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6859 fComplete = (!HAL_STATUS_SUCCESS(status));
6860 }
6861 }
6862 } else {
6863 // we got a dis-assoc request while not connected to any peer
6864 // just complete the command
6865 fComplete = eANI_BOOLEAN_TRUE;
6866 status = eHAL_STATUS_FAILURE;
6867 }
6868 if(fComplete)
6869 {
6870 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6871 }
6872
6873 if(HAL_STATUS_SUCCESS(status))
6874 {
6875 if ( csrIsConnStateInfra( pMac, sessionId ) )
6876 {
6877 //Set the state to disconnect here
6878 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6879 }
6880 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006881 else
6882 {
6883 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6884 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006885 return (status);
6886}
6887
Jeff Johnson295189b2012-06-20 16:38:30 -07006888/* This is been removed from latest code base */
6889/*
6890static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6891{
6892 eHalStatus status;
6893 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006894 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6895 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006896 return ( status );
6897}
6898*/
6899
Jeff Johnson295189b2012-06-20 16:38:30 -07006900eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6901{
6902 eHalStatus status = eHAL_STATUS_SUCCESS;
6903 tSmeCmd *pCommand;
6904 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006905 do
6906 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006907 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006908 pCommand = csrGetCommandBuffer( pMac );
6909 if ( !pCommand )
6910 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006911 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006912 status = eHAL_STATUS_RESOURCES;
6913 break;
6914 }
6915 //Change the substate in case it is wait-for-key
6916 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6917 {
6918 csrRoamStopWaitForKeyTimer( pMac );
6919 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6920 }
6921 pCommand->command = eSmeCommandRoam;
6922 pCommand->sessionId = (tANI_U8)sessionId;
6923 switch ( reason )
6924 {
6925 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6926 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6927 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006928 case eCSR_DISCONNECT_REASON_DEAUTH:
6929 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6930 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006931 case eCSR_DISCONNECT_REASON_HANDOFF:
6932 fHighPriority = eANI_BOOLEAN_TRUE;
6933 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6934 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006935 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6936 case eCSR_DISCONNECT_REASON_DISASSOC:
6937 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6938 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006939 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6940 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6941 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006942 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6943 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6944 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006945 default:
6946 break;
6947 }
6948 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6949 if( !HAL_STATUS_SUCCESS( status ) )
6950 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006951 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006952 csrReleaseCommandRoam( pMac, pCommand );
6953 }
6954 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006955 return( status );
6956}
6957
Jeff Johnson295189b2012-06-20 16:38:30 -07006958eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6959{
6960 eHalStatus status = eHAL_STATUS_SUCCESS;
6961 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006962 pCommand = csrGetCommandBuffer( pMac );
6963 if ( NULL != pCommand )
6964 {
6965 //Change the substate in case it is wait-for-key
6966 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6967 {
6968 csrRoamStopWaitForKeyTimer( pMac );
6969 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6970 }
6971 pCommand->command = eSmeCommandRoam;
6972 pCommand->sessionId = (tANI_U8)sessionId;
6973 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6974 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6975 if( !HAL_STATUS_SUCCESS( status ) )
6976 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006977 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006978 csrReleaseCommandRoam( pMac, pCommand );
6979 }
6980 }
6981 else
6982 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006983 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006984 status = eHAL_STATUS_RESOURCES;
6985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006986 return ( status );
6987}
6988
Jeff Johnson295189b2012-06-20 16:38:30 -07006989eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
6990{
6991 eHalStatus status = eHAL_STATUS_SUCCESS;
6992 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006993
6994 if(!pSession)
6995 {
6996 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6997 return eHAL_STATUS_FAILURE;
6998 }
6999
Jeff Johnson295189b2012-06-20 16:38:30 -07007000#ifdef FEATURE_WLAN_BTAMP_UT_RF
7001 //Stop te retry
7002 pSession->maxRetryCount = 0;
7003 csrRoamStopJoinRetryTimer(pMac, sessionId);
7004#endif
7005 //Not to call cancel roaming here
7006 //Only issue disconnect when necessary
7007 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7008 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7009 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7010
7011 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007012 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007013 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7014 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307015 else
7016 {
7017 smsLog( pMac, LOGE, FL("Roam command is not present"));
7018 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007019 return (status);
7020}
7021
Jeff Johnson295189b2012-06-20 16:38:30 -07007022eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7023{
7024 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007025
7026 if(!pSession)
7027 {
7028 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7029 return eHAL_STATUS_FAILURE;
7030 }
7031
Jeff Johnson295189b2012-06-20 16:38:30 -07007032 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007033 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7034
7035 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7036}
7037
Jeff Johnson295189b2012-06-20 16:38:30 -07007038eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7039 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7040{
7041 eHalStatus status = eHAL_STATUS_SUCCESS;
7042 tDot11fBeaconIEs *pIesTemp = pIes;
7043 tANI_U8 index;
7044 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7045 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007046
7047 if(!pSession)
7048 {
7049 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7050 return eHAL_STATUS_FAILURE;
7051 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007052 if(pConnectProfile->pAddIEAssoc)
7053 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307054 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007055 pConnectProfile->pAddIEAssoc = NULL;
7056 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307057 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007058 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7059 pConnectProfile->AuthInfo = pProfile->AuthType;
7060 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7061 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7062 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7063 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7064 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7065 pConnectProfile->BSSType = pProfile->BSSType;
7066 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7067 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007068 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
7069
Kiet Lam64c1b492013-07-12 13:56:44 +05307070 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007071 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7072 if(pProfile->nAddIEAssocLength)
7073 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307074 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7075 if ( NULL == pConnectProfile->pAddIEAssoc )
7076 status = eHAL_STATUS_FAILURE;
7077 else
7078 status = eHAL_STATUS_SUCCESS;
7079 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007080 {
7081 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7082 return eHAL_STATUS_FAILURE;
7083 }
7084 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307085 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7086 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007087 }
7088
Jeff Johnson295189b2012-06-20 16:38:30 -07007089 //Save bssid
7090 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7091#ifdef WLAN_FEATURE_VOWIFI_11R
7092 if (pSirBssDesc->mdiePresent)
7093 {
7094 pConnectProfile->MDID.mdiePresent = 1;
7095 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7096 }
7097#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007098 if( NULL == pIesTemp )
7099 {
7100 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007102#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007103 if ((csrIsProfileCCX(pProfile) ||
7104 ((pIesTemp->CCXVersion.present)
7105 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7106 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7107 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7108 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07007109#ifdef WLAN_FEATURE_11W
7110 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
7111#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05307112 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007113 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007114 {
7115 pConnectProfile->isCCXAssoc = 1;
7116 }
7117#endif
7118 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007119 if(HAL_STATUS_SUCCESS(status))
7120 {
7121 if(pIesTemp->SSID.present)
7122 {
7123 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307124 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7125 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007126 }
7127
7128 //Save the bss desc
7129 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307130
7131 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007132 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307133 //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 -07007134 pConnectProfile->qap = TRUE;
7135 }
7136 else
7137 {
7138 pConnectProfile->qap = FALSE;
7139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007140 if ( NULL == pIes )
7141 {
7142 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307143 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007144 }
7145 }
7146 //Save Qos connection
7147 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7148
7149 if(!HAL_STATUS_SUCCESS(status))
7150 {
7151 csrFreeConnectBssDesc(pMac, sessionId);
7152 }
7153 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7154 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307155 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7156 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7157 pConnectProfile->SSID.ssId,
7158 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007159 {
7160 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7161 break;
7162 }
7163 pConnectProfile->handoffPermitted = FALSE;
7164 }
7165
7166 return (status);
7167}
7168
Jeff Johnson295189b2012-06-20 16:38:30 -07007169static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7170{
7171 tListElem *pEntry = NULL;
7172 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007173 //The head of the active list is the request we sent
7174 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7175 if(pEntry)
7176 {
7177 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007179 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7180 {
7181 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7182 {
7183#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7184 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7185#endif
7186 }
7187 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7188 }
7189 else
7190 {
7191 tANI_U32 roamId = 0;
7192 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007193 if(!pSession)
7194 {
7195 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7196 return;
7197 }
7198
Jeff Johnson295189b2012-06-20 16:38:30 -07007199
7200 //The head of the active list is the request we sent
7201 //Try to get back the same profile and roam again
7202 if(pCommand)
7203 {
7204 roamId = pCommand->u.roamCmd.roamId;
7205 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007206 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7207 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007208 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007209#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7210 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7211 if (csrRoamIsHandoffInProgress(pMac))
7212 {
7213 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7214 /* Should indicate neighbor roam algorithm about the connect failure here */
7215 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7216 }
7217#endif
7218 if (pCommand)
7219 {
7220 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7221 {
7222 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7223 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7224 csrRoamReissueRoamCommand(pMac);
7225 }
7226 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7227 {
7228 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7229 }
7230 else
7231 {
7232 csrRoam(pMac, pCommand);
7233 }
7234 }
7235 else
7236 {
7237 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7238 }
7239 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7240}
7241
Jeff Johnson295189b2012-06-20 16:38:30 -07007242eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7243 tDot11fBeaconIEs *pIes,
7244 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7245{
7246 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007247 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7248 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007249
7250 // Set the roaming substate to 'join attempt'...
7251 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007252 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007253 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007254 return (status);
7255}
7256
Jeff Johnson295189b2012-06-20 16:38:30 -07007257static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7258 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7259{
7260 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007261 // Set the roaming substate to 'join attempt'...
7262 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7263
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307264 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7265 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007266
7267 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007268 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007269}
7270
Jeff Johnson295189b2012-06-20 16:38:30 -07007271void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7272{
7273 tListElem *pEntry;
7274 tSmeCmd *pCommand;
7275 tCsrRoamInfo roamInfo;
7276 tANI_U32 sessionId;
7277 tCsrRoamSession *pSession;
7278
7279 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7280 if(pEntry)
7281 {
7282 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7283 if ( eSmeCommandRoam == pCommand->command )
7284 {
7285 sessionId = pCommand->sessionId;
7286 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007287
7288 if(!pSession)
7289 {
7290 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7291 return;
7292 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307293 /* While switching between two AP, csr will reissue roam command again
7294 to the nextbss if it was interrupted by the dissconnect req for the
7295 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7296 so reset the bRefAssocStartCnt.
7297 */
7298 if(pSession->bRefAssocStartCnt > 0)
7299 {
7300 pSession->bRefAssocStartCnt--;
7301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007302 if( pCommand->u.roamCmd.fStopWds )
7303 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307304 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007305 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7306 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7307 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007308 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007309 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7310 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7311 eCSR_ROAM_WDS_IND,
7312 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007313 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7314 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7315 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7316 eCSR_ROAM_INFRA_IND,
7317 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7318 }
7319
Jeff Johnson295189b2012-06-20 16:38:30 -07007320
Jeff Johnson295189b2012-06-20 16:38:30 -07007321 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7322 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007323 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007324 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7325 }
7326 }
7327 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7328 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007329 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007330 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7331 }
7332 }
7333 else
7334 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007335 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 }
7337 }
7338 else
7339 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007340 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007341 }
7342}
7343
Jeff Johnson295189b2012-06-20 16:38:30 -07007344tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7345{
7346 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7347 tListElem *pEntry;
7348 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007349 //alwasy lock active list before locking pending list
7350 csrLLLock( &pMac->sme.smeCmdActiveList );
7351 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7352 if(pEntry)
7353 {
7354 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7355 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7356 {
7357 fRet = eANI_BOOLEAN_TRUE;
7358 }
7359 }
7360 if(eANI_BOOLEAN_FALSE == fRet)
7361 {
7362 csrLLLock(&pMac->sme.smeCmdPendingList);
7363 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7364 while(pEntry)
7365 {
7366 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7367 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7368 {
7369 fRet = eANI_BOOLEAN_TRUE;
7370 break;
7371 }
7372 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7373 }
7374 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7375 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307376 if (eANI_BOOLEAN_FALSE == fRet)
7377 {
7378 csrLLLock(&pMac->roam.roamCmdPendingList);
7379 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7380 while (pEntry)
7381 {
7382 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7383 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7384 {
7385 fRet = eANI_BOOLEAN_TRUE;
7386 break;
7387 }
7388 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7389 }
7390 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7391 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007392 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007393 return (fRet);
7394}
7395
Jeff Johnson295189b2012-06-20 16:38:30 -07007396tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7397{
7398 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7399 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007400 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7401 {
7402 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7403 {
7404 break;
7405 }
7406 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007407 return ( fRet );
7408}
7409
Jeff Johnson295189b2012-06-20 16:38:30 -07007410tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7411{
7412 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007413 //alwasy lock active list before locking pending list
7414 csrLLLock( &pMac->sme.smeCmdActiveList );
7415 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7416 if(eANI_BOOLEAN_FALSE == fRet)
7417 {
7418 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7419 }
7420 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007421 return (fRet);
7422}
7423
Jeff Johnson295189b2012-06-20 16:38:30 -07007424tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7425{
7426 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7427 tListElem *pEntry;
7428 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007429 //alwasy lock active list before locking pending list
7430 csrLLLock( &pMac->sme.smeCmdActiveList );
7431 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7432 if( pEntry )
7433 {
7434 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7435 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7436 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7437 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7438 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7439 {
7440 fRet = eANI_BOOLEAN_TRUE;
7441 }
7442 }
7443 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007444 return (fRet);
7445}
Jeff Johnson295189b2012-06-20 16:38:30 -07007446eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7447{
7448 eHalStatus status = eHAL_STATUS_SUCCESS;
7449 tSmeCmd *pCommand = NULL;
7450 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7451 tANI_BOOLEAN fRemoveCmd = FALSE;
7452 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007453 // Delete the old assoc command. All is setup for reassoc to be serialized
7454 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7455 if ( pEntry )
7456 {
7457 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7458 if ( !pCommand )
7459 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007460 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007461 return eHAL_STATUS_RESOURCES;
7462 }
7463 if ( eSmeCommandRoam == pCommand->command )
7464 {
7465 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7466 {
7467 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7468 }
7469 else
7470 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007471 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007472 }
7473 if (fRemoveCmd == FALSE)
7474 {
7475 // Implies we did not get the serialized assoc command we
7476 // were expecting
7477 pCommand = NULL;
7478 }
7479 }
7480 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007481 if(NULL == pCommand)
7482 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007483 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007484 return eHAL_STATUS_RESOURCES;
7485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 do
7487 {
7488 //Change the substate in case it is wait-for-key
7489 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7490 {
7491 csrRoamStopWaitForKeyTimer( pMac );
7492 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7493 }
7494 pCommand->command = eSmeCommandRoam;
7495 pCommand->sessionId = (tANI_U8)sessionId;
7496 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7498 if( !HAL_STATUS_SUCCESS( status ) )
7499 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007500 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007501 csrReleaseCommandRoam( pMac, pCommand );
7502 }
7503 } while( 0 );
7504
Jeff Johnson295189b2012-06-20 16:38:30 -07007505 return( status );
7506}
7507static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7508{
7509 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7510 tCsrScanResult *pScanResult = NULL;
7511 tSirBssDescription *pBssDesc = NULL;
7512 tSmeCmd *pCommand = NULL;
7513 tANI_U32 sessionId;
7514 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007515 if(NULL == pEntry)
7516 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307517 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007518 return;
7519 }
7520 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7521 sessionId = pCommand->sessionId;
7522 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007523
7524 if(!pSession)
7525 {
7526 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7527 return;
7528 }
7529
Jeff Johnson295189b2012-06-20 16:38:30 -07007530 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7531 {
7532 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007533 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007534 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7535 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007536 /* If the roaming has stopped, not to continue the roaming command*/
7537 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7538 {
7539 //No need to complete roaming here as it already completes
7540 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7541 pCommand->u.roamCmd.roamReason);
7542 csrSetAbortRoamingCommand( pMac, pCommand );
7543 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007545 else
7546 {
7547 if ( CCM_IS_RESULT_SUCCESS(result) )
7548 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007549 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007550 // Successfully set the configuration parameters for the new Bss. Attempt to
7551 // join the roaming Bss.
7552 if(pCommand->u.roamCmd.pRoamBssEntry)
7553 {
7554 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7555 pBssDesc = &pScanResult->Result.BssDescriptor;
7556 }
7557 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7558 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007559 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007560 )
7561 {
7562 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7563 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7564 pBssDesc, pCommand->u.roamCmd.roamId )))
7565 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307566 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007567 //We need to complete the command
7568 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7569 }
7570 }
7571 else
7572 {
7573 if (!pCommand->u.roamCmd.pRoamBssEntry)
7574 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307575 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007576 //We need to complete the command
7577 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7578 return;
7579 }
7580 // If we are roaming TO an Infrastructure BSS...
7581 VOS_ASSERT(pScanResult != NULL);
7582 if ( csrIsInfraBssDesc( pBssDesc ) )
7583 {
7584 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007585 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7586 {
7587 // ..and currently in an Infrastructure connection....
7588 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7589 {
7590 // ...and the SSIDs are equal, then we Reassoc.
7591 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7592 pIesLocal ) )
7593 // ..and currently in an infrastructure connection
7594 {
7595 // then issue a Reassoc.
7596 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7597 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7598 &pCommand->u.roamCmd.roamProfile );
7599 }
7600 else
7601 {
7602
7603 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7604 // previously associated AP.
7605 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7606 pIesLocal,
7607 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7608 {
7609 //try something else
7610 csrRoam( pMac, pCommand );
7611 }
7612 }
7613 }
7614 else
7615 {
7616 eHalStatus status = eHAL_STATUS_SUCCESS;
7617
7618 /* We need to come with other way to figure out that this is because of HO in BMP
7619 The below API will be only available for Android as it uses a different HO algorithm */
7620 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7621 * use join request */
7622#ifdef WLAN_FEATURE_VOWIFI_11R
7623 if (csrRoamIsHandoffInProgress(pMac) &&
7624 csrRoamIs11rAssoc(pMac))
7625 {
7626 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7627 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7628 }
7629 else
7630#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007631#ifdef FEATURE_WLAN_CCX
7632 if (csrRoamIsHandoffInProgress(pMac) &&
7633 csrRoamIsCCXAssoc(pMac))
7634 {
7635 // Now serialize the reassoc command.
7636 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7637 }
7638 else
7639#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007640#ifdef FEATURE_WLAN_LFR
7641 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307642 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007643 {
7644 // Now serialize the reassoc command.
7645 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7646 }
7647 else
7648#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007649 // else we are not connected and attempting to Join. Issue the
7650 // Join request.
7651 {
7652 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7653 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7654 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7655 }
7656 if(!HAL_STATUS_SUCCESS(status))
7657 {
7658 //try something else
7659 csrRoam( pMac, pCommand );
7660 }
7661 }
7662 if( !pScanResult->Result.pvIes )
7663 {
7664 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307665 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007666 }
7667 }
7668 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7669 else
7670 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007671 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007672 }
7673 }//else
7674 }//if ( WNI_CFG_SUCCESS == result )
7675 else
7676 {
7677 // In the event the configuration failed, for infra let the roam processor
7678 //attempt to join something else...
7679 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7680 {
7681 csrRoam(pMac, pCommand);
7682 }
7683 else
7684 {
7685 //We need to complete the command
7686 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7687 {
7688 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7689 }
7690 else
7691 {
7692 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7693 }
7694 }
7695 }
7696 }//we have active entry
7697}
7698
Jeff Johnson295189b2012-06-20 16:38:30 -07007699static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7700{
7701 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007702 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007703 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007705 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007706 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7707 // join the new one...
7708 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7710 }
7711 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007712 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007713 /***profHandleLostLinkAfterReset(pAdapter);
7714 // In the event the authenticate fails, let the roam processor attempt to join something else...
7715 roamRoam( pAdapter );***/
7716 }
7717}
7718
Jeff Johnson295189b2012-06-20 16:38:30 -07007719static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7720{
7721 eCsrRoamCompleteResult result;
7722 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7723 tCsrRoamInfo roamInfo;
7724 tANI_U32 roamId = 0;
7725
7726 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7727 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007728 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007729 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007730 /* Defeaturize this part later if needed */
7731#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7732 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7733 * we need the response contents while processing the result in csrRoamProcessResults() */
7734 if (csrRoamIsHandoffInProgress(pMac))
7735 {
7736 /* Need to dig more on indicating events to SME QoS module */
7737 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7738 csrRoamComplete( pMac, result, pSmeJoinRsp);
7739 }
7740 else
7741#endif
7742 {
7743 csrRoamComplete( pMac, result, NULL );
7744 }
7745 }
7746 /* Should we handle this similar to handling the join failure? Is it ok
7747 * to call csrRoamComplete() with state as CsrJoinFailure */
7748 else
7749 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007750 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007751 result = eCsrReassocFailure;
7752#ifdef WLAN_FEATURE_VOWIFI_11R
7753 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7754 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7755 {
7756 // Inform HDD to turn off FT flag in HDD
7757 if (pNeighborRoamInfo)
7758 {
7759 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7760 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7761 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007762 /*
7763 * Since the above callback sends a disconnect
7764 * to HDD, we should clean-up our state
7765 * machine as well to be in sync with the upper
7766 * layers. There is no need to send a disassoc
7767 * since: 1) we will never reassoc to the current
7768 * AP in LFR, and 2) there is no need to issue a
7769 * disassoc to the AP with which we were trying
7770 * to reassoc.
7771 */
7772 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7773 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007774 }
7775 }
7776#endif
7777 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7778 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7779 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7780 //The disassoc rsp message will remove the command from active list
7781 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7782 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7783 {
7784 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7785 }
7786 }
7787}
7788
Jeff Johnson295189b2012-06-20 16:38:30 -07007789static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7790{
Jeff Johnson295189b2012-06-20 16:38:30 -07007791#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7792 {
7793 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007794 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7795 if(pIbssLog)
7796 {
7797 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7798 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7799 {
7800 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7801 }
7802 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7803 }
7804 }
7805#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007806 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7807 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7808 {
7809 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7810 }
7811 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7812 {
7813 csrRoamReissueRoamCommand(pMac);
7814 }
7815}
7816
Jeff Johnson295189b2012-06-20 16:38:30 -07007817void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7818{
7819 tSirResultCodes statusCode;
7820#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7821 tScanResultHandle hBSSList;
7822 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7823 eHalStatus status;
7824 tCsrRoamInfo roamInfo;
7825 tCsrScanResultFilter *pScanFilter = NULL;
7826 tANI_U32 roamId = 0;
7827 tCsrRoamProfile *pCurRoamProfile = NULL;
7828 tListElem *pEntry = NULL;
7829 tSmeCmd *pCommand = NULL;
7830#endif
7831 tANI_U32 sessionId;
7832 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007833
Jeff Johnson295189b2012-06-20 16:38:30 -07007834 tSirSmeDisassocRsp SmeDisassocRsp;
7835
7836 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7837 sessionId = SmeDisassocRsp.sessionId;
7838 statusCode = SmeDisassocRsp.statusCode;
7839
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007840 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007841
7842 if ( csrIsConnStateInfra( pMac, sessionId ) )
7843 {
7844 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7845 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007846 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007847
7848 if(!pSession)
7849 {
7850 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7851 return;
7852 }
7853
Jeff Johnson295189b2012-06-20 16:38:30 -07007854 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7855 {
7856 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7857 }
7858 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7859 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7860 {
7861 if ( eSIR_SME_SUCCESS == statusCode )
7862 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007863 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007864 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7865 }
7866 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7867 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007868 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7869 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307870 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
7871 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007872#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007873 /*
7874 * First ensure if the roam profile is in the scan cache.
7875 * If not, post a reassoc failure and disconnect.
7876 */
Kiet Lam64c1b492013-07-12 13:56:44 +05307877 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7878 if ( NULL == pScanFilter )
7879 status = eHAL_STATUS_FAILURE;
7880 else
7881 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007882 if(HAL_STATUS_SUCCESS(status))
7883 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307884 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007885 status = csrRoamPrepareFilterFromProfile(pMac,
7886 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7887 if(!HAL_STATUS_SUCCESS(status))
7888 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007889 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007890 __func__, status);
7891 goto POST_ROAM_FAILURE;
7892 }
7893 else
7894 {
7895 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7896 if (!HAL_STATUS_SUCCESS(status))
7897 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007898 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007899 __func__, status);
7900 goto POST_ROAM_FAILURE;
7901 }
7902 }
7903 }
7904 else
7905 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007906 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007907 __func__, status);
7908 goto POST_ROAM_FAILURE;
7909 }
7910
7911 /*
7912 * After ensuring that the roam profile is in the scan result list,
7913 * dequeue the command from the active list.
7914 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007915 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7916 if ( pEntry )
7917 {
7918 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007919 /* If the head of the queue is Active and it is a ROAM command, remove
7920 * and put this on the Free queue.
7921 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007922 if ( eSmeCommandRoam == pCommand->command )
7923 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007924
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007925 /*
7926 * we need to process the result first before removing it from active list
7927 * because state changes still happening insides roamQProcessRoamResults so
7928 * no other roam command should be issued.
7929 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007930 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7931 if(pCommand->u.roamCmd.fReleaseProfile)
7932 {
7933 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7934 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7935 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007936 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007937 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007938 else
7939 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007940 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007941 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007942 }
7943 }
7944 else
7945 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007946 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007947 }
7948 }
7949 else
7950 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007951 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007952 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007953
7954 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007955 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7956
Kiet Lam64c1b492013-07-12 13:56:44 +05307957 vos_mem_copy(roamInfo.bssid,
7958 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7959 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007960
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007961 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7962 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007963
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007964 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05307965 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7966 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07007967 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307968 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007969 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7970 //make sure to put it at the head of the cmd queue
7971 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7972 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7973 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7974
Jeff Johnson295189b2012-06-20 16:38:30 -07007975 if(!HAL_STATUS_SUCCESS(status))
7976 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007977 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007978 __func__, status);
7979 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007980 }
7981
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007982 /* Notify sub-modules like QoS etc. that handoff happening */
7983 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007984 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307985 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007986 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307987 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007988 return;
7989 }
7990
7991POST_ROAM_FAILURE:
7992 if (pScanFilter)
7993 {
7994 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307995 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007996 }
7997 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05307998 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007999
8000 /* Inform the upper layers that the reassoc failed */
8001 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8002 csrRoamCallCallback(pMac, sessionId,
8003 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8004
8005 /*
8006 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8007 * Upon success, we would re-enter this routine after receiving the disassoc
8008 * response and will fall into the reassoc fail sub-state. And, eventually
8009 * call csrRoamComplete which would remove the roam command from SME active
8010 * queue.
8011 */
8012 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8013 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8014 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008015 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008016 __func__, status);
8017 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008018 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008019#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008020
Jeff Johnson295189b2012-06-20 16:38:30 -07008021 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8022 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8023 {
8024 // Disassoc due to Reassoc failure falls into this codepath....
8025 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8026 }
8027 else
8028 {
8029 if ( eSIR_SME_SUCCESS == statusCode )
8030 {
8031 // Successfully disassociated from the 'old' Bss...
8032 //
8033 // We get Disassociate response in three conditions.
8034 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8035 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8036 // Infrastructure network.
8037 // - Third is where we are doing an Infra to Infra roam between networks with different
8038 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8039
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008040 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 }
8042 else
8043 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008044 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008045 }
8046 //We are not done yet. Get the data and continue roaming
8047 csrRoamReissueRoamCommand(pMac);
8048 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008049}
8050
Jeff Johnson295189b2012-06-20 16:38:30 -07008051static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8052{
8053 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008054 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008055 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008056 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008057 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008058 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8059 {
8060 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8061 }
8062 else
8063 {
8064 if ( eSIR_SME_SUCCESS == statusCode )
8065 {
8066 // Successfully deauth from the 'old' Bss...
8067 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008068 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008069 }
8070 else
8071 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008072 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008073 }
8074 //We are not done yet. Get the data and continue roaming
8075 csrRoamReissueRoamCommand(pMac);
8076 }
8077}
8078
Jeff Johnson295189b2012-06-20 16:38:30 -07008079static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8080{
8081 eCsrRoamCompleteResult result;
8082
8083 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8084 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008085 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008086 result = eCsrStartBssSuccess;
8087 }
8088 else
8089 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008090 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008091 //Let csrRoamComplete decide what to do
8092 result = eCsrStartBssFailure;
8093 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008094 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008095}
8096
Jeff Johnson295189b2012-06-20 16:38:30 -07008097/*
8098 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8099 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8100 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8101 For the messages where sender allocates memory for specific structures, then it can be
8102 cast accordingly.
8103*/
8104void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8105{
8106 tSirSmeRsp *pSmeRsp;
8107 tSmeIbssPeerInd *pIbssPeerInd;
8108 tCsrRoamInfo roamInfo;
8109 // TODO Session Id need to be acquired in this function
8110 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008111 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008112 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008113 pSmeRsp->messageType, pSmeRsp->messageType,
8114 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07008115 pSmeRsp->messageType = (pSmeRsp->messageType);
8116 pSmeRsp->length = (pSmeRsp->length);
8117 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008118 switch (pSmeRsp->messageType)
8119 {
8120
8121 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8122 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8123 {
8124 //We sent a JOIN_REQ
8125 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8126 }
8127 break;
8128
8129 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8130 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8131 {
8132 //We sent a AUTH_REQ
8133 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8134 }
8135 break;
8136
8137 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8138 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8139 {
8140 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8141 }
8142 break;
8143
8144 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8145 {
8146 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8147 }
8148 break;
8149
8150 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8151 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8152 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8153 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8154 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8155 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8156//HO
8157 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8158 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008159 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008160 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
8161 }
8162 break;
8163
8164 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8165 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8166 {
8167 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8168 }
8169 break;
8170
8171 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8172 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8173 {
8174 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8175 }
8176 break;
8177
8178 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8179 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8180 {
8181 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8182 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008183 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008184 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8185 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8186 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008187 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308188 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8189 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008190 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8191 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308192 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8193 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008194 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8195 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8196 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8197 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008198 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008199 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008200 pSmeRsp->messageType, pSmeRsp->messageType,
8201 pMac->roam.curSubState[pSmeRsp->sessionId] );
8202
8203 //If we are connected, check the link status change
8204 if(!csrIsConnStateDisconnected(pMac, sessionId))
8205 {
8206 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8207 }
8208 break;
8209 }
8210}
8211
Jeff Johnson295189b2012-06-20 16:38:30 -07008212void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8213{
8214 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008215 switch (pSirMsg->messageType)
8216 {
8217 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008218 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008219 csrRoamStatsRspProcessor( pMac, pSirMsg );
8220 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008221 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8222 {
8223 tCsrRoamSession *pSession;
8224 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8225 tCsrRoamInfo roamInfo;
8226 tCsrRoamInfo *pRoamInfo = NULL;
8227 tANI_U32 sessionId;
8228 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008229 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308230 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008231 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008232 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8233 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8234 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008235
8236 if(!pSession)
8237 {
8238 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8239 return;
8240 }
8241
Jeff Johnson295189b2012-06-20 16:38:30 -07008242 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8243 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008244 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8245 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8246 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008247 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8248 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308249 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8250 sizeof(tSirMacAddr));
8251 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8252 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008253 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008254 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8255 {
8256 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8257 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8258 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8259 }
8260 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8261 {
8262 vos_sleep( 100 );
8263 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8264 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8265 }
8266
Jeff Johnson295189b2012-06-20 16:38:30 -07008267 }
8268 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008269 default:
8270 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8271 break;
8272 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008273}
8274
Jeff Johnson295189b2012-06-20 16:38:30 -07008275eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8276 tSirBssDescription *pBssDescription,
8277 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8278 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8279 tANI_U8 keyId, tANI_U16 keyLength,
8280 tANI_U8 *pKey, tANI_U8 paeRole )
8281{
8282 eHalStatus status = eHAL_STATUS_SUCCESS;
8283 tAniEdType edType;
8284
8285 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8286 {
8287 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8288 }
8289
8290 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8291
8292 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8293 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8294 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8295 addKey )
8296 {
8297 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008298 setKey.encType = EncryptType;
8299 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308300 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008301 setKey.paeRole = paeRole; //0 for supplicant
8302 setKey.keyId = keyId; // Kye index
8303 setKey.keyLength = keyLength;
8304 if( keyLength )
8305 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308306 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008307 }
8308 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8309 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008310 return (status);
8311}
8312
Jeff Johnson295189b2012-06-20 16:38:30 -07008313static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8314 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8315{
8316 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8317 tSmeCmd *pCommand = NULL;
8318#ifdef FEATURE_WLAN_CCX
8319 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8320#endif /* FEATURE_WLAN_CCX */
8321
8322 do
8323 {
8324 pCommand = csrGetCommandBuffer(pMac);
8325 if(NULL == pCommand)
8326 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008327 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008328 status = eHAL_STATUS_RESOURCES;
8329 break;
8330 }
8331 pCommand->command = eSmeCommandSetKey;
8332 pCommand->sessionId = (tANI_U8)sessionId;
8333 // validate the key length, Adjust if too long...
8334 // for static WEP the keys are not set thru' SetContextReq
8335 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8336 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8337 {
8338 //KeyLength maybe 0 for static WEP
8339 if( pSetKey->keyLength )
8340 {
8341 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8342 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008343 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008344 break;
8345 }
8346
8347 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308348 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8349 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008350 }
8351 }
8352 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8353 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8354 {
8355 //KeyLength maybe 0 for static WEP
8356 if( pSetKey->keyLength )
8357 {
8358 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8359 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008360 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008361 break;
8362 }
8363
8364 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308365 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8366 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008367 }
8368 }
8369 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8370 {
8371 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8372 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008373 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008374 break;
8375 }
8376 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308377 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8378 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008379 }
8380 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8381 {
8382 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008384 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008385 break;
8386 }
8387 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308388 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8389 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008390 }
8391#ifdef FEATURE_WLAN_WAPI
8392 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8393 {
8394 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8395 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008396 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008397 break;
8398 }
8399 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308400 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8401 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008402 }
8403#endif /* FEATURE_WLAN_WAPI */
8404#ifdef FEATURE_WLAN_CCX
8405 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8406 {
8407 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8408 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008409 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008410 break;
8411 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308412 vos_mem_copy(pSession->ccxCckmInfo.krk, pSetKey->Key,
8413 CSR_KRK_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008414 pSession->ccxCckmInfo.reassoc_req_num=1;
8415 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8416 status = eHAL_STATUS_SUCCESS;
8417 break;
8418 }
8419#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008420
Jeff Johnson295189b2012-06-20 16:38:30 -07008421#ifdef WLAN_FEATURE_11W
8422 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008423 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008424 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008425 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008426 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008427 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008428 break;
8429 }
8430 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308431 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008432 }
8433#endif
8434 status = eHAL_STATUS_SUCCESS;
8435 pCommand->u.setKeyCmd.roamId = roamId;
8436 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8437 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308438 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8439 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008440 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8441 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308442 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008443 //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
8444
8445 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8446 if( !HAL_STATUS_SUCCESS( status ) )
8447 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008448 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008449 }
8450 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008451 // Free the command if there has been a failure, or it is a
8452 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008453 if ( ( NULL != pCommand ) &&
8454 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008455#ifdef FEATURE_WLAN_CCX
8456 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8457#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008458 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008459 {
8460 csrReleaseCommandSetKey( pMac, pCommand );
8461 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008462 return( status );
8463}
8464
Jeff Johnson295189b2012-06-20 16:38:30 -07008465eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8466 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8467{
8468 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8469 tSmeCmd *pCommand = NULL;
8470 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008471 do
8472 {
8473 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8474 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008475 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008476 status = eHAL_STATUS_CSR_WRONG_STATE;
8477 break;
8478 }
8479 pCommand = csrGetCommandBuffer(pMac);
8480 if(NULL == pCommand)
8481 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008482 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008483 status = eHAL_STATUS_RESOURCES;
8484 break;
8485 }
8486 pCommand->command = eSmeCommandRemoveKey;
8487 pCommand->sessionId = (tANI_U8)sessionId;
8488 pCommand->u.removeKeyCmd.roamId = roamId;
8489 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308490 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8491 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008492 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8493 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8494 {
8495 //in this case, put it to the end of the Q incase there is a set key pending.
8496 fImediate = eANI_BOOLEAN_FALSE;
8497 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008498 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008499 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008500 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008501 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8502 if( !HAL_STATUS_SUCCESS( status ) )
8503 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008504 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 break;
8506 }
8507 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8509 {
8510 csrReleaseCommandRemoveKey( pMac, pCommand );
8511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008512 return (status );
8513}
8514
Jeff Johnson295189b2012-06-20 16:38:30 -07008515eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8516{
8517 eHalStatus status;
8518 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8519 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8520 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8521 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008522#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8523 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8524 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008525 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008526 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308527 vos_mem_set(&setKeyEvent,
8528 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008529 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8530 {
8531 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8532 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8533 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8534 }
8535 else
8536 {
8537 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8538 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8539 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8540 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308541 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008542 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008543 {
8544 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008545 //It has to be static WEP here
8546 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8547 {
8548 setKeyEvent.keyId = (v_U8_t)defKeyId;
8549 }
8550 }
8551 else
8552 {
8553 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8554 }
8555 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8556 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8557 }
8558#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008559 if( csrIsSetKeyAllowed(pMac, sessionId) )
8560 {
8561 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8562 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8563 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8564 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8565 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8566 pCommand->u.setKeyCmd.keyRsc);
8567 }
8568 else
8569 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008570 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008571 //Set this status so the error handling take care of the case.
8572 status = eHAL_STATUS_CSR_WRONG_STATE;
8573 }
8574 if( !HAL_STATUS_SUCCESS(status) )
8575 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008576 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008577 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008578#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008579 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008580 {
8581 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8582 {
8583 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8584 }
8585 else
8586 {
8587 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8588 }
8589 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8590 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8591 }
8592#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008593 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008594 return ( status );
8595}
8596
Jeff Johnson295189b2012-06-20 16:38:30 -07008597eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8598{
8599 eHalStatus status;
8600 tpSirSmeRemoveKeyReq pMsg = NULL;
8601 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8602 tANI_U8 *p;
8603 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008604#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8605 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8606 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05308607 vos_mem_set(&removeKeyEvent,
8608 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8610 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8611 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308612 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008613 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8614 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8615 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8616#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008617 if( csrIsSetKeyAllowed(pMac, sessionId) )
8618 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308619 pMsg = vos_mem_malloc(wMsgLen);
8620 if ( NULL == pMsg )
8621 status = eHAL_STATUS_FAILURE;
8622 else
8623 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008624 }
8625 else
8626 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008627 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008628 //Set the error status so error handling kicks in below
8629 status = eHAL_STATUS_CSR_WRONG_STATE;
8630 }
8631 if( HAL_STATUS_SUCCESS( status ) )
8632 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308633 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008634 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8635 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008636 pMsg->sessionId = (tANI_U8)sessionId;
8637 pMsg->transactionId = 0;
8638 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8639 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8640 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308641 vos_mem_copy(p,
8642 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8643 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008644 p += sizeof(tSirMacAddr);
8645 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308646 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008647 p += sizeof(tSirMacAddr);
8648 // edType
8649 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8650 p++;
8651 // weptype
8652 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8653 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8654 {
8655 *p = (tANI_U8)eSIR_WEP_STATIC;
8656 }
8657 else
8658 {
8659 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8660 }
8661 p++;
8662 //keyid
8663 *p = pCommand->u.removeKeyCmd.keyId;
8664 p++;
8665 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008666 status = palSendMBMessage(pMac->hHdd, pMsg);
8667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008668 if( !HAL_STATUS_SUCCESS( status ) )
8669 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008670 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008671#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8672 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008673 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008674 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8675#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008676 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8677 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008678 return ( status );
8679}
8680
Jeff Johnson295189b2012-06-20 16:38:30 -07008681eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8682{
8683 eHalStatus status;
8684
8685 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8686 {
8687 status = eHAL_STATUS_CSR_WRONG_STATE;
8688 }
8689 else
8690 {
8691 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8692 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008693 return ( status );
8694}
8695
Jeff Johnson295189b2012-06-20 16:38:30 -07008696/*
8697 Prepare a filter base on a profile for parsing the scan results.
8698 Upon successful return, caller MUST call csrFreeScanFilter on
8699 pScanFilter when it is done with the filter.
8700*/
8701eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8702 tCsrScanResultFilter *pScanFilter)
8703{
8704 eHalStatus status = eHAL_STATUS_SUCCESS;
8705 tANI_U32 size = 0;
8706 tANI_U8 index = 0;
8707
8708 do
8709 {
8710 if(pProfile->BSSIDs.numOfBSSIDs)
8711 {
8712 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308713 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8714 if ( NULL == pScanFilter->BSSIDs.bssid )
8715 status = eHAL_STATUS_FAILURE;
8716 else
8717 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008718 if(!HAL_STATUS_SUCCESS(status))
8719 {
8720 break;
8721 }
8722 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308723 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008724 }
8725 if(pProfile->SSIDs.numOfSSIDs)
8726 {
8727 if( !CSR_IS_WDS_STA( pProfile ) )
8728 {
8729 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8730 }
8731 else
8732 {
8733 //For WDS station
8734 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8735 pScanFilter->SSIDs.numOfSSIDs = 1;
8736 }
8737 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308738 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8739 if ( NULL == pScanFilter->SSIDs.SSIDList )
8740 status = eHAL_STATUS_FAILURE;
8741 else
8742 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008743 if(!HAL_STATUS_SUCCESS(status))
8744 {
8745 break;
8746 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308747 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8748 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008749 }
8750 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8751 {
8752 pScanFilter->ChannelInfo.numOfChannels = 0;
8753 pScanFilter->ChannelInfo.ChannelList = NULL;
8754 }
8755 else if(pProfile->ChannelInfo.numOfChannels)
8756 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308757 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8758 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8759 pProfile->ChannelInfo.numOfChannels);
8760 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8761 status = eHAL_STATUS_FAILURE;
8762 else
8763 status = eHAL_STATUS_SUCCESS;
8764
Jeff Johnson295189b2012-06-20 16:38:30 -07008765 pScanFilter->ChannelInfo.numOfChannels = 0;
8766 if(HAL_STATUS_SUCCESS(status))
8767 {
8768 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8769 {
8770 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8771 {
8772 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8773 = pProfile->ChannelInfo.ChannelList[index];
8774 pScanFilter->ChannelInfo.numOfChannels++;
8775 }
8776 else
8777 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008778 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008779 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008780 }
8781 }
8782 else
8783 {
8784 break;
8785 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 }
8787 else
8788 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308789 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008790 status = eHAL_STATUS_FAILURE;
8791 break;
8792 }
8793 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8794 pScanFilter->authType = pProfile->AuthType;
8795 pScanFilter->EncryptionType = pProfile->EncryptionType;
8796 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8797 pScanFilter->BSSType = pProfile->BSSType;
8798 pScanFilter->phyMode = pProfile->phyMode;
8799#ifdef FEATURE_WLAN_WAPI
8800 //check if user asked for WAPI with 11n or auto mode, in that case modify
8801 //the phymode to 11g
8802 if(csrIsProfileWapi(pProfile))
8803 {
8804 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8805 {
8806 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8807 }
8808 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8809 {
8810 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8811 }
8812 if(!pScanFilter->phyMode)
8813 {
8814 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8815 }
8816 }
8817#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008818 /*Save the WPS info*/
8819 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008820 if( pProfile->countryCode[0] )
8821 {
8822 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05308823 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
8824 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008825 }
8826#ifdef WLAN_FEATURE_VOWIFI_11R
8827 if (pProfile->MDID.mdiePresent)
8828 {
8829 pScanFilter->MDID.mdiePresent = 1;
8830 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8831 }
8832#endif
8833
8834 }while(0);
8835
8836 if(!HAL_STATUS_SUCCESS(status))
8837 {
8838 csrFreeScanFilter(pMac, pScanFilter);
8839 }
8840
8841 return(status);
8842}
8843
Jeff Johnson295189b2012-06-20 16:38:30 -07008844tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8845 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8846{
8847 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8848 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 do
8850 {
8851 // Validate the type is ok...
8852 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8853 pCommand = csrGetCommandBuffer( pMac );
8854 if ( !pCommand )
8855 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008856 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008857 break;
8858 }
8859 //Change the substate in case it is waiting for key
8860 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8861 {
8862 csrRoamStopWaitForKeyTimer( pMac );
8863 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8864 }
8865 pCommand->command = eSmeCommandWmStatusChange;
8866 pCommand->sessionId = (tANI_U8)sessionId;
8867 pCommand->u.wmStatusChangeCmd.Type = Type;
8868 if ( eCsrDisassociated == Type )
8869 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308870 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
8871 pSmeRsp,
8872 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008873 }
8874 else
8875 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308876 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
8877 pSmeRsp,
8878 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 }
8880 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8881 {
8882 fCommandQueued = eANI_BOOLEAN_TRUE;
8883 }
8884 else
8885 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008886 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008887 csrReleaseCommandWmStatusChange( pMac, pCommand );
8888 }
8889
Jeff Johnson295189b2012-06-20 16:38:30 -07008890 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8891 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008892 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008893 return( fCommandQueued );
8894}
8895
Jeff Johnson295189b2012-06-20 16:38:30 -07008896static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8897{
8898 v_S7_t rssi = 0;
8899 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8900 if(pGetRssiReq)
8901 {
8902 if(NULL != pGetRssiReq->pVosContext)
8903 {
8904 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8905 }
8906 else
8907 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008908 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008909 return;
8910 }
8911
8912 if(NULL != pGetRssiReq->rssiCallback)
8913 {
8914 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8915 }
8916 else
8917 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008918 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008919 return;
8920 }
8921 }
8922 else
8923 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008924 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008925 }
8926 return;
8927}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308928
8929static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
8930{
8931 tANI_S8 snr = 0;
8932 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
8933
8934 if (pGetSnrReq)
8935 {
8936 if (VOS_STATUS_SUCCESS !=
8937 WDA_GetSnr(pGetSnrReq->staId, &snr))
8938 {
8939 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
8940 return;
8941 }
8942
8943 if (pGetSnrReq->snrCallback)
8944 {
8945 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
8946 pGetSnrReq->pDevContext);
8947 }
8948 else
8949 {
8950 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
8951 return;
8952 }
8953 }
8954 else
8955 {
8956 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
8957 }
8958 return;
8959}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008960#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8961void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8962{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008963 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8964
Jeff Johnson36d483b2013-04-08 11:08:53 -07008965 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008966 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008967 /* Get roam Rssi request is backed up and passed back to the response,
8968 Extract the request message to fetch callback */
8969 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8970 v_S7_t rssi = pRoamRssiRsp->rssi;
8971
8972 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008973 {
8974 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8975 reqBkp->rssiCallback = NULL;
8976 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08008977 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008978 }
8979 else
8980 {
8981 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8982 if (NULL != reqBkp)
8983 {
8984 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08008985 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008986 }
8987 }
8988 }
8989 else
8990 {
8991 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8992 }
8993 return;
8994}
8995#endif
8996
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008997
8998#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
8999void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9000{
9001 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9002
9003 if (NULL != pTsmStatsRsp)
9004 {
9005 /* Get roam Rssi request is backed up and passed back to the response,
9006 Extract the request message to fetch callback */
9007 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9008
9009 if (NULL != reqBkp)
9010 {
9011 if (NULL != reqBkp->tsmStatsCallback)
9012 {
9013 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9014 pTsmStatsRsp->staId, reqBkp->pDevContext);
9015 reqBkp->tsmStatsCallback = NULL;
9016 }
9017 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009018 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009019 }
9020 else
9021 {
9022 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9023 if (NULL != reqBkp)
9024 {
9025 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009026 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009027 }
9028 }
9029 }
9030 else
9031 {
9032 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9033 }
9034 return;
9035}
9036
9037void csrSendCcxAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
9038{
9039 tANI_U32 roamTS2 = 0;
9040 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009041 tpPESession pSessionEntry = NULL;
9042 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009043
9044 if (NULL == pSession)
9045 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009046 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009047 return;
9048 }
9049
9050 roamTS2 = vos_timer_get_system_time();
9051 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009052 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9053 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009054 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009055
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009056 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9057 if (NULL == pSessionEntry)
9058 {
9059 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9060 return;
9061 }
9062 pSessionEntry->ccxContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009063 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
9064 0, eCSR_ROAM_CCX_ADJ_AP_REPORT_IND, 0);
9065}
9066#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
9067
Jeff Johnsone7245742012-09-05 17:12:55 -07009068static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9069{
9070 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9071 if(pTlRssiInd)
9072 {
9073 if(NULL != pTlRssiInd->tlCallback)
9074 {
9075 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009076 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009077 }
9078 else
9079 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009080 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009081 }
9082 }
9083 else
9084 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009085 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009086 }
9087 return;
9088}
Jeff Johnson295189b2012-06-20 16:38:30 -07009089
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309090eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9091{
9092 tpSirResetAPCapsChange pMsg;
9093 tANI_U16 len;
9094 eHalStatus status = eHAL_STATUS_SUCCESS;
9095
9096 /* Create the message and send to lim */
9097 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309098 pMsg = vos_mem_malloc(len);
9099 if ( NULL == pMsg )
9100 status = eHAL_STATUS_FAILURE;
9101 else
9102 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309103 if (HAL_STATUS_SUCCESS(status))
9104 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309105 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309106 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9107 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309108 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009109 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9110 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309111 status = palSendMBMessage(pMac->hHdd, pMsg);
9112 }
9113 else
9114 {
9115 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9116 }
9117 return status;
9118}
9119
Jeff Johnson295189b2012-06-20 16:38:30 -07009120void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9121{
9122 tSirSmeAssocInd *pAssocInd;
9123 tSirSmeDisassocInd *pDisassocInd;
9124 tSirSmeDeauthInd *pDeauthInd;
9125 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9126 tSirSmeNewBssInfo *pNewBss;
9127 tSmeIbssPeerInd *pIbssPeerInd;
9128 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9129 tSirSmeApNewCaps *pApNewCaps;
9130 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9131 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9132 tCsrRoamInfo *pRoamInfo = NULL;
9133 tCsrRoamInfo roamInfo;
9134 eHalStatus status;
9135 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9136 tCsrRoamSession *pSession = NULL;
9137 tpSirSmeSwitchChannelInd pSwitchChnInd;
9138 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309139 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009140
9141
9142 if (NULL == pSirMsg)
9143 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9144 return;
9145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009146 switch( pSirMsg->messageType )
9147 {
9148 case eWNI_SME_ASSOC_IND:
9149 {
9150 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009151 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009152 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9153 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9154 if( HAL_STATUS_SUCCESS( status ) )
9155 {
9156 pSession = CSR_GET_SESSION(pMac, sessionId);
9157
Jeff Johnson32d95a32012-09-10 13:15:23 -07009158 if(!pSession)
9159 {
9160 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9161 return;
9162 }
9163
Jeff Johnson295189b2012-06-20 16:38:30 -07009164 pRoamInfo = &roamInfo;
9165
9166 // Required for indicating the frames to upper layer
9167 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9168 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9169
9170 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9171 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9172 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9173 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9174
9175 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9176 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9177 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9178
9179 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9180 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309181 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9182 sizeof(tSirMacAddr));
9183 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9184 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009185 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9186 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009187 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009188 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9189 {
9190 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9191 {
9192 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9193 pSession->pConnectBssDesc,
9194 &(pRoamInfo->peerMac),
9195 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9196 pRoamInfo->fAuthRequired = FALSE;
9197 }
9198 else
9199 {
9200 pRoamInfo->fAuthRequired = TRUE;
9201 }
9202 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9203 if (!HAL_STATUS_SUCCESS(status))
9204 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9205 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009206 /* Send Association completion message to PE */
9207 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9208
9209 /* send a message to CSR itself just to avoid the EAPOL frames going
9210 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009211 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9212 {
9213 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9214 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009215 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9216 {
9217 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9218 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9219 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009221 }
9222 }
9223 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009224 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009225 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309226 // Check if AP dis-associated us because of MIC failure. If so,
9227 // then we need to take action immediately and not wait till the
9228 // the WmStatusChange requests is pushed and processed
9229 tSmeCmd *pCommand;
9230
9231 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9232 status = csrRoamGetSessionIdFromBSSID( pMac,
9233 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9234 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009235 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309236 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9237 " for session %d "), sessionId);
9238 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9239 MAC_ADDRESS_STR " "
9240 " reason = %d status = %d "),
9241 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9242 pDisassocInd->reasonCode,
9243 pDisassocInd->statusCode);
9244 // If we are in neighbor preauth done state then on receiving
9245 // disassoc or deauth we dont roam instead we just disassoc
9246 // from current ap and then go to disconnected state
9247 // This happens for CCX and 11r FT connections ONLY.
9248#ifdef WLAN_FEATURE_VOWIFI_11R
9249 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9250 {
9251 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009253#endif
9254#ifdef FEATURE_WLAN_CCX
Agarwal Ashish4f616132013-12-30 23:32:50 +05309255 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9256 {
9257 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009259#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009260#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309261 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9262 {
9263 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9264 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009265#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309266 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009267
Agarwal Ashish4f616132013-12-30 23:32:50 +05309268 if (!pSession)
9269 {
9270 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9271 return;
9272 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009273
Agarwal Ashish4f616132013-12-30 23:32:50 +05309274 if ( csrIsConnStateInfra( pMac, sessionId ) )
9275 {
9276 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009278#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309279 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009280#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309281 csrRoamLinkDown(pMac, sessionId);
9282 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9283 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9284 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009285
Agarwal Ashish4f616132013-12-30 23:32:50 +05309286 pCommand = csrGetCommandBuffer(pMac);
9287 if (NULL == pCommand)
9288 {
9289 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9290 status = eHAL_STATUS_RESOURCES;
9291 }
9292 pRoamInfo = &roamInfo;
9293 pRoamInfo->statusCode = pDisassocInd->statusCode;
9294 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9295 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009296
Agarwal Ashish4f616132013-12-30 23:32:50 +05309297 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9298 sizeof(tSirMacAddr));
9299 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9300 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009301
Agarwal Ashish4f616132013-12-30 23:32:50 +05309302 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9303 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009304
Agarwal Ashish4f616132013-12-30 23:32:50 +05309305 /*
9306 * STA/P2P client got disassociated so remove any pending deauth
9307 * commands in sme pending list
9308 */
9309 pCommand->command = eSmeCommandRoam;
9310 pCommand->sessionId = (tANI_U8)sessionId;
9311 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9312 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9313 pDisassocInd->peerMacAddr,
9314 sizeof(tSirMacAddr));
9315 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9316 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009317
Agarwal Ashish4f616132013-12-30 23:32:50 +05309318 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009319 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309320 else
9321 {
9322 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9323 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9324 }
Kiet Lam82004c62013-11-11 13:24:28 +05309325 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009326 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009327 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009328 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009329 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9330 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9331 if( HAL_STATUS_SUCCESS( status ) )
9332 {
9333 // If we are in neighbor preauth done state then on receiving
9334 // disassoc or deauth we dont roam instead we just disassoc
9335 // from current ap and then go to disconnected state
9336 // This happens for CCX and 11r FT connections ONLY.
9337#ifdef WLAN_FEATURE_VOWIFI_11R
9338 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9339 {
9340 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9341 }
9342#endif
9343#ifdef FEATURE_WLAN_CCX
9344 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9345 {
9346 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9347 }
9348#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009349#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309350 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009351 {
9352 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9353 }
9354#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009355 pSession = CSR_GET_SESSION( pMac, sessionId );
9356
Jeff Johnson32d95a32012-09-10 13:15:23 -07009357 if(!pSession)
9358 {
9359 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9360 return;
9361 }
9362
Jeff Johnson295189b2012-06-20 16:38:30 -07009363 if ( csrIsConnStateInfra( pMac, sessionId ) )
9364 {
9365 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9366 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009367#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9368 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9369#endif
9370 csrRoamLinkDown(pMac, sessionId);
9371 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009372 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9373 {
9374
9375 pRoamInfo = &roamInfo;
9376
9377 pRoamInfo->statusCode = pDeauthInd->statusCode;
9378 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9379
9380 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9381
Kiet Lam64c1b492013-07-12 13:56:44 +05309382 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9383 sizeof(tSirMacAddr));
9384 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9385 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009386
9387 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9388 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009389 }
9390 break;
9391
9392 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 -08009393 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009394 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9395 //Update with the new channel id.
9396 //The channel id is hidden in the statusCode.
9397 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9398 if( HAL_STATUS_SUCCESS( status ) )
9399 {
9400 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009401 if(!pSession)
9402 {
9403 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9404 return;
9405 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009406 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9407 if(pSession->pConnectBssDesc)
9408 {
9409 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9410 }
9411 }
9412 break;
9413
9414 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009415 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009416 {
9417 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9418 sessionId = pDeauthRsp->sessionId;
9419 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9420 {
9421 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009422 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9423 {
9424 pRoamInfo = &roamInfo;
9425 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309426 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9427 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009428 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9429 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9430 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9431 }
9432 }
9433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009434 break;
9435
9436 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009437 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009438 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009439 {
9440 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9441 sessionId = pDisassocRsp->sessionId;
9442 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9443 {
9444 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009445 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9446 {
9447 pRoamInfo = &roamInfo;
9448 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309449 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9450 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009451 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9452 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9453 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9454 }
9455 }
9456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009457 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009458 case eWNI_SME_MIC_FAILURE_IND:
9459 {
9460 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9461 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9462 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009463
9464 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9465 if( HAL_STATUS_SUCCESS( status ) )
9466 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309467 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009468 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9469 pRoamInfo = &roamInfo;
9470 if(pMicInd->info.multicast)
9471 {
9472 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9473 }
9474 else
9475 {
9476 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9477 }
9478 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9479 }
9480
Jeff Johnson295189b2012-06-20 16:38:30 -07009481#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9482 {
lukez3c809222013-05-03 10:23:02 -07009483 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009484 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009485 if(!pSession)
9486 {
9487 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9488 return;
9489 }
lukez3c809222013-05-03 10:23:02 -07009490
Kiet Lam64c1b492013-07-12 13:56:44 +05309491 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009492 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9493 secEvent.encryptionModeMulticast =
9494 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9495 secEvent.encryptionModeUnicast =
9496 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9497 secEvent.authMode =
9498 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309499 vos_mem_copy(secEvent.bssid,
9500 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009501 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9502 }
9503#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009504 }
9505 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009506 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9507 {
9508 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9509 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009510 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009511
9512 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9513 if( HAL_STATUS_SUCCESS( status ) )
9514 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309515 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009516 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9517 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9518 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9519 }
9520 }
9521 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009522
Jeff Johnson295189b2012-06-20 16:38:30 -07009523 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9524 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9525 switch( pStatusChangeMsg->statusChangeCode )
9526 {
9527 case eSIR_SME_IBSS_ACTIVE:
9528 sessionId = csrFindIbssSession( pMac );
9529 if( CSR_SESSION_ID_INVALID != sessionId )
9530 {
9531 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009532 if(!pSession)
9533 {
9534 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9535 return;
9536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009537 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9538 if(pSession->pConnectBssDesc)
9539 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309540 vos_mem_copy(&roamInfo.bssid,
9541 pSession->pConnectBssDesc->bssId,
9542 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9544 pRoamInfo = &roamInfo;
9545 }
9546 else
9547 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009548 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009549 }
9550 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9551 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9552 }
9553 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 case eSIR_SME_IBSS_INACTIVE:
9555 sessionId = csrFindIbssSession( pMac );
9556 if( CSR_SESSION_ID_INVALID != sessionId )
9557 {
9558 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009559 if(!pSession)
9560 {
9561 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9562 return;
9563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009564 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9565 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9566 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9567 }
9568 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009569 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9570 sessionId = csrFindIbssSession( pMac );
9571 if( CSR_SESSION_ID_INVALID != sessionId )
9572 {
9573 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009574 if(!pSession)
9575 {
9576 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9577 return;
9578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009579 // update the connection state information
9580 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009581#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9582 {
9583 vos_log_ibss_pkt_type *pIbssLog;
9584 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009585 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9586 if(pIbssLog)
9587 {
9588 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9589 if(pNewBss)
9590 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309591 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009592 if(pNewBss->ssId.length)
9593 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309594 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9595 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009596 }
9597 pIbssLog->operatingChannel = pNewBss->channelNumber;
9598 }
9599 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9600 {
9601 //***U8 is not enough for beacon interval
9602 pIbssLog->beaconInterval = (v_U8_t)bi;
9603 }
9604 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9605 }
9606 }
9607#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009608 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009609
9610 if ((eCSR_ENCRYPT_TYPE_NONE ==
9611 pSession->connectedProfile.EncryptionType ))
9612 {
9613 csrRoamIssueSetContextReq( pMac, sessionId,
9614 pSession->connectedProfile.EncryptionType,
9615 pSession->pConnectBssDesc,
9616 &Broadcastaddr,
9617 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9618 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009619 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9620 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309621 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9622 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009623 pRoamInfo = &roamInfo;
9624 //This BSSID is th ereal BSSID, let's save it
9625 if(pSession->pConnectBssDesc)
9626 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309627 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9628 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009630 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009631 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009632 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009633 // detection by LIM that the capabilities of the associated AP have changed.
9634 case eSIR_SME_AP_CAPS_CHANGED:
9635 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009636 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009637 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9638 if( HAL_STATUS_SUCCESS( status ) )
9639 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009640 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9641 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309642 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009643 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9644 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9645 )
9646 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309647 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9648 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009649 }
9650 else
9651 {
9652 smsLog(pMac, LOGW,
9653 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009654 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009655 pMac->roam.curState[sessionId],
9656 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309657 /* We ignore the caps change event if CSR is not in full connected state.
9658 * Send one event to PE to reset limSentCapsChangeNtf
9659 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9660 * otherwise lim cannot send any CAPS change events to SME */
9661 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009662 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009663 }
9664 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309665
Jeff Johnson295189b2012-06-20 16:38:30 -07009666 default:
9667 roamStatus = eCSR_ROAM_FAILED;
9668 result = eCSR_ROAM_RESULT_NONE;
9669 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009670 } // end switch on statusChangeCode
9671 if(eCSR_ROAM_RESULT_NONE != result)
9672 {
9673 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9674 }
9675 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009676 case eWNI_SME_IBSS_NEW_PEER_IND:
9677 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009678#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9679 {
9680 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009681 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9682 if(pIbssLog)
9683 {
9684 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309685 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009686 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9687 }
9688 }
9689#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009690 sessionId = csrFindIbssSession( pMac );
9691 if( CSR_SESSION_ID_INVALID != sessionId )
9692 {
9693 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009694
9695 if(!pSession)
9696 {
9697 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9698 return;
9699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009700 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9701 if(pSession->pConnectBssDesc)
9702 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309703 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9704 sizeof(tCsrBssid));
9705 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9706 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009707 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9708 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309709 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9710 - sizeof(tSmeIbssPeerInd)));
9711 if ( NULL == roamInfo.pbFrames )
9712 status = eHAL_STATUS_FAILURE;
9713 else
9714 status = eHAL_STATUS_SUCCESS;
9715 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009716 {
9717 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309718 vos_mem_copy(roamInfo.pbFrames,
9719 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9720 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009721 }
9722 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9723 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9724 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309725 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9726 if ( NULL == roamInfo.pBssDesc )
9727 status = eHAL_STATUS_FAILURE;
9728 else
9729 status = eHAL_STATUS_SUCCESS;
9730 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009731 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309732 vos_mem_copy(roamInfo.pBssDesc,
9733 pSession->pConnectBssDesc,
9734 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009735 }
9736 if(HAL_STATUS_SUCCESS(status))
9737 {
9738 pRoamInfo = &roamInfo;
9739 }
9740 else
9741 {
9742 if(roamInfo.pbFrames)
9743 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309744 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009745 }
9746 if(roamInfo.pBssDesc)
9747 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309748 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009749 }
9750 }
9751 }
9752 else
9753 {
9754 pRoamInfo = &roamInfo;
9755 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009756 if ((eCSR_ENCRYPT_TYPE_NONE ==
9757 pSession->connectedProfile.EncryptionType ))
9758 {
9759 csrRoamIssueSetContextReq( pMac, sessionId,
9760 pSession->connectedProfile.EncryptionType,
9761 pSession->pConnectBssDesc,
9762 &(pIbssPeerInd->peerAddr),
9763 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9764 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009765 }
9766 else
9767 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009768 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009769 }
9770 //send up the sec type for the new peer
9771 if (pRoamInfo)
9772 {
9773 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9774 }
9775 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9776 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9777 if(pRoamInfo)
9778 {
9779 if(roamInfo.pbFrames)
9780 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309781 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009782 }
9783 if(roamInfo.pBssDesc)
9784 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309785 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 }
9787 }
9788 }
9789 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009790 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9791 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9792 sessionId = csrFindIbssSession( pMac );
9793 if( CSR_SESSION_ID_INVALID != sessionId )
9794 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009795#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9796 {
9797 vos_log_ibss_pkt_type *pIbssLog;
9798
9799 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_PEER_LEAVE;
9803 if(pIbssPeerInd)
9804 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309805 vos_mem_copy(pIbssLog->peerMacAddr,
9806 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009807 }
9808 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9809 }
9810 }
9811#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009812 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009813 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9814 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9815 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309816 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9817 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009818 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9819 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9820 }
9821 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009822 case eWNI_SME_SETCONTEXT_RSP:
9823 {
9824 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9825 tListElem *pEntry;
9826 tSmeCmd *pCommand;
9827
9828 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9829 if ( pEntry )
9830 {
9831 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9832 if ( eSmeCommandSetKey == pCommand->command )
9833 {
9834 sessionId = pCommand->sessionId;
9835 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009836
9837 if(!pSession)
9838 {
9839 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9840 return;
9841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009842
9843#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9844 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9845 {
9846 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309847 vos_mem_set(&setKeyEvent,
9848 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009849 if( pRsp->peerMacAddr[0] & 0x01 )
9850 {
9851 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9852 }
9853 else
9854 {
9855 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9856 }
9857 setKeyEvent.encryptionModeMulticast =
9858 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9859 setKeyEvent.encryptionModeUnicast =
9860 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309861 vos_mem_copy(setKeyEvent.bssid,
9862 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009863 setKeyEvent.authMode =
9864 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009865 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009866 {
9867 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9868 }
9869 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9870 }
9871#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9872 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9873 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009874 csrRoamStopWaitForKeyTimer( pMac );
9875
Jeff Johnson295189b2012-06-20 16:38:30 -07009876 //We are done with authentication, whethere succeed or not
9877 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009878 //We do it here because this linkup function is not called after association
9879 //when a key needs to be set.
9880 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9881 {
9882 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9883 }
9884 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009885 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009886 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309887 vos_mem_copy(&roamInfo.peerMac,
9888 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07009889 //Make sure we install the GTK before indicating to HDD as authenticated
9890 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +05309891 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
9892 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009893 {
Yathish9f22e662012-12-10 14:21:35 -08009894#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9895 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9896 {
9897 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +05309898 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -08009899 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9900 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9901 pMsg->seesionId = sessionId;
9902 status = palSendMBMessage(pMac->hHdd, pMsg );
9903 }
9904#endif
Sandeep Puligilla332ea912014-02-04 00:16:24 +05309905 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
9906 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
9907 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE )
9908 {
9909 tpSirSmeHT40OBSSScanInd pMsg;
9910 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
9911 pMsg->messageType =
9912 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
9913 pMsg->length =
9914 pal_cpu_to_be16(sizeof( tANI_U8));
9915 pMsg->seesionId = sessionId;
9916 status = palSendMBMessage(pMac->hHdd,
9917 pMsg );
9918 }
9919 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009920 }
9921 else
9922 {
9923 result = eCSR_ROAM_RESULT_NONE;
9924 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009925 pRoamInfo = &roamInfo;
9926 }
9927 else
9928 {
9929 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009930 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
9931 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
9932 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009933 }
9934 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9935 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009936 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9937 // can go ahead and initiate the TSPEC if any are pending
9938 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009939#ifdef FEATURE_WLAN_CCX
9940 //Send Adjacent AP repot to new AP.
9941 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9942 pSession->isPrevApInfoValid &&
9943 pSession->connectedProfile.isCCXAssoc)
9944 {
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009945#ifdef FEATURE_WLAN_CCX_UPLOAD
9946 csrSendCcxAdjacentApRepInd(pMac, pSession);
9947#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009948 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9949#endif
9950 pSession->isPrevApInfoValid = FALSE;
9951 }
9952#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009953 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9954 {
9955 csrReleaseCommandSetKey( pMac, pCommand );
9956 }
9957 }
9958 else
9959 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009960 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009961 }
9962 }
9963 else
9964 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009965 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009967 smeProcessPendingQueue( pMac );
9968 }
9969 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009970 case eWNI_SME_REMOVEKEY_RSP:
9971 {
9972 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9973 tListElem *pEntry;
9974 tSmeCmd *pCommand;
9975
9976 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9977 if ( pEntry )
9978 {
9979 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9980 if ( eSmeCommandRemoveKey == pCommand->command )
9981 {
9982 sessionId = pCommand->sessionId;
9983 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009984
9985 if(!pSession)
9986 {
9987 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9988 return;
9989 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009990#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9991 {
9992 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309993 vos_mem_set(&removeKeyEvent,
9994 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009995 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9996 removeKeyEvent.encryptionModeMulticast =
9997 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9998 removeKeyEvent.encryptionModeUnicast =
9999 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010000 vos_mem_copy( removeKeyEvent.bssid,
10001 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010002 removeKeyEvent.authMode =
10003 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010004 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010005 {
10006 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10007 }
10008 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10009 }
10010#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010011 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010012 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010013 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10014 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010015 result = eCSR_ROAM_RESULT_NONE;
10016 pRoamInfo = &roamInfo;
10017 }
10018 else
10019 {
10020 result = eCSR_ROAM_RESULT_FAILURE;
10021 }
10022 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10023 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10024 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10025 {
10026 csrReleaseCommandRemoveKey( pMac, pCommand );
10027 }
10028 }
10029 else
10030 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010031 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010032 }
10033 }
10034 else
10035 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010036 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010037 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010038 smeProcessPendingQueue( pMac );
10039 }
10040 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010041 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010042 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010043 csrRoamStatsRspProcessor( pMac, pSirMsg );
10044 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010045#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
10046 case eWNI_SME_GET_ROAM_RSSI_RSP:
10047 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10048 csrRoamRssiRspProcessor( pMac, pSirMsg );
10049 break;
10050#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010051#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
10052 case eWNI_SME_GET_TSM_STATS_RSP:
10053 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10054 csrTsmStatsRspProcessor( pMac, pSirMsg );
10055 break;
10056#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010057 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010058 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010059 csrUpdateRssi( pMac, pSirMsg );
10060 break;
10061
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010062 case eWNI_SME_GET_SNR_REQ:
10063 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10064 csrUpdateSnr(pMac, pSirMsg);
10065 break;
10066
Jeff Johnson295189b2012-06-20 16:38:30 -070010067#ifdef WLAN_FEATURE_VOWIFI_11R
10068 case eWNI_SME_FT_PRE_AUTH_RSP:
10069 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10070 break;
10071#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010072 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10073 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010074 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 -070010075 sessionId = pSmeMaxAssocInd->sessionId;
10076 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010077 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10078 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010079 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10080 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10081 break;
10082
10083 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010084 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010085 btampEstablishLogLinkHdlr( pSirMsg );
10086 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010087 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010088 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010089 csrRoamRssiIndHdlr( pMac, pSirMsg );
10090 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010091#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10092 case eWNI_SME_CANDIDATE_FOUND_IND:
10093 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10094 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10095 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010096 case eWNI_SME_HANDOFF_REQ:
10097 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10098 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10099 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010100#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010101
10102 default:
10103 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010104 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010105}
10106
Jeff Johnson295189b2012-06-20 16:38:30 -070010107void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10108 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10109{
10110 if(pSession)
10111 {
10112 if(pSession->bRefAssocStartCnt)
10113 {
10114 pSession->bRefAssocStartCnt--;
10115 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10116 //Need to call association_completion because there is an assoc_start pending.
10117 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10118 eCSR_ROAM_ASSOCIATION_COMPLETION,
10119 eCSR_ROAM_RESULT_FAILURE);
10120 }
10121 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10122 }
10123 else
10124 {
10125 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10126 }
10127}
10128
10129
10130eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10131{
10132 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010133 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10134 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10135 {
10136 status = csrScanRequestLostLink1( pMac, sessionId );
10137 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010138 return(status);
10139}
10140
Jeff Johnson295189b2012-06-20 16:38:30 -070010141//return a boolean to indicate whether roaming completed or continue.
10142tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10143 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10144{
10145 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10146 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10147 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10148 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010149 if(!pSession)
10150 {
10151 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10152 return eANI_BOOLEAN_FALSE;
10153 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010154 //Check whether time is up
10155 if(pSession->fCancelRoaming || fForce ||
10156 ((curTime - pSession->roamingStartTime) > roamTime) ||
10157 eCsrReassocRoaming == pSession->roamingReason ||
10158 eCsrDynamicRoaming == pSession->roamingReason)
10159 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010160 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010161 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10162 {
10163 //roaming is cancelled, tell HDD to indicate disconnect
10164 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10165 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10166 //to be eSIR_BEACON_MISSED
10167 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10168 {
10169 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10170 }
10171 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10172 {
10173 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10174 }
10175 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10176 {
10177 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10178 }
10179 else
10180 {
10181 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10182 }
10183 }
10184 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10185 pSession->roamingReason = eCsrNotRoaming;
10186 }
10187 else
10188 {
10189 pSession->roamResult = roamResult;
10190 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10191 {
10192 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10193 pSession->roamingReason = eCsrNotRoaming;
10194 }
10195 else
10196 {
10197 fCompleted = eANI_BOOLEAN_FALSE;
10198 }
10199 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010200 return(fCompleted);
10201}
10202
Jeff Johnson295189b2012-06-20 16:38:30 -070010203void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10204{
10205 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010206
10207 if(!pSession)
10208 {
10209 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10210 return;
10211 }
10212
Jeff Johnson295189b2012-06-20 16:38:30 -070010213 if(CSR_IS_ROAMING(pSession))
10214 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010215 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010216 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10217 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10218 {
10219 //No need to do anything in here because the handler takes care of it
10220 }
10221 else
10222 {
10223 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10224 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10225 //Roaming is stopped after here
10226 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10227 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010228 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010229 csrRoamStopRoamingTimer(pMac, sessionId);
10230 }
10231 }
10232}
10233
Jeff Johnson295189b2012-06-20 16:38:30 -070010234void csrRoamRoamingTimerHandler(void *pv)
10235{
10236 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10237 tpAniSirGlobal pMac = pInfo->pMac;
10238 tANI_U32 sessionId = pInfo->sessionId;
10239 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010240
10241 if(!pSession)
10242 {
10243 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10244 return;
10245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010246
10247 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10248 {
10249 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10250 {
10251 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10252 pSession->roamingReason = eCsrNotRoaming;
10253 }
10254 }
10255}
10256
Jeff Johnson295189b2012-06-20 16:38:30 -070010257eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10258{
10259 eHalStatus status;
10260 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010261
10262 if(!pSession)
10263 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010264 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010265 return eHAL_STATUS_FAILURE;
10266 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010267
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010268 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010269 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010270 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010271
10272 return (status);
10273}
10274
Jeff Johnson295189b2012-06-20 16:38:30 -070010275eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10276{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010277 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010278}
10279
Jeff Johnson295189b2012-06-20 16:38:30 -070010280void csrRoamWaitForKeyTimeOutHandler(void *pv)
10281{
10282 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10283 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010284 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010285 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010286
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010287 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010288 pMac->roam.neighborRoamInfo.neighborRoamState,
10289 pMac->roam.curSubState[pInfo->sessionId]);
10290
Jeff Johnson295189b2012-06-20 16:38:30 -070010291 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10292 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010293#ifdef FEATURE_WLAN_LFR
10294 if (csrNeighborRoamIsHandoffInProgress(pMac))
10295 {
10296 /*
10297 * Enable heartbeat timer when hand-off is in progress
10298 * and Key Wait timer expired.
10299 */
10300 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010301 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010302 pMac->roam.configParam.HeartbeatThresh24);
10303 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10304 pMac->roam.configParam.HeartbeatThresh24,
10305 NULL, eANI_BOOLEAN_FALSE);
10306 }
10307#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010308 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010309
Jeff Johnson295189b2012-06-20 16:38:30 -070010310 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010311 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10312 {
10313 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10314 pInfo->sessionId);
10315 }
10316
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010317 if (pSession)
10318 {
10319 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10320 {
10321 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10322 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010323 if( (pSession->connectedProfile.AuthType ==
10324 eCSR_AUTH_TYPE_SHARED_KEY) &&
10325 ( (pSession->connectedProfile.EncryptionType ==
10326 eCSR_ENCRYPT_TYPE_WEP40) ||
10327 (pSession->connectedProfile.EncryptionType ==
10328 eCSR_ENCRYPT_TYPE_WEP104) ))
10329 {
10330 status = sme_AcquireGlobalLock( &pMac->sme );
10331 if ( HAL_STATUS_SUCCESS( status ) )
10332 {
10333 csrRoamDisconnect( pMac, pInfo->sessionId,
10334 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10335 sme_ReleaseGlobalLock( &pMac->sme );
10336 }
10337 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010338 }
10339 else
10340 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010341 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010342 __func__);
10343 }
10344 }
10345 else
10346 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010347 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010348 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010349 }
10350
10351}
10352
Jeff Johnson295189b2012-06-20 16:38:30 -070010353eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10354{
10355 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010356#ifdef FEATURE_WLAN_LFR
10357 if (csrNeighborRoamIsHandoffInProgress(pMac))
10358 {
10359 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010360 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010361 __func__,
10362 pMac->roam.neighborRoamInfo.neighborRoamState,
10363 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10364 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10365 }
10366#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010367 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010368 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010369
10370 return (status);
10371}
10372
Jeff Johnson295189b2012-06-20 16:38:30 -070010373eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10374{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010375 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010376 pMac->roam.neighborRoamInfo.neighborRoamState,
10377 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10378#ifdef FEATURE_WLAN_LFR
10379 if (csrNeighborRoamIsHandoffInProgress(pMac))
10380 {
10381 /*
10382 * Enable heartbeat timer when hand-off is in progress
10383 * and Key Wait timer got stopped for some reason
10384 */
10385 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010386 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010387 pMac->roam.configParam.HeartbeatThresh24);
10388 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10389 pMac->roam.configParam.HeartbeatThresh24,
10390 NULL, eANI_BOOLEAN_FALSE);
10391 }
10392#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010393 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010394}
10395
Jeff Johnson295189b2012-06-20 16:38:30 -070010396void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10397 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10398{
10399 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10400 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010401 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10402 /* To silence the KW tool Null chaeck is added */
10403 if(!pSession)
10404 {
10405 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10406 return;
10407 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010408
10409 if(pCommand)
10410 {
10411 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010412 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010413 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010414 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10415 {
10416 //if success, force roaming completion
10417 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10418 }
10419 else
10420 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010421 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010422 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010423 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10424 }
10425}
10426
Jeff Johnson295189b2012-06-20 16:38:30 -070010427eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10428{
10429 eHalStatus status = eHAL_STATUS_SUCCESS;
10430 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10431 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10432 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10433 tCsrRoamInfo *pRoamInfo = NULL;
10434 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010435 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010436 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010437 /* To silence the KW tool Null chaeck is added */
10438 if(!pSession)
10439 {
10440 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10441 return eHAL_STATUS_FAILURE;
10442 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010443 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010444 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010445 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10446 if ( eWNI_SME_DISASSOC_IND == type )
10447 {
10448 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10449 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10450 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010451 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010452 }
10453 else if ( eWNI_SME_DEAUTH_IND == type )
10454 {
10455 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10456 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10457 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010458 /* Convert into proper reason code */
10459 pSession->joinFailStatusCode.reasonCode =
10460 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010461 0 : pDeauthIndMsg->reasonCode;
10462 /* cfg layer expects 0 as reason code if
10463 the driver dosent know the reason code
10464 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010465 }
10466 else
10467 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010468 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010469 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010470 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010471 }
10472
10473 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010474 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010475 {
10476 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10477 }
10478
10479 if ( eWNI_SME_DISASSOC_IND == type )
10480 {
10481 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10482 }
10483 else if ( eWNI_SME_DEAUTH_IND == type )
10484 {
10485 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10486 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010487 if(!HAL_STATUS_SUCCESS(status))
10488 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010489 //If fail to send confirmation to PE, not to trigger roaming
10490 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010491 }
10492
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010493 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010494 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010495 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10496 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010497 if( eWNI_SME_DISASSOC_IND == type)
10498 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010499 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010500 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10501 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010502 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10503 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010504 else if( eWNI_SME_DEAUTH_IND == type )
10505 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010506 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010507 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10508 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010509 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10510 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010511 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010512
10513 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10514 that we are roaming. But if we cannot possibly roam, or if we are unable to
10515 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010516 if(fToRoam)
10517 {
10518 //Only remove the connected BSS in infrastructure mode
10519 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10520 //Not to do anying for lostlink with WDS
10521 if( pMac->roam.configParam.nRoamingTime )
10522 {
10523 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10524 ( eWNI_SME_DEAUTH_IND == type ) ?
10525 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10526 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010527 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010528 //For IBSS, we need to give some more info to HDD
10529 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10530 {
10531 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10532 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10533 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10534 }
10535 else
10536 {
10537 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10538 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010539 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010540 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10541 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10542 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10543 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10544 }
10545 else
10546 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010547 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010548 fToRoam = eANI_BOOLEAN_FALSE;
10549 }
10550 }
10551 else
10552 {
10553 //We are told not to roam, indicate lostlink
10554 fToRoam = eANI_BOOLEAN_FALSE;
10555 }
10556 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010557 if(!fToRoam)
10558 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010559 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010560 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010561 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010562 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10563 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10564 * csrRoamCheckForLinkStatusChange API.
10565 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010566 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10567 }
10568
10569 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010570 Still enable idle scan for polling in case concurrent sessions are running */
10571 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10572 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010573 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010574 }
10575 }
10576
10577 return (status);
10578}
10579
Jeff Johnson295189b2012-06-20 16:38:30 -070010580eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10581{
10582 eHalStatus status = eHAL_STATUS_SUCCESS;
10583 tListElem *pEntry = NULL;
10584 tSmeCmd *pCommand = NULL;
10585 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010586
10587 if(!pSession)
10588 {
10589 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10590 return eHAL_STATUS_FAILURE;
10591 }
10592
Jeff Johnson295189b2012-06-20 16:38:30 -070010593 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010594 //Only remove the connected BSS in infrastructure mode
10595 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10596 if(pMac->roam.configParam.nRoamingTime)
10597 {
10598 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10599 {
10600 //before starting the lost link logic release the roam command for handoff
10601 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10602 if(pEntry)
10603 {
10604 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10605 }
10606 if(pCommand)
10607 {
10608 if (( eSmeCommandRoam == pCommand->command ) &&
10609 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10610 {
10611 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10612 {
10613 csrReleaseCommandRoam( pMac, pCommand );
10614 }
10615 }
10616 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010617 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010618 }
10619 }
10620 else
10621 {
10622 //We are told not to roam, indicate lostlink
10623 status = eHAL_STATUS_FAILURE;
10624 }
10625
10626 return (status);
10627}
Jeff Johnson295189b2012-06-20 16:38:30 -070010628void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10629{
10630 tListElem *pEntry;
10631 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010632 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10633 if ( pEntry )
10634 {
10635 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10636 if ( eSmeCommandWmStatusChange == pCommand->command )
10637 {
10638 // Nothing to process in a Lost Link completion.... It just kicks off a
10639 // roaming sequence.
10640 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10641 {
10642 csrReleaseCommandWmStatusChange( pMac, pCommand );
10643 }
10644 else
10645 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010646 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010647 }
10648
10649 }
10650 else
10651 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010652 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010653 }
10654 }
10655 else
10656 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010657 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010658 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010659 smeProcessPendingQueue( pMac );
10660}
10661
Jeff Johnson295189b2012-06-20 16:38:30 -070010662void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10663{
10664 eHalStatus status = eHAL_STATUS_FAILURE;
10665 tSirSmeRsp *pSirSmeMsg;
10666 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010667
10668 if(!pSession)
10669 {
10670 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10671 return;
10672 }
10673
Jeff Johnson295189b2012-06-20 16:38:30 -070010674 switch ( pCommand->u.wmStatusChangeCmd.Type )
10675 {
10676 case eCsrDisassociated:
10677 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10678 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10679 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010680 case eCsrDeauthenticated:
10681 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10682 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10683 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010684 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010685 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010686 break;
10687 }
10688 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10689 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10690 {
10691 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10692 {
10693 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010694 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010695 }
10696 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010697 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10698 // command here since there is nothing else to do.
10699 csrRoamWmStatusChangeComplete( pMac );
10700}
10701
Jeff Johnson295189b2012-06-20 16:38:30 -070010702//This function returns band and mode information.
10703//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10704//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010705static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10706 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010707{
Jeff Johnson295189b2012-06-20 16:38:30 -070010708 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10709 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10710 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010711 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010712
Jeff Johnson295189b2012-06-20 16:38:30 -070010713 //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 -070010714 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10715 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10716 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10717 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010718 {
10719 switch( pMac->roam.configParam.uCfgDot11Mode )
10720 {
10721 case eCSR_CFG_DOT11_MODE_11A:
10722 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10723 eBand = eCSR_BAND_5G;
10724 break;
10725 case eCSR_CFG_DOT11_MODE_11B:
10726 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10727 eBand = eCSR_BAND_24;
10728 break;
10729 case eCSR_CFG_DOT11_MODE_11G:
10730 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10731 eBand = eCSR_BAND_24;
10732 break;
10733 case eCSR_CFG_DOT11_MODE_11N:
10734 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010735 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10736 break;
10737#ifdef WLAN_FEATURE_11AC
10738 case eCSR_CFG_DOT11_MODE_11AC:
10739 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10740 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010741 /* If the operating channel is in 2.4 GHz band, check for
10742 * INI item to disable VHT operation in 2.4 GHz band
10743 */
10744 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10745 !pMac->roam.configParam.enableVhtFor24GHz)
10746 {
10747 /* Disable 11AC operation */
10748 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10749 }
10750 else
10751 {
10752 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10753 }
10754 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010755 }
10756 else
10757 {
10758 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10759 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10760 }
10761 break;
10762 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10763 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10764 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010765 /* If the operating channel is in 2.4 GHz band, check for
10766 * INI item to disable VHT operation in 2.4 GHz band
10767 */
10768 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10769 !pMac->roam.configParam.enableVhtFor24GHz)
10770 {
10771 /* Disable 11AC operation */
10772 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10773 }
10774 else
10775 {
10776 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10777 }
10778 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010779 }
10780 else
10781 {
10782 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10783 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10784 }
10785 break;
10786#endif
10787 case eCSR_CFG_DOT11_MODE_AUTO:
10788 eBand = pMac->roam.configParam.eBand;
10789 if (eCSR_BAND_24 == eBand)
10790 {
10791 // WiFi tests require IBSS networks to start in 11b mode
10792 // without any change to the default parameter settings
10793 // on the adapter. We use ACU to start an IBSS through
10794 // creation of a startIBSS profile. This startIBSS profile
10795 // has Auto MACProtocol and the adapter property setting
10796 // for dot11Mode is also AUTO. So in this case, let's
10797 // start the IBSS network in 11b mode instead of 11g mode.
10798 // So this is for Auto=profile->MacProtocol && Auto=Global.
10799 // dot11Mode && profile->channel is < 14, then start the IBSS
10800 // in b mode.
10801 //
10802 // Note: we used to have this start as an 11g IBSS for best
10803 // performance... now to specify that the user will have to
10804 // set the do11Mode in the property page to 11g to force it.
10805 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10806 }
10807 else
10808 {
10809#ifdef WLAN_FEATURE_11AC
10810 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10811 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010812 /* If the operating channel is in 2.4 GHz band, check for
10813 * INI item to disable VHT operation in 2.4 GHz band
10814 */
10815 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10816 !pMac->roam.configParam.enableVhtFor24GHz)
10817 {
10818 /* Disable 11AC operation */
10819 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10820 }
10821 else
10822 {
10823 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10824 }
10825 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010826 }
10827 else
10828 {
10829 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10830 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10831 }
10832#else
10833 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10834 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10835#endif
10836 }
10837 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010838 default:
10839 // Global dot11 Mode setting is 11a/b/g.
10840 // use the channel number to determine the Mode setting.
10841 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10842 {
10843 eBand = pMac->roam.configParam.eBand;
10844 if(eCSR_BAND_24 == eBand)
10845 {
10846 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10847 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10848 }
10849 else
10850 {
10851 //prefer 5GHz
10852 eBand = eCSR_BAND_5G;
10853 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10854 }
10855 }
10856 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10857 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010858 // WiFi tests require IBSS networks to start in 11b mode
10859 // without any change to the default parameter settings
10860 // on the adapter. We use ACU to start an IBSS through
10861 // creation of a startIBSS profile. This startIBSS profile
10862 // has Auto MACProtocol and the adapter property setting
10863 // for dot11Mode is also AUTO. So in this case, let's
10864 // start the IBSS network in 11b mode instead of 11g mode.
10865 // So this is for Auto=profile->MacProtocol && Auto=Global.
10866 // dot11Mode && profile->channel is < 14, then start the IBSS
10867 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010868 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010869 // Note: we used to have this start as an 11g IBSS for best
10870 // performance... now to specify that the user will have to
10871 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010872 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10873 eBand = eCSR_BAND_24;
10874 }
10875 else
10876 {
10877 // else, it's a 5.0GHz channel. Set mode to 11a.
10878 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10879 eBand = eCSR_BAND_5G;
10880 }
10881 break;
10882 }//switch
10883 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10884 else
10885 {
10886 //dot11 mode is set, lets pick the band
10887 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10888 {
10889 // channel is Auto also.
10890 eBand = pMac->roam.configParam.eBand;
10891 if(eCSR_BAND_ALL == eBand)
10892 {
10893 //prefer 5GHz
10894 eBand = eCSR_BAND_5G;
10895 }
10896 }
10897 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10898 {
10899 eBand = eCSR_BAND_24;
10900 }
10901 else
10902 {
10903 eBand = eCSR_BAND_5G;
10904 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010905 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010906 if(pBand)
10907 {
10908 *pBand = eBand;
10909 }
10910
10911 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010912 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010913 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10914 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010915
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010916 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10917 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 -070010918 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010919#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010920 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010921#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010922 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10923 {
10924 //We cannot do 11n here
10925 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10926 {
10927 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10928 }
10929 else
10930 {
10931 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10932 }
10933 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010934 return( cfgDot11Mode );
10935}
10936
Jeff Johnson295189b2012-06-20 16:38:30 -070010937eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10938{
10939 eHalStatus status;
10940 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010941
10942 if(!pSession)
10943 {
10944 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10945 return eHAL_STATUS_FAILURE;
10946 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010947
10948#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10949 {
10950 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010951 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10952 if(pIbssLog)
10953 {
10954 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10955 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10956 }
10957 }
10958#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010959 // Set the roaming substate to 'stop Bss request'...
10960 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10961
10962 // attempt to stop the Bss (reason code is ignored...)
10963 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010964 if(!HAL_STATUS_SUCCESS(status))
10965 {
10966 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10967 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010968 return (status);
10969}
10970
Jeff Johnson295189b2012-06-20 16:38:30 -070010971//pNumChan is a caller allocated space with the sizeof pChannels
10972eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10973{
10974
10975 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10976 (tANI_U8 *)pChannels,
10977 pNumChan));
10978}
10979
Kiran4a17ebe2013-01-31 10:43:43 -080010980tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10981{
10982 tANI_U32 cfgLength = 0;
10983 tANI_U16 cfgId = 0;
10984 tPowerdBm maxTxPwr = 0;
10985 tANI_U8 *pCountryInfo = NULL;
10986 eHalStatus status;
10987 tANI_U8 count = 0;
10988 tANI_U8 firstChannel;
10989 tANI_U8 maxChannels;
10990
10991 if (CSR_IS_CHANNEL_5GHZ(channel))
10992 {
10993 cfgId = WNI_CFG_MAX_TX_POWER_5;
10994 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10995 }
10996 else if (CSR_IS_CHANNEL_24GHZ(channel))
10997 {
10998 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10999 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11000 }
11001 else
11002 return maxTxPwr;
11003
Kiet Lam64c1b492013-07-12 13:56:44 +053011004 pCountryInfo = vos_mem_malloc(cfgLength);
11005 if ( NULL == pCountryInfo )
11006 status = eHAL_STATUS_FAILURE;
11007 else
11008 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011009 if (status != eHAL_STATUS_SUCCESS)
11010 {
11011 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011012 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011013 __FUNCTION__, status);
11014 goto error;
11015 }
11016 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11017 if (status != eHAL_STATUS_SUCCESS)
11018 {
11019 goto error;
11020 }
11021 /* Identify the channel and maxtxpower */
11022 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11023 {
11024 firstChannel = pCountryInfo[count++];
11025 maxChannels = pCountryInfo[count++];
11026 maxTxPwr = pCountryInfo[count++];
11027
11028 if ((channel >= firstChannel) &&
11029 (channel < (firstChannel + maxChannels)))
11030 {
11031 break;
11032 }
11033 }
11034
11035error:
11036 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011037 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011038
11039 return maxTxPwr;
11040}
11041
11042
Jeff Johnson295189b2012-06-20 16:38:30 -070011043tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11044{
11045 tANI_BOOLEAN fValid = FALSE;
11046 tANI_U32 idxValidChannels;
11047 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11048
11049 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11050 {
11051 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11052 {
11053 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11054 {
11055 fValid = TRUE;
11056 break;
11057 }
11058 }
11059 }
11060 pMac->roam.numValidChannels = len;
11061 return fValid;
11062}
11063
Jeff Johnson295189b2012-06-20 16:38:30 -070011064tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11065{
11066 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11067 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011068 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11069 {
11070 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11071 {
11072 fValid = eANI_BOOLEAN_TRUE;
11073 break;
11074 }
11075 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011076 return (fValid);
11077}
11078
Jeff Johnson295189b2012-06-20 16:38:30 -070011079//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011080 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011081{
Jeff Johnsone7245742012-09-05 17:12:55 -070011082 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011083 tANI_U8 centerChn;
11084 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011085
Jeff Johnson295189b2012-06-20 16:38:30 -070011086 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11087 {
11088 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11089 }
11090 else
11091 {
11092 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11093 }
11094 //Figure what the other side's CB mode
11095 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11096 {
11097 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11098 {
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011099 // Check set as TKIP or not.
Praveen Kumar Sirisilla548cf372014-01-16 18:28:59 -080011100 if ((NULL != &(pIes->RSN.pwise_cipher_suites[0][0]) &&
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011101 !memcmp( &(pIes->RSN.pwise_cipher_suites[0][0]),
11102 "\x00\x0f\xac\x02" ,4))
Praveen Kumar Sirisilla548cf372014-01-16 18:28:59 -080011103 || (((NULL != &(pIes->WPA)) &&
11104 (pIes->WPA.unicast_cipher_count == 1))
11105 && ((NULL != &(pIes->WPA.unicast_ciphers[0]))
11106 && memcmp(&(pIes->WPA.unicast_ciphers[0]),
11107 "\x00\x0f\xac\x02", 4))))
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011108 {
11109 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11110 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11111 }
11112
11113 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011114 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011115 /* This is called during INFRA STA/CLIENT and should use the merged value of
11116 * supported channel width and recommended tx width as per standard
11117 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011118 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011119 pIes->HTCaps.supportedChannelWidthSet,
11120 pIes->HTInfo.recommendedTxWidthSet,
11121 pIes->HTInfo.secondaryChannelOffset);
11122
11123 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11124 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011125 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011126 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11127 switch (eRet) {
11128 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11129 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11130 break;
11131 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11132 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11133 break;
11134 case PHY_SINGLE_CHANNEL_CENTERED:
11135 default:
11136 centerChn = primaryChn;
11137 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011138 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011139 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011140 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011141 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070011142 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011143 }
11144 }
11145 }
11146 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011147 return eRet;
11148}
Jeff Johnson295189b2012-06-20 16:38:30 -070011149tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11150{
11151 tANI_BOOLEAN fFound = FALSE;
11152 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011153 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11154 {
11155 if( pCipherList->encryptionType[idx] == encryptionType )
11156 {
11157 fFound = TRUE;
11158 break;
11159 }
11160 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011161 return fFound;
11162}
Jeff Johnson295189b2012-06-20 16:38:30 -070011163tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11164{
11165 tANI_BOOLEAN fFound = FALSE;
11166 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011167 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11168 {
11169 if( pAuthList->authType[idx] == authType )
11170 {
11171 fFound = TRUE;
11172 break;
11173 }
11174 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011175 return fFound;
11176}
Jeff Johnson295189b2012-06-20 16:38:30 -070011177tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11178{
11179 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11180 tCsrScanResultFilter *pScanFilter = NULL;
11181 eHalStatus status = eHAL_STATUS_SUCCESS;
11182
11183 if(pProfile1 && pProfile2)
11184 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011185 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11186 if ( NULL == pScanFilter )
11187 status = eHAL_STATUS_FAILURE;
11188 else
11189 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011190 if(HAL_STATUS_SUCCESS(status))
11191 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011192 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011193 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11194 if(HAL_STATUS_SUCCESS(status))
11195 {
11196 fCheck = eANI_BOOLEAN_FALSE;
11197 do
11198 {
11199 tANI_U32 i;
11200 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11201 {
11202 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11203 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11204 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11205 if ( fCheck ) break;
11206 }
11207 if(!fCheck)
11208 {
11209 break;
11210 }
11211 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11212 || pProfile2->BSSType != pProfile1->BSSType
11213 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11214 )
11215 {
11216 fCheck = eANI_BOOLEAN_FALSE;
11217 break;
11218 }
11219#ifdef WLAN_FEATURE_VOWIFI_11R
11220 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11221 {
11222 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11223 {
11224 fCheck = eANI_BOOLEAN_FALSE;
11225 break;
11226 }
11227 }
11228#endif
11229 //Match found
11230 fCheck = eANI_BOOLEAN_TRUE;
11231 }while(0);
11232 csrFreeScanFilter(pMac, pScanFilter);
11233 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011234 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011235 }
11236 }
11237
11238 return (fCheck);
11239}
11240
Jeff Johnson295189b2012-06-20 16:38:30 -070011241tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11242{
11243 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11244 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011245 do
11246 {
11247 //Only check for static WEP
11248 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11249 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11250 {
11251 fCheck = eANI_BOOLEAN_TRUE;
11252 break;
11253 }
11254 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11255 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11256 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11257 {
11258 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011259 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11260 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011261 {
11262 break;
11263 }
11264 }
11265 if( i == CSR_MAX_NUM_KEY)
11266 {
11267 fCheck = eANI_BOOLEAN_TRUE;
11268 }
11269 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011270 return (fCheck);
11271}
11272
Jeff Johnson295189b2012-06-20 16:38:30 -070011273//IBSS
11274
Jeff Johnson295189b2012-06-20 16:38:30 -070011275tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11276{
11277 tANI_U8 channel = 0;
11278 tANI_U32 idx;
11279 tANI_U32 idxValidChannels;
11280 tANI_BOOLEAN fFound = FALSE;
11281 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11282
11283 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11284 {
11285 channel = pMac->roam.configParam.AdHocChannel5G;
11286 if(!csrRoamIsChannelValid(pMac, channel))
11287 {
11288 channel = 0;
11289 }
11290 }
11291 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11292 {
11293 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11294 {
11295 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11296 {
11297 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11298 {
11299 fFound = TRUE;
11300 channel = csrStartIbssChannels50[ idx ];
11301 }
11302 }
11303 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011304 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11305 if (!fFound)
11306 {
11307 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11308 {
11309 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11310 {
11311 channel = csrStartIbssChannels50[ idx ];
11312 break;
11313 }
11314 }
11315 }
11316 }//if
11317
11318 return( channel );
11319}
11320
Jeff Johnson295189b2012-06-20 16:38:30 -070011321tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11322{
11323 tANI_U8 channel = 1;
11324 tANI_U32 idx;
11325 tANI_U32 idxValidChannels;
11326 tANI_BOOLEAN fFound = FALSE;
11327 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11328
11329 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11330 {
11331 channel = pMac->roam.configParam.AdHocChannel24;
11332 if(!csrRoamIsChannelValid(pMac, channel))
11333 {
11334 channel = 0;
11335 }
11336 }
11337
11338 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11339 {
11340 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11341 {
11342 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11343 {
11344 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11345 {
11346 fFound = TRUE;
11347 channel = csrStartIbssChannels24[ idx ];
11348 }
11349 }
11350 }
11351 }
11352
11353 return( channel );
11354}
11355
Jeff Johnson295189b2012-06-20 16:38:30 -070011356static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11357 tCsrRoamStartBssParams *pParam )
11358{
11359 eCsrCfgDot11Mode cfgDot11Mode;
11360 eCsrBand eBand;
11361 tANI_U8 channel = 0;
11362 tSirNwType nwType;
11363 tANI_U8 operationChannel = 0;
11364
11365 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11366 {
11367 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11368 }
11369
Jeff Johnson295189b2012-06-20 16:38:30 -070011370 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011371
Jeff Johnson295189b2012-06-20 16:38:30 -070011372 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11373 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11374 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11375 )
11376 {
11377 /* This should never happen */
11378 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011379 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011380 pProfile->csrPersona);
11381 VOS_ASSERT(0);
11382 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011383 switch( cfgDot11Mode )
11384 {
11385 case eCSR_CFG_DOT11_MODE_11G:
11386 nwType = eSIR_11G_NW_TYPE;
11387 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011388 case eCSR_CFG_DOT11_MODE_11B:
11389 nwType = eSIR_11B_NW_TYPE;
11390 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011391 case eCSR_CFG_DOT11_MODE_11A:
11392 nwType = eSIR_11A_NW_TYPE;
11393 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011394 default:
11395 case eCSR_CFG_DOT11_MODE_11N:
11396 case eCSR_CFG_DOT11_MODE_TAURUS:
11397 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11398 if(eCSR_BAND_24 == eBand)
11399 {
11400 nwType = eSIR_11G_NW_TYPE;
11401 }
11402 else
11403 {
11404 nwType = eSIR_11A_NW_TYPE;
11405 }
11406 break;
11407 }
11408
11409 pParam->extendedRateSet.numRates = 0;
11410
11411 switch ( nwType )
11412 {
11413 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011414 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011415 case eSIR_11A_NW_TYPE:
11416
11417 pParam->operationalRateSet.numRates = 8;
11418
11419 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11420 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11421 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11422 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11423 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11424 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11425 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11426 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11427
11428 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11429 {
11430 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11431 if( 0 == channel &&
11432 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11433 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11434 )
11435 {
11436 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11437 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11438 nwType = eSIR_11B_NW_TYPE;
11439 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11440 pParam->operationalRateSet.numRates = 4;
11441 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11442 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11443 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11444 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11445 }
11446 }
11447 else
11448 {
11449 channel = operationChannel;
11450 }
11451 break;
11452
11453 case eSIR_11B_NW_TYPE:
11454 pParam->operationalRateSet.numRates = 4;
11455 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11456 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11457 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11458 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011459 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11460 {
11461 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11462 }
11463 else
11464 {
11465 channel = operationChannel;
11466 }
11467
11468 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011469 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011470 /* For P2P Client and P2P GO, disable 11b rates */
11471 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11472 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11473 )
11474 {
11475 pParam->operationalRateSet.numRates = 8;
11476
11477 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11478 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11479 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11480 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11481 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11482 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11483 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11484 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11485 }
11486 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011487 {
11488 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011489 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11490 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11491 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11492 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11493
11494 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011495 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11496 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11497 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11498 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11499 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11500 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11501 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11502 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11503 }
11504
11505 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11506 {
11507 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11508 }
11509 else
11510 {
11511 channel = operationChannel;
11512 }
11513
11514 break;
11515 }
11516 pParam->operationChn = channel;
11517 pParam->sirNwType = nwType;
11518}
11519
Jeff Johnson295189b2012-06-20 16:38:30 -070011520static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11521 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11522{
11523
11524 if( pParam )
11525 {
11526 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011527 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011528 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011529 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011530
11531 if( pIes )
11532 {
11533 if(pIes->SuppRates.present)
11534 {
11535 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11536 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11537 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011538 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 -070011539 pIes->SuppRates.num_rates);
11540 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11541 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011542 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11543 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011544 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011545 if (pIes->ExtSuppRates.present)
11546 {
11547 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
11548 if(pIes->ExtSuppRates.num_rates > SIR_MAC_EXTENDED_RATE_EID_MAX)
11549 {
11550 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11551 SIR_MAC_RATESET_EID_MAX, resetting to \
11552 SIR_MAC_RATESET_EID_MAX"),
11553 pIes->ExtSuppRates.num_rates);
11554 pIes->ExtSuppRates.num_rates = SIR_MAC_EXTENDED_RATE_EID_MAX;
11555 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011556 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011557 pIes->ExtSuppRates.rates,
11558 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11559 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011560 if( pIes->SSID.present )
11561 {
11562 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011563 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11564 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011565 }
11566 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011567 }
11568 else
11569 {
11570 pParam->ssId.length = 0;
11571 pParam->operationalRateSet.numRates = 0;
11572 }
11573 }
11574}
11575
Jeff Johnson295189b2012-06-20 16:38:30 -070011576static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11577{
11578 tANI_U8 MaxRate = 0;
11579 tANI_U32 i;
11580 tANI_U8 *pRate;
11581
11582 pRate = pSirRateSet->rate;
11583 for ( i = 0; i < pSirRateSet->numRates; i++ )
11584 {
11585 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11586 }
11587
11588 // Save the max rate in the connected state information...
11589
11590 // modify LastRates variable as well
11591
11592 return;
11593}
11594
Jeff Johnson295189b2012-06-20 16:38:30 -070011595eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11596 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11597{
11598 eHalStatus status = eHAL_STATUS_SUCCESS;
11599 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011600 // Set the roaming substate to 'Start BSS attempt'...
11601 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011602#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11603 //Need to figure out whether we need to log WDS???
11604 if( CSR_IS_IBSS( pProfile ) )
11605 {
11606 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011607 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11608 if(pIbssLog)
11609 {
11610 if(pBssDesc)
11611 {
11612 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011613 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011614 }
11615 else
11616 {
11617 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11618 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011619 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011620 if(pProfile->ChannelInfo.numOfChannels == 0)
11621 {
11622 pIbssLog->channelSetting = AUTO_PICK;
11623 }
11624 else
11625 {
11626 pIbssLog->channelSetting = SPECIFIED;
11627 }
11628 pIbssLog->operatingChannel = pParam->operationChn;
11629 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11630 }
11631 }
11632#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11633 //Put RSN information in for Starting BSS
11634 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11635 pParam->pRSNIE = pProfile->pRSNReqIE;
11636
Jeff Johnson295189b2012-06-20 16:38:30 -070011637 pParam->privacy = pProfile->privacy;
11638 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11639 pParam->authType = pProfile->csr80211AuthType;
11640 pParam->beaconInterval = pProfile->beaconInterval;
11641 pParam->dtimPeriod = pProfile->dtimPeriod;
11642 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11643 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11644 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11645 {
11646 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11647 {
11648 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11649 }
11650 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011651 pParam->protEnabled = pProfile->protEnabled;
11652 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11653 pParam->ht_protection = pProfile->cfg_protection;
11654 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011655
Jeff Johnson295189b2012-06-20 16:38:30 -070011656 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11657 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011658 pParam->bssPersona = pProfile->csrPersona;
11659 // When starting an IBSS, start on the channel from the Profile.
11660 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011661 return (status);
11662}
11663
Jeff Johnson295189b2012-06-20 16:38:30 -070011664static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011665 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011666{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011667 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011668 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011669 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011670
11671 if(!pSession)
11672 {
11673 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11674 return;
11675 }
11676
Jeff Johnson295189b2012-06-20 16:38:30 -070011677 if( pBssDesc )
11678 {
11679 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11680 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11681 //The following code has to be do after that.
11682 //For WDS station, use selfMac as the self BSSID
11683 if( CSR_IS_WDS_STA( pProfile ) )
11684 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011685 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11686 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011687 }
11688 }
11689 else
11690 {
11691 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011692 //Use the first SSID
11693 if(pProfile->SSIDs.numOfSSIDs)
11694 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011695 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11696 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011697 }
11698 //For WDS station, use selfMac as the self BSSID
11699 if( CSR_IS_WDS_STA( pProfile ) )
11700 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011701 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11702 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011703 }
11704 //Use the first BSSID
11705 else if( pProfile->BSSIDs.numOfBSSIDs )
11706 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011707 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11708 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011709 }
11710 else
11711 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011712 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011713 }
11714 }
11715 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011716 //Set operating channel in pProfile which will be used
11717 //in csrRoamSetBssConfigCfg() to determine channel bonding
11718 //mode and will be configured in CFG later
11719 pProfile->operationChannel = Channel;
11720
11721 if(Channel == 0)
11722 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053011723 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011724 }
11725 else
11726 {
11727
11728 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011729 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011730 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011731 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011732 {
11733 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11734 }
11735 else
11736 {
11737 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11738 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011739 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011740 pBssConfig->cbMode = cbMode;
11741 pSession->bssParams.cbMode = cbMode;
11742 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011743 }
11744}
11745
Jeff Johnson295189b2012-06-20 16:38:30 -070011746static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11747 tANI_BOOLEAN *pfSameIbss )
11748{
11749 eHalStatus status = eHAL_STATUS_SUCCESS;
11750 tANI_BOOLEAN fSameIbss = FALSE;
11751
11752 if ( csrIsConnStateIbss( pMac, sessionId ) )
11753 {
11754 // Check if any profile parameter has changed ? If any profile parameter
11755 // has changed then stop old BSS and start a new one with new parameters
11756 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11757 {
11758 fSameIbss = TRUE;
11759 }
11760 else
11761 {
11762 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11763 }
11764 }
11765 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11766 {
11767 // Disassociate from the connected Infrastructure network...
11768 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11769 }
11770 else
11771 {
11772 tBssConfigParam *pBssConfig;
11773
Kiet Lam64c1b492013-07-12 13:56:44 +053011774 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11775 if ( NULL == pBssConfig )
11776 status = eHAL_STATUS_FAILURE;
11777 else
11778 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011779 if(HAL_STATUS_SUCCESS(status))
11780 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011781 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011782 // there is no Bss description before we start an IBSS so we need to adopt
11783 // all Bss configuration parameters from the Profile.
11784 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11785 if(HAL_STATUS_SUCCESS(status))
11786 {
11787 //save dotMode
11788 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11789 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011790 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011791 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11792 NULL, pBssConfig,
11793 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011794 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011795
11796 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011797 }//Allocate memory
11798 }
11799
11800 if(pfSameIbss)
11801 {
11802 *pfSameIbss = fSameIbss;
11803 }
11804 return( status );
11805}
11806
Jeff Johnson295189b2012-06-20 16:38:30 -070011807static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11808 tSirSmeNewBssInfo *pNewBss )
11809{
11810 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011811
11812 if(!pSession)
11813 {
11814 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11815 return;
11816 }
11817
Jeff Johnson295189b2012-06-20 16:38:30 -070011818 if( pNewBss )
11819 {
11820 // Set the operating channel.
11821 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11822 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011823 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11824 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011825 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 return;
11827}
11828
Jeff Johnson295189b2012-06-20 16:38:30 -070011829#ifdef FEATURE_WLAN_WAPI
11830eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11831 tANI_U32 numItems )
11832{
11833 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11834 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011835 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11836 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011837 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011838 return status;
11839 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011840 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011841 pSession = CSR_GET_SESSION( pMac, sessionId );
11842 if(numItems <= CSR_MAX_BKID_ALLOWED)
11843 {
11844 status = eHAL_STATUS_SUCCESS;
11845 //numItems may be 0 to clear the cache
11846 pSession->NumBkidCache = (tANI_U16)numItems;
11847 if(numItems && pBKIDCache)
11848 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011849 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
11850 sizeof(tBkidCacheInfo) * numItems);
11851 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011852 }
11853 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011854 return (status);
11855}
Jeff Johnson295189b2012-06-20 16:38:30 -070011856eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11857 tBkidCacheInfo *pBkidCache)
11858{
11859 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11860 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011861 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11862 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011863 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011864 return status;
11865 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011866 pSession = CSR_GET_SESSION( pMac, sessionId );
11867 if(pNum && pBkidCache)
11868 {
11869 if(pSession->NumBkidCache == 0)
11870 {
11871 *pNum = 0;
11872 status = eHAL_STATUS_SUCCESS;
11873 }
11874 else if(*pNum >= pSession->NumBkidCache)
11875 {
11876 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11877 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011878 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 -070011879 pSession->NumBkidCache);
11880 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11881 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011882 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
11883 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011884 *pNum = pSession->NumBkidCache;
11885 status = eHAL_STATUS_SUCCESS;
11886 }
11887 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011888 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011889}
Jeff Johnson295189b2012-06-20 16:38:30 -070011890tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11891{
11892 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011893}
11894#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011895eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11896 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11897{
11898 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11899 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011900
11901 if(!pSession)
11902 {
11903 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11904 return eHAL_STATUS_FAILURE;
11905 }
11906
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011907 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011908 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11909 {
11910#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11911 {
11912 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053011913 vos_mem_set(&secEvent,
11914 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011915 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11916 secEvent.encryptionModeMulticast =
11917 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11918 secEvent.encryptionModeUnicast =
11919 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053011920 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011921 secEvent.authMode =
11922 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11923 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11924 }
11925#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011926 status = eHAL_STATUS_SUCCESS;
11927 //numItems may be 0 to clear the cache
11928 pSession->NumPmkidCache = (tANI_U16)numItems;
11929 if(numItems && pPMKIDCache)
11930 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011931 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
11932 sizeof(tPmkidCacheInfo) * numItems);
11933 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011934 }
11935 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011936 return (status);
11937}
11938
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011939eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11940 tANI_U8 *pBSSId )
11941{
11942 eHalStatus status = eHAL_STATUS_FAILURE;
11943 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11944 tANI_BOOLEAN fMatchFound = FALSE;
11945 tANI_U32 Index;
11946 if(!pSession)
11947 {
11948 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11949 return eHAL_STATUS_FAILURE;
11950 }
11951 do
11952 {
11953 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
11954 {
Arif Hussaina7c8e412013-11-20 11:06:42 -080011955 smsLog(pMac, LOGW, "Delete PMKID for "
11956 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Kiet Lamf2f201e2013-11-16 21:24:16 +053011957 if( vos_mem_compare( pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011958 {
11959 fMatchFound = TRUE;
11960 break;
11961 }
11962 }
11963 if( !fMatchFound ) break;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053011964 vos_mem_set(pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid), 0);
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011965 status = eHAL_STATUS_SUCCESS;
11966 }
11967 while( 0 );
11968 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
11969 fMatchFound, status);
11970 return status;
11971}
Jeff Johnson295189b2012-06-20 16:38:30 -070011972tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11973{
11974 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11975}
11976
Jeff Johnson295189b2012-06-20 16:38:30 -070011977eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11978{
11979 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11980 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011981
11982 if(!pSession)
11983 {
11984 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11985 return eHAL_STATUS_FAILURE;
11986 }
11987
Jeff Johnson295189b2012-06-20 16:38:30 -070011988 if(pNum && pPmkidCache)
11989 {
11990 if(pSession->NumPmkidCache == 0)
11991 {
11992 *pNum = 0;
11993 status = eHAL_STATUS_SUCCESS;
11994 }
11995 else if(*pNum >= pSession->NumPmkidCache)
11996 {
11997 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11998 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011999 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 -070012000 pSession->NumPmkidCache);
12001 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12002 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012003 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
12004 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012005 *pNum = pSession->NumPmkidCache;
12006 status = eHAL_STATUS_SUCCESS;
12007 }
12008 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012009 return (status);
12010}
12011
Jeff Johnson295189b2012-06-20 16:38:30 -070012012eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12013{
12014 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12015 tANI_U32 len;
12016 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012017
12018 if(!pSession)
12019 {
12020 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12021 return eHAL_STATUS_FAILURE;
12022 }
12023
Jeff Johnson295189b2012-06-20 16:38:30 -070012024 if(pLen)
12025 {
12026 len = *pLen;
12027 *pLen = pSession->nWpaRsnReqIeLength;
12028 if(pBuf)
12029 {
12030 if(len >= pSession->nWpaRsnReqIeLength)
12031 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012032 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12033 pSession->nWpaRsnReqIeLength);
12034 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012035 }
12036 }
12037 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012038 return (status);
12039}
12040
Jeff Johnson295189b2012-06-20 16:38:30 -070012041eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12042{
12043 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12044 tANI_U32 len;
12045 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012046
12047 if(!pSession)
12048 {
12049 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12050 return eHAL_STATUS_FAILURE;
12051 }
12052
Jeff Johnson295189b2012-06-20 16:38:30 -070012053 if(pLen)
12054 {
12055 len = *pLen;
12056 *pLen = pSession->nWpaRsnRspIeLength;
12057 if(pBuf)
12058 {
12059 if(len >= pSession->nWpaRsnRspIeLength)
12060 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012061 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12062 pSession->nWpaRsnRspIeLength);
12063 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012064 }
12065 }
12066 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012067 return (status);
12068}
Jeff Johnson295189b2012-06-20 16:38:30 -070012069#ifdef FEATURE_WLAN_WAPI
12070eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12071{
12072 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12073 tANI_U32 len;
12074 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012075
12076 if(!pSession)
12077 {
12078 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12079 return eHAL_STATUS_FAILURE;
12080 }
12081
Jeff Johnson295189b2012-06-20 16:38:30 -070012082 if(pLen)
12083 {
12084 len = *pLen;
12085 *pLen = pSession->nWapiReqIeLength;
12086 if(pBuf)
12087 {
12088 if(len >= pSession->nWapiReqIeLength)
12089 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012090 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12091 pSession->nWapiReqIeLength);
12092 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012093 }
12094 }
12095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012096 return (status);
12097}
Jeff Johnson295189b2012-06-20 16:38:30 -070012098eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12099{
12100 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12101 tANI_U32 len;
12102 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012103
12104 if(!pSession)
12105 {
12106 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12107 return eHAL_STATUS_FAILURE;
12108 }
12109
Jeff Johnson295189b2012-06-20 16:38:30 -070012110 if(pLen)
12111 {
12112 len = *pLen;
12113 *pLen = pSession->nWapiRspIeLength;
12114 if(pBuf)
12115 {
12116 if(len >= pSession->nWapiRspIeLength)
12117 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012118 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12119 pSession->nWapiRspIeLength);
12120 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012121 }
12122 }
12123 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012124 return (status);
12125}
12126#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012127eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12128{
12129 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12130 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012131
12132 if(!pSession)
12133 {
12134 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12135 return (retStatus);
12136 }
12137
Jeff Johnson295189b2012-06-20 16:38:30 -070012138 if(CSR_IS_ROAMING(pSession))
12139 {
12140 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12141 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12142 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012143 return (retStatus);
12144}
12145
Jeff Johnson295189b2012-06-20 16:38:30 -070012146//This function remove the connected BSS from te cached scan result
12147eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12148 tCsrRoamConnectedProfile *pConnProfile)
12149{
12150 eHalStatus status = eHAL_STATUS_FAILURE;
12151 tCsrScanResultFilter *pScanFilter = NULL;
12152 tListElem *pEntry;
12153 tCsrScanResult *pResult;
12154 tDot11fBeaconIEs *pIes;
12155 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012156 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12157 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12158 {
12159 do
12160 {
12161 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012162 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12163 if ( NULL == pScanFilter )
12164 status = eHAL_STATUS_FAILURE;
12165 else
12166 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012167 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012168 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12169 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12170 if ( NULL == pScanFilter->BSSIDs.bssid )
12171 status = eHAL_STATUS_FAILURE;
12172 else
12173 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012174 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012175 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12176 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012177 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12178 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12179 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012180 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12181 if ( NULL == pScanFilter->SSIDs.SSIDList )
12182 status = eHAL_STATUS_FAILURE;
12183 else
12184 status = eHAL_STATUS_SUCCESS;
12185 if (!HAL_STATUS_SUCCESS(status)) break;
12186 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12187 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012188 }
12189 pScanFilter->authType.numEntries = 1;
12190 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12191 pScanFilter->BSSType = pConnProfile->BSSType;
12192 pScanFilter->EncryptionType.numEntries = 1;
12193 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12194 pScanFilter->mcEncryptionType.numEntries = 1;
12195 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12196 //We ignore the channel for now, BSSID should be enough
12197 pScanFilter->ChannelInfo.numOfChannels = 0;
12198 //Also ignore the following fields
12199 pScanFilter->uapsd_mask = 0;
12200 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
12201 pScanFilter->countryCode[0] = 0;
12202 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012203 csrLLLock(&pMac->scan.scanResultList);
12204 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12205 while( pEntry )
12206 {
12207 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12208 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12209 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12210 pScanFilter, NULL, NULL, NULL, &pIes);
12211 //Release the IEs allocated by csrMatchBSS is needed
12212 if( !pResult->Result.pvIes )
12213 {
12214 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012215 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012216 }
12217 if(fMatch)
12218 {
12219 //We found the one
12220 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12221 {
12222 //Free the memory
12223 csrFreeScanResultEntry( pMac, pResult );
12224 }
12225 break;
12226 }
12227 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12228 }//while
12229 csrLLUnlock(&pMac->scan.scanResultList);
12230 }while(0);
12231 if(pScanFilter)
12232 {
12233 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012234 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012235 }
12236 }
12237 return (status);
12238}
12239
Jeff Johnson295189b2012-06-20 16:38:30 -070012240//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012241eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12242{
12243 eHalStatus status = eHAL_STATUS_SUCCESS;
12244 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012245 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12246 {
12247 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12248 {
12249 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12250 {
12251 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012252 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012253 status = eHAL_STATUS_CSR_WRONG_STATE;
12254 break;
12255 }
12256 if( csrIsConnStateInfra( pMac, sessionId ) )
12257 {
12258 if( chnId &&
12259 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012261 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012262 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12263 status = eHAL_STATUS_CSR_WRONG_STATE;
12264 break;
12265 }
12266 }
12267 }
12268 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012269 return ( status );
12270}
12271
Jeff Johnson295189b2012-06-20 16:38:30 -070012272static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12273{
12274 eHalStatus status = eHAL_STATUS_SUCCESS;
12275 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12276 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012277
12278 if(!pSession)
12279 {
12280 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12281 return eHAL_STATUS_FAILURE;
12282 }
12283
Jeff Johnson295189b2012-06-20 16:38:30 -070012284 if ( csrIsConnStateIbss( pMac, sessionId ) )
12285 {
12286 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12287 }
12288 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12289 {
12290 // Disassociate from the connected Infrastructure network...
12291 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12292 }
12293 else
12294 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012295 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12296 //Otherwise we need to add code to handle the
12297 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12298 //send stop_bss to PE, before we can continue.
12299 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012300 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012301 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012302 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12303 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012304 // there is no Bss description before we start an WDS so we need
12305 // to adopt all Bss configuration parameters from the Profile.
12306 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12307 if(HAL_STATUS_SUCCESS(status))
12308 {
12309 //Save profile for late use
12310 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012311 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12312 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012313 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012314 vos_mem_set(pSession->pCurRoamProfile,
12315 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012316 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12317 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012318 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012319 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012320 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12321 NULL, &bssConfig,
12322 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012323 }
12324 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012325
Jeff Johnson295189b2012-06-20 16:38:30 -070012326 return( status );
12327}
12328
Jeff Johnson295189b2012-06-20 16:38:30 -070012329////////////////////Mail box
12330
Jeff Johnson295189b2012-06-20 16:38:30 -070012331//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12332//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012333static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12334 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012335 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12336{
12337 tCsrChannelSet channelGroup;
12338 tSirMacCapabilityInfo *pAP_capabilityInfo;
12339 tAniBool fTmp;
12340 tANI_BOOLEAN found = FALSE;
12341 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012342 tANI_S8 pwrLimit = 0;
12343 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012344 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12345 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12346 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12347 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012348 // 802.11h
12349 //We can do this because it is in HOST CPU order for now.
12350 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012351 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12352 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12353 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012354 fTmp = (tAniBool)pal_cpu_to_be32(1);
12355 }
12356 else
12357 fTmp = (tAniBool)0;
12358
12359 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012360 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012361 pBuf += sizeof(tAniBool);
12362 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012363 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012364 // This is required for 11k test VoWiFi Ent: Test 2.
12365 // We need the power capabilities for Assoc Req.
12366 // This macro is provided by the halPhyCfg.h. We pick our
12367 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012368 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12369 if (0 != pwrLimit)
12370 {
12371 *pBuf++ = pwrLimit;
12372 }
12373 else
12374 {
12375 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12376 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012377 size = sizeof(pMac->roam.validChannelList);
12378 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12379 {
12380 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12381 for ( i = 0; i < size; i++)
12382 {
12383 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12384
12385 }
12386 }
12387 else
12388 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012389 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012390 *pBuf++ = 0; //tSirSupChnl->numChnl
12391 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012392 //Check whether it is ok to enter UAPSD
12393#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12394 if( btcIsReadyForUapsd(pMac) )
12395#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12396 {
12397 *pBuf++ = uapsdMask;
12398 }
12399#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12400 else
12401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012402 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012403 *pBuf++ = 0;
12404 }
12405#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12406
Jeff Johnson295189b2012-06-20 16:38:30 -070012407 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012408 vos_mem_copy(pBuf, pBssDescription,
12409 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012410 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12411}
12412
Jeff Johnson295189b2012-06-20 16:38:30 -070012413/*
12414 * The communication between HDD and LIM is thru mailbox (MB).
12415 * Both sides will access the data structure "tSirSmeJoinReq".
12416 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12417 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12418 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12419 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12420 */
12421eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012422 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012423{
12424 eHalStatus status = eHAL_STATUS_SUCCESS;
12425 tSirSmeJoinReq *pMsg;
12426 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012427 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012428 tANI_U16 msgLen, wTmp, ieLen;
12429 tSirMacRateSet OpRateSet;
12430 tSirMacRateSet ExRateSet;
12431 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12432 tANI_U32 dwTmp;
12433 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012434 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012435
12436 if(!pSession)
12437 {
12438 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12439 return eHAL_STATUS_FAILURE;
12440 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012441 /* To satisfy klockworks */
12442 if (NULL == pBssDescription)
12443 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012444 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012445 return eHAL_STATUS_FAILURE;
12446 }
12447
Jeff Johnson295189b2012-06-20 16:38:30 -070012448 do {
12449 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12450 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012451 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012452 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12453 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12454 // IE fields, but the length field in the bssDescription needs to be interpreted to
12455 // determine length of the IE fields.
12456 //
12457 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12458 // add in the length from the bssDescription (then add the size of the 'length' field
12459 // itself because that is NOT included in the length field).
12460 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12461 pBssDescription->length + sizeof( pBssDescription->length ) +
12462 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 +053012463 pMsg = vos_mem_malloc(msgLen);
12464 if (NULL == pMsg)
12465 status = eHAL_STATUS_FAILURE;
12466 else
12467 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012468 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012469 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012470 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012471 pMsg->length = pal_cpu_to_be16(msgLen);
12472 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012473 // sessionId
12474 *pBuf = (tANI_U8)sessionId;
12475 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012476 // transactionId
12477 *pBuf = 0;
12478 *( pBuf + 1 ) = 0;
12479 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012480 // ssId
12481 if( pIes->SSID.present && pIes->SSID.num_ssid )
12482 {
12483 // ssId len
12484 *pBuf = pIes->SSID.num_ssid;
12485 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012486 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012487 pBuf += pIes->SSID.num_ssid;
12488 }
12489 else
12490 {
12491 *pBuf = 0;
12492 pBuf++;
12493 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012494 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012495 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12496 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012497 pBuf += sizeof(tSirMacAddr);
12498 // bsstype
12499 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12500 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012501 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012502 pBuf += sizeof(tSirBssType);
12503 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012504 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12505 if (pBssDescription->channelId <= 14 &&
12506 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12507 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12508 {
12509 //Need to disable VHT operation in 2.4 GHz band
12510 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12511 }
12512 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012513 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012514 //Persona
12515 *pBuf = (tANI_U8)pProfile->csrPersona;
12516 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012517 //CBMode
12518 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12519 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012520
12521 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012522 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12523
Jeff Johnson295189b2012-06-20 16:38:30 -070012524 // uapsdPerAcBitmask
12525 *pBuf = pProfile->uapsd_mask;
12526 pBuf++;
12527
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012528
12529
Jeff Johnson295189b2012-06-20 16:38:30 -070012530 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012531 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012532 {
12533 // OperationalRateSet
12534 if (OpRateSet.numRates) {
12535 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012536 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012537 pBuf += OpRateSet.numRates;
12538 } else *pBuf++ = 0;
12539 // ExtendedRateSet
12540 if (ExRateSet.numRates) {
12541 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012542 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012543 pBuf += ExRateSet.numRates;
12544 } else *pBuf++ = 0;
12545 }
12546 else
12547 {
12548 *pBuf++ = 0;
12549 *pBuf++ = 0;
12550 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012551 // rsnIE
12552 if ( csrIsProfileWpa( pProfile ) )
12553 {
12554 // Insert the Wpa IE into the join request
12555 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12556 (tCsrWpaIe *)( wpaRsnIE ) );
12557 }
12558 else if( csrIsProfileRSN( pProfile ) )
12559 {
12560 // Insert the RSN IE into the join request
12561 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12562 (tCsrRSNIe *)( wpaRsnIE ) );
12563 }
12564#ifdef FEATURE_WLAN_WAPI
12565 else if( csrIsProfileWapi( pProfile ) )
12566 {
12567 // Insert the WAPI IE into the join request
12568 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12569 (tCsrWapiIe *)( wpaRsnIE ) );
12570 }
12571#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012572 else
12573 {
12574 ieLen = 0;
12575 }
12576 //remember the IE for future use
12577 if( ieLen )
12578 {
12579 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12580 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012581 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 -070012582 ieLen = DOT11F_IE_RSN_MAX_LEN;
12583 }
12584#ifdef FEATURE_WLAN_WAPI
12585 if( csrIsProfileWapi( pProfile ) )
12586 {
12587 //Check whether we need to allocate more memory
12588 if(ieLen > pSession->nWapiReqIeLength)
12589 {
12590 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12591 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012592 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012593 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012594 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12595 if (NULL == pSession->pWapiReqIE)
12596 status = eHAL_STATUS_FAILURE;
12597 else
12598 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012599 if(!HAL_STATUS_SUCCESS(status)) break;
12600 }
12601 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012602 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012603 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012604 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012605 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012606 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012607 pBuf += ieLen;
12608 }
12609 else//should be WPA/WPA2 otherwise
12610#endif /* FEATURE_WLAN_WAPI */
12611 {
12612 //Check whether we need to allocate more memory
12613 if(ieLen > pSession->nWpaRsnReqIeLength)
12614 {
12615 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12616 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012617 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012618 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012619 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12620 if (NULL == pSession->pWpaRsnReqIE)
12621 status = eHAL_STATUS_FAILURE;
12622 else
12623 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012624 if(!HAL_STATUS_SUCCESS(status)) break;
12625 }
12626 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012627 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012628 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012629 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012630 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012631 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012632 pBuf += ieLen;
12633 }
12634 }
12635 else
12636 {
12637 //free whatever old info
12638 pSession->nWpaRsnReqIeLength = 0;
12639 if(pSession->pWpaRsnReqIE)
12640 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012641 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012642 pSession->pWpaRsnReqIE = NULL;
12643 }
12644#ifdef FEATURE_WLAN_WAPI
12645 pSession->nWapiReqIeLength = 0;
12646 if(pSession->pWapiReqIE)
12647 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012648 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012649 pSession->pWapiReqIE = NULL;
12650 }
12651#endif /* FEATURE_WLAN_WAPI */
12652 //length is two bytes
12653 *pBuf = 0;
12654 *(pBuf + 1) = 0;
12655 pBuf += 2;
12656 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012657#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012658 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012659 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012660 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012661 //length is two bytes
12662 *pBuf = 0;
12663 *(pBuf + 1) = 0;
12664 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012665 }
12666 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012667 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012668 // cckmIE
12669 if( csrIsProfileCCX( pProfile ) )
12670 {
12671 // Insert the CCKM IE into the join request
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012672#ifdef FEATURE_WLAN_CCX_UPLOAD
12673 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080012674 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012675 pSession->suppCckmIeInfo.cckmIe, ieLen);
12676#else
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012677 ieLen = csrConstructCcxCckmIe( pMac,
12678 pSession,
12679 pProfile,
12680 pBssDescription,
12681 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012682 pSession->nWpaRsnReqIeLength,
12683 (void *)( wpaRsnIE ) );
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012684#endif /* FEATURE_WLAN_CCX_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012685 }
12686 else
12687 {
12688 ieLen = 0;
12689 }
12690 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12691 if( ieLen )
12692 {
12693 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12694 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012695 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012696 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012697 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012698 pBuf += ieLen;
12699 }
12700 else
12701 {
12702 //Indicate you have no CCKM IE
12703 //length is two bytes
12704 *pBuf = 0;
12705 *(pBuf + 1) = 0;
12706 pBuf += 2;
12707 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012708 }
12709#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012710 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053012711 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070012712 {
12713 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012714 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012715 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012716 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012717 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012718 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012719 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053012720 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012721 pBuf += ieLen;
12722 }
12723 else
12724 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053012725 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012726 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012727 *pBuf = 0;
12728 *(pBuf + 1) = 0;
12729 pBuf += 2;
12730 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012731 // addIEAssoc
12732 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12733 {
12734 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012735 if(ieLen > pSession->nAddIEAssocLength)
12736 {
12737 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012738 {
12739 vos_mem_free(pSession->pAddIEAssoc);
12740 }
12741 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12742 if (NULL == pSession->pAddIEAssoc)
12743 status = eHAL_STATUS_FAILURE;
12744 else
12745 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012746 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012747 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012748 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012749 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012750 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012751 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012752 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012753 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012754 pBuf += ieLen;
12755 }
12756 else
12757 {
12758 pSession->nAddIEAssocLength = 0;
12759 if(pSession->pAddIEAssoc)
12760 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012761 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012762 pSession->pAddIEAssoc = NULL;
12763 }
12764 *pBuf = 0;
12765 *(pBuf + 1) = 0;
12766 pBuf += 2;
12767 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012768
12769 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012771 //Unmask any AC in reassoc that is ACM-set
12772 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12773 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012774 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012775 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12776 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012777#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012778 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012779#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012780 uapsd_mask &= ~(acm_mask);
12781 }
12782 else
12783 {
12784 uapsd_mask = 0;
12785 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012786 }
12787 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012788
Jeff Johnson295189b2012-06-20 16:38:30 -070012789 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012790 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012791 pBuf += sizeof(tANI_U32);
12792
Jeff Johnson295189b2012-06-20 16:38:30 -070012793 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012794 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012795 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012796#ifdef WLAN_FEATURE_11W
12797 //MgmtEncryption
12798 if (pProfile->MFPEnabled)
12799 {
12800 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12801 }
12802 else
12803 {
12804 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12805 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012806 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012807 pBuf += sizeof(tANI_U32);
12808#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012809#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012810 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012811 if (csrIsProfile11r( pProfile )
12812#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012813 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12814 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012815#endif
12816 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012817 {
12818 // is11Rconnection;
12819 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012820 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012821 pBuf += sizeof(tAniBool);
12822 }
12823 else
12824 {
12825 // is11Rconnection;
12826 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012827 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012828 pBuf += sizeof(tAniBool);
12829 }
12830#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012831#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012832
12833 // isCCXFeatureIniEnabled
12834 if (TRUE == pMac->roam.configParam.isCcxIniFeatureEnabled)
12835 {
12836 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012837 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012838 pBuf += sizeof(tAniBool);
12839 }
12840 else
12841 {
12842 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080012843 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012844 pBuf += sizeof(tAniBool);
12845 }
12846
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012847 /* A profile can not be both CCX and 11R. But an 802.11R AP
12848 * may be advertising support for CCX as well. So if we are
12849 * associating Open or explicitly CCX then we will get CCX.
12850 * If we are associating explictly 11R only then we will get
12851 * 11R.
12852 */
12853 if ((csrIsProfileCCX(pProfile) ||
12854 ((pIes->CCXVersion.present)
12855 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012856 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12857 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12858 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012859#ifdef WLAN_FEATURE_11W
12860 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12861#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012862 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012863 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12864 {
12865 // isCCXconnection;
12866 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012867 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012868 pBuf += sizeof(tAniBool);
12869 }
12870 else
12871 {
12872 //isCCXconnection;
12873 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012874 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012875 pBuf += sizeof(tAniBool);
12876 }
12877
12878 if (eWNI_SME_JOIN_REQ == messageType)
12879 {
12880 tCCXTspecInfo ccxTspec;
12881 // CCX-Tspec IEs in the ASSOC request is presently not supported
12882 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012883 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12884 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012885 pBuf += sizeof(tCCXTspecInfo);
12886 }
12887 else if (eWNI_SME_REASSOC_REQ == messageType)
12888 {
12889 if ((csrIsProfileCCX(pProfile) ||
12890 ((pIes->CCXVersion.present)
12891 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012892 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12893 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12894 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012895#ifdef WLAN_FEATURE_11W
12896 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12897#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012898 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012899 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012900 {
12901 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012902 // CCX Tspec information
Kiet Lam64c1b492013-07-12 13:56:44 +053012903 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012904 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12905 *pBuf = ccxTspec.numTspecs;
12906 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012907 // Copy the TSPEC information only if present
12908 if (ccxTspec.numTspecs) {
Kiet Lam64c1b492013-07-12 13:56:44 +053012909 vos_mem_copy(pBuf, (void*)&ccxTspec.tspec[0],
12910 (ccxTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070012911 }
12912 pBuf += sizeof(ccxTspec.tspec);
12913 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012914 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012915 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012916 tCCXTspecInfo ccxTspec;
12917 // CCX-Tspec IEs in the ASSOC request is presently not supported
12918 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012919 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12920 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070012921 pBuf += sizeof(tCCXTspecInfo);
12922 }
12923 }
12924#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012925#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012926 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012927 if (pMac->roam.configParam.isFastTransitionEnabled
12928#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012929 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012930#endif
12931 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012932 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012933 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012934 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012935 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012936 }
12937 else
12938 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012939 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012940 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012941 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012942 }
12943#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012944#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012945 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012946 {
12947 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012948 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012949 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012950 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012951 }
12952 else
12953 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012954 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012955 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012956 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012957 }
12958#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012959
12960 // txLdpcIniFeatureEnabled
12961 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12962 pBuf++;
12963
Kiran4a17ebe2013-01-31 10:43:43 -080012964 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12965 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12966 {
12967 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12968 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12969 csrApplyPower2Current(pMac);
12970 }
12971
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012972#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012973 // txBFIniFeatureEnabled
12974 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12975 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012976
12977 // txBFCsnValue
12978 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12979 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012980#endif
krunal soni5afa96c2013-09-06 22:19:02 -070012981 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
12982 pBuf++;
12983
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053012984 // WME
12985 if(pMac->roam.roamSession[sessionId].fWMMConnection)
12986 {
12987 //WME enabled
12988 dwTmp = pal_cpu_to_be32(TRUE);
12989 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
12990 pBuf += sizeof(tAniBool);
12991 }
12992 else
12993 {
12994 dwTmp = pal_cpu_to_be32(FALSE);
12995 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
12996 pBuf += sizeof(tAniBool);
12997 }
12998
12999 // QOS
13000 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13001 {
13002 //QOS enabled
13003 dwTmp = pal_cpu_to_be32(TRUE);
13004 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13005 pBuf += sizeof(tAniBool);
13006 }
13007 else
13008 {
13009 dwTmp = pal_cpu_to_be32(FALSE);
13010 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13011 pBuf += sizeof(tAniBool);
13012 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013013 //BssDesc
13014 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13015 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013016
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013017 status = palSendMBMessage(pMac->hHdd, pMsg );
13018 if(!HAL_STATUS_SUCCESS(status))
13019 {
13020 break;
13021 }
13022 else
13023 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013024#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013025 if (eWNI_SME_JOIN_REQ == messageType)
13026 {
13027 //Tush-QoS: notify QoS module that join happening
13028 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13029 }
13030 else if (eWNI_SME_REASSOC_REQ == messageType)
13031 {
13032 //Tush-QoS: notify QoS module that reassoc happening
13033 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13034 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013035#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013036 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013037 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013038 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013039}
13040
Jeff Johnson295189b2012-06-20 16:38:30 -070013041//
13042eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13043{
13044 eHalStatus status = eHAL_STATUS_SUCCESS;
13045 tSirSmeDisassocReq *pMsg;
13046 tANI_U8 *pBuf;
13047 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013048 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13049 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13050 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013051 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013052 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13053 if (NULL == pMsg)
13054 status = eHAL_STATUS_FAILURE;
13055 else
13056 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013057 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013058 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013059 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13060 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013061 pBuf = &pMsg->sessionId;
13062 // sessionId
13063 *pBuf++ = (tANI_U8)sessionId;
13064 // transactionId
13065 *pBuf = 0;
13066 *( pBuf + 1 ) = 0;
13067 pBuf += sizeof(tANI_U16);
13068
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013069 if ( (pSession->pCurRoamProfile != NULL) &&
13070 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13071 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013072 {
13073 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013074 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13075 sizeof( tSirMacAddr ));
13076 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013077 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013078 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013079 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13080 //perMacAddr is passed as bssId for softAP
13081 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013082 pBuf = pBuf + sizeof ( tSirMacAddr );
13083 }
13084 else
13085 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013086 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013087 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13088 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013089 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013090 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13091 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013092 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013093 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013094 if(!HAL_STATUS_SUCCESS(status))
13095 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013096 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013097 break;
13098 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013099 // reasonCode
13100 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013101 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13102 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013103 if(!HAL_STATUS_SUCCESS(status))
13104 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013105 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013106 break;
13107 }
13108 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013109 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13110 Here we should not send the disassoc over the air to the AP */
13111 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13112#ifdef WLAN_FEATURE_VOWIFI_11R
13113 && csrRoamIs11rAssoc(pMac)
13114#endif
13115 )
13116 {
13117 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13118 }
13119 pBuf += sizeof(tANI_U8);
13120 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013121 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013122 return( status );
13123}
Jeff Johnson295189b2012-06-20 16:38:30 -070013124eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13125{
13126 eHalStatus status = eHAL_STATUS_SUCCESS;
13127 tSirSmeTkipCntrMeasReq *pMsg;
13128 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013129 do
13130 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013131 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13132 if ( NULL == pMsg )
13133 status = eHAL_STATUS_FAILURE;
13134 else
13135 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013136 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013137 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013138 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13139 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013140 pBuf = &pMsg->sessionId;
13141 // sessionId
13142 *pBuf++ = (tANI_U8)sessionId;
13143 // transactionId
13144 *pBuf = 0;
13145 *( pBuf + 1 ) = 0;
13146 pBuf += sizeof(tANI_U16);
13147 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013148 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13149 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013150 pBuf = pBuf + sizeof ( tSirMacAddr );
13151 // bEnable
13152 *pBuf = (tANI_BOOLEAN)bEnable;
13153 if(!HAL_STATUS_SUCCESS(status))
13154 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013155 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 break;
13157 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013158 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013159 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013160 return( status );
13161}
Jeff Johnson295189b2012-06-20 16:38:30 -070013162eHalStatus
13163csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13164 VOS_MODULE_ID modId, tSirMacAddr bssId,
13165 void *pUsrContext, void *pfnSapEventCallback,
13166 tANI_U8 *pAssocStasBuf )
13167{
13168 eHalStatus status = eHAL_STATUS_SUCCESS;
13169 tSirSmeGetAssocSTAsReq *pMsg;
13170 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13171 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013172 do
13173 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013174 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13175 if ( NULL == pMsg )
13176 status = eHAL_STATUS_FAILURE;
13177 else
13178 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013179 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013180 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013181 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013182 pBuf = (tANI_U8 *)&pMsg->bssId;
13183 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013184 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013185 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013186 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013187 // modId
13188 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013189 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013190 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013191 // pUsrContext
13192 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013193 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013194 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013195 // pfnSapEventCallback
13196 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013197 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013198 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013199 // pAssocStasBuf
13200 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
Kiet Lam64c1b492013-07-12 13:56:44 +053013201 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013202 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013203 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013204 status = palSendMBMessage( pMac->hHdd, pMsg );
13205 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013206 return( status );
13207 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013208eHalStatus
13209csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13210 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13211 {
13212 eHalStatus status = eHAL_STATUS_SUCCESS;
13213 tSirSmeGetWPSPBCSessionsReq *pMsg;
13214 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13215 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 do
13217 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013218 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13219 if ( NULL == pMsg )
13220 status = eHAL_STATUS_FAILURE;
13221 else
13222 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013223 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013224 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013225 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013226 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013227 VOS_ASSERT(pBuf);
13228
Jeff Johnson295189b2012-06-20 16:38:30 -070013229 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 // pUsrContext
13231 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013232 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013233 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013234 // pSapEventCallback
13235 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013236 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013238 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013239 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013240 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013241 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013242 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013243 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013244 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013246 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013247 return( status );
13248}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013249
13250eHalStatus
13251csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13252{
13253 tpSirChangeBIParams pMsg;
13254 tANI_U16 len = 0;
13255 eHalStatus status = eHAL_STATUS_SUCCESS;
13256 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13257
13258 if(!pSession)
13259 {
13260 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13261 return eHAL_STATUS_FAILURE;
13262 }
13263
13264 //NO need to update the Beacon Params if update beacon parameter flag is not set
13265 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13266 return eHAL_STATUS_SUCCESS;
13267
13268 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13269
13270 /* Create the message and send to lim */
13271 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013272 pMsg = vos_mem_malloc(len);
13273 if ( NULL == pMsg )
13274 status = eHAL_STATUS_FAILURE;
13275 else
13276 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013277 if(HAL_STATUS_SUCCESS(status))
13278 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013279 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013280 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13281 pMsg->length = len;
13282
13283 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013284 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13285 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013286 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13287 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013288 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013289 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013290 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13291 status = palSendMBMessage(pMac->hHdd, pMsg);
13292 }
13293 return status;
13294}
13295
Jeff Johnson295189b2012-06-20 16:38:30 -070013296eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13297{
13298 eHalStatus status = eHAL_STATUS_SUCCESS;
13299 tSirSmeDeauthReq *pMsg;
13300 tANI_U8 *pBuf;
13301 tANI_U16 wTmp;
13302 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13303 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13304 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013305 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013306 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13307 if ( NULL == pMsg )
13308 status = eHAL_STATUS_FAILURE;
13309 else
13310 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013311 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013312 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013313 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13314 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13315 //sessionId
13316 pBuf = &pMsg->sessionId;
13317 *pBuf++ = (tANI_U8)sessionId;
13318
13319 //tansactionId
13320 *pBuf = 0;
13321 *(pBuf + 1 ) = 0;
13322 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013324 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013325 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13326 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013327 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13328 sizeof( pMsg->peerMacAddr ) );
13329 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013330 pBuf = pBuf + sizeof(tSirMacAddr);
13331 }
13332 else
13333 {
13334 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013335 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13336 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013337 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 }
13339 if(!HAL_STATUS_SUCCESS(status))
13340 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013341 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013342 break;
13343 }
13344 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013345 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13346 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013347 pBuf = pBuf + sizeof(tSirMacAddr);
13348 if(!HAL_STATUS_SUCCESS(status))
13349 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013350 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013351 break;
13352 }
13353 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013354 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13355 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013356 if(!HAL_STATUS_SUCCESS(status))
13357 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013358 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013359 break;
13360 }
13361 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013362 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013363 return( status );
13364}
13365
Jeff Johnson295189b2012-06-20 16:38:30 -070013366eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13367{
13368 eHalStatus status = eHAL_STATUS_SUCCESS;
13369 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013370 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013371 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13372 if ( NULL == pMsg )
13373 status = eHAL_STATUS_FAILURE;
13374 else
13375 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013376 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013377 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013378 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13379 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13380 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013381 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13382 sizeof(pMsg->peerMacAddr));
13383 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013384 if(!HAL_STATUS_SUCCESS(status))
13385 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013386 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013387 break;
13388 }
13389//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013390 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13391 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013392 if(!HAL_STATUS_SUCCESS(status))
13393 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013394 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013395 break;
13396 }
13397//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013398 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013399 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013400 return( status );
13401}
13402
Jeff Johnson295189b2012-06-20 16:38:30 -070013403eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13404{
13405 eHalStatus status = eHAL_STATUS_SUCCESS;
13406 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013407 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013408 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13409 if ( NULL == pMsg )
13410 status = eHAL_STATUS_FAILURE;
13411 else
13412 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013413 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013414 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013415 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13416 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13417 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013418 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13419 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013420 if(!HAL_STATUS_SUCCESS(status))
13421 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013422 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013423 break;
13424 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013425 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13426 sizeof(pMsg->peerMacAddr));
13427 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013428 if(!HAL_STATUS_SUCCESS(status))
13429 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013430 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013431 break;
13432 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013433 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013434 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013435 return( status );
13436}
Jeff Johnson295189b2012-06-20 16:38:30 -070013437eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13438{
13439 eHalStatus status = eHAL_STATUS_SUCCESS;
13440 tSirSmeAssocCnf *pMsg;
13441 tANI_U8 *pBuf;
13442 tSirResultCodes statusCode;
13443 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013444 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013445 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13446 if ( NULL == pMsg )
13447 status = eHAL_STATUS_FAILURE;
13448 else
13449 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013450 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013451 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013452 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13453 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013454 pBuf = (tANI_U8 *)&pMsg->statusCode;
13455 if(HAL_STATUS_SUCCESS(Halstatus))
13456 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13457 else
13458 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013459 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013460 pBuf += sizeof(tSirResultCodes);
13461 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013462 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13463 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013464 pBuf += sizeof (tSirMacAddr);
13465 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013466 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13467 sizeof(tSirMacAddr));
13468 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013469 pBuf += sizeof (tSirMacAddr);
13470 // aid
13471 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013472 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013473 pBuf += sizeof (tANI_U16);
13474 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013475 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13476 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013477 pBuf += sizeof (tSirMacAddr);
13478 // alternateChannelId
13479 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013480 status = palSendMBMessage( pMac->hHdd, pMsg );
13481 if(!HAL_STATUS_SUCCESS(status))
13482 {
13483 //pMsg is freed by palSendMBMessage
13484 break;
13485 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013486 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013487 return( status );
13488}
Jeff Johnson295189b2012-06-20 16:38:30 -070013489eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13490 tpSirSmeAssocInd pAssocInd,
13491 eHalStatus Halstatus,
13492 tANI_U8 sessionId)
13493{
13494 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13496 tANI_U8 *pBuf;
13497 tSirResultCodes statusCode;
13498 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013499 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013500 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13501 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13502 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013503
Jeff Johnson295189b2012-06-20 16:38:30 -070013504 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13505 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13506
13507 pMsg->sessionId = sessionId;
13508
13509 pBuf = (tANI_U8 *)&pMsg->statusCode;
13510 if(HAL_STATUS_SUCCESS(Halstatus))
13511 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13512 else
13513 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013514 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013515 pBuf += sizeof(tSirResultCodes);
13516 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013517 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013518 pBuf += sizeof (tSirMacAddr);
13519 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013520 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13521 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013522 pBuf += sizeof (tSirMacAddr);
13523 // StaId
13524 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013525 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013526 pBuf += sizeof (tANI_U16);
13527 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013528 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013529 pBuf += sizeof (tSirMacAddr);
13530 // alternateChannelId
13531 *pBuf = 11;
13532 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013533 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013534 //Wmm
13535 *pBuf = pAssocInd->wmmEnabledSta;
13536 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013537 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013538 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013539 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013540 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013541 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013542 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013543 //reassocReq
13544 *pBuf = pAssocInd->reassocReq;
13545 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13547 msgQ.bodyptr = pMsg;
13548 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013549 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013550 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013551 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013552}
Jeff Johnson295189b2012-06-20 16:38:30 -070013553
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013554eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013555 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13556 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13557 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13558 tANI_U8 *pKeyRsc )
13559{
13560 tSirSmeSetContextReq *pMsg;
13561 tANI_U16 msgLen;
13562 eHalStatus status = eHAL_STATUS_FAILURE;
13563 tAniEdType tmpEdType;
13564 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013565 tANI_U8 *pBuf = NULL;
13566 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013567 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013568 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013569 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013570 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13571 // key set. Since we only support upto one key, we always allocate memory for 1 key
13572 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13573 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13574 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13575 ( sizeof( pMsg->keyMaterial.key ) );
13576
Kiet Lam64c1b492013-07-12 13:56:44 +053013577 pMsg = vos_mem_malloc(msgLen);
13578 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13579 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013580 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13581 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013582 //sessionId
13583 pBuf = &pMsg->sessionId;
13584 *pBuf = (tANI_U8)sessionId;
13585 pBuf++;
13586 // transactionId
13587 *pBuf = 0;
13588 *(pBuf + 1) = 0;
13589 pBuf += sizeof(tANI_U16);
13590 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013591 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013592
13593 pBuf += sizeof(tSirMacAddr);
13594
13595 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013596 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13597 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013598
13599 pBuf += sizeof(tSirMacAddr);
13600
13601 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013602 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13603 // in the tSirKeyMaterial keyMaterial; field).
13604 //
13605 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13606 // shorter than this max size. Is LIM interpreting this ok ?
13607 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 -070013608 // set pMsg->keyMaterial.edType
13609 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013610 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013611 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013612 // set the pMsg->keyMaterial.numKeys field
13613 *p = numKeys;
13614 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013615 // set pSirKey->keyId = keyId;
13616 *p = keyId;
13617 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013618 // set pSirKey->unicast = (tANI_U8)fUnicast;
13619 *p = (tANI_U8)fUnicast;
13620 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013621 // set pSirKey->keyDirection = aniKeyDirection;
13622 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013623 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013624 p += sizeof(tAniKeyDirection);
13625 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013626 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013627 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013628 // set pSirKey->paeRole
13629 *p = paeRole; // 0 is Supplicant
13630 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013631 // set pSirKey->keyLength = keyLength;
13632 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013633 if ( keyLength && pKey )
13634 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013635 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013636 if(keyLength == 16)
13637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013638 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 -070013639 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13640 pKey[5], pKey[6], pKey[7], pKey[8],
13641 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13642 }
13643 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013644 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013646 return( status );
13647}
13648
Jeff Johnson295189b2012-06-20 16:38:30 -070013649eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13650 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13651{
13652 eHalStatus status;
13653 tSirSmeStartBssReq *pMsg;
13654 tANI_U8 *pBuf = NULL;
13655 tANI_U8 *wTmpBuf = NULL;
13656 tANI_U16 msgLen, wTmp;
13657 tANI_U32 dwTmp;
13658 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013659 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013660 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013661 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013662
13663 if(!pSession)
13664 {
13665 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13666 return eHAL_STATUS_FAILURE;
13667 }
13668
Jeff Johnson295189b2012-06-20 16:38:30 -070013669 do {
13670 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13671 pSession->joinFailStatusCode.reasonCode = 0;
13672 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013673 pMsg = vos_mem_malloc(msgLen);
13674 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13675 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013676 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013677 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013678 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013679 //sessionId
13680 *pBuf = (tANI_U8)sessionId;
13681 pBuf++;
13682 // transactionId
13683 *pBuf = 0;
13684 *(pBuf + 1) = 0;
13685 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013686 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013687 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013688 pBuf += sizeof(tSirMacAddr);
13689 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013690 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013691 pBuf += sizeof(tSirMacAddr);
13692 // beaconInterval
13693 if( pBssDesc && pBssDesc->beaconInterval )
13694 {
13695 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13696 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013697 else if(pParam->beaconInterval)
13698 {
13699 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13700 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013701 else
13702 {
13703 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13704 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013705 if(csrIsconcurrentsessionValid (pMac, sessionId,
13706 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013707 == eHAL_STATUS_SUCCESS )
13708 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013709 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013710 pParam->bssPersona);
13711 //Update the beacon Interval
13712 pParam->beaconInterval = wTmp;
13713 }
13714 else
13715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013716 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013717 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013718 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013719 return status;
13720 }
13721
Kiet Lam64c1b492013-07-12 13:56:44 +053013722 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013723 pBuf += sizeof(tANI_U16);
13724 // dot11mode
13725 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13726 pBuf += 1;
13727 // bssType
13728 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013729 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013730 pBuf += sizeof(tSirBssType);
13731 // ssId
13732 if( pParam->ssId.length )
13733 {
13734 // ssId len
13735 *pBuf = pParam->ssId.length;
13736 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013737 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013738 pBuf += pParam->ssId.length;
13739 }
13740 else
13741 {
13742 *pBuf = 0;
13743 pBuf++;
13744 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013745 // set the channel Id
13746 *pBuf = pParam->operationChn;
13747 pBuf++;
13748 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013749 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013750 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013751 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013752
Jeff Johnson295189b2012-06-20 16:38:30 -070013753 // Set privacy
13754 *pBuf = pParam->privacy;
13755 pBuf++;
13756
13757 //Set Uapsd
13758 *pBuf = pParam->ApUapsdEnable;
13759 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013760 //Set SSID hidden
13761 *pBuf = pParam->ssidHidden;
13762 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13764 pBuf++;
13765
13766 //Ht protection Enable/Disable
13767 *pBuf = (tANI_U8)pParam->protEnabled;
13768 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013769 //Enable Beacons to Receive for OBSS protection Enable/Disable
13770 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13771 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 //set cfg related to protection
13773 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013774 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013775 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013776 // Set Auth type
13777 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013778 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013779 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013780 // Set DTIM
13781 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013782 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013784 // Set wps_state
13785 *pBuf = pParam->wps_state;
13786 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080013787 // set isCoalesingInIBSSAllowed
13788 *pBuf = pMac->isCoalesingInIBSSAllowed;
13789 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013790 //Persona
13791 *pBuf = (tANI_U8)pParam->bssPersona;
13792 pBuf++;
13793
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013794 //txLdpcIniFeatureEnabled
13795 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13796 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013797
krunal soni4f087d22013-07-29 16:32:26 -070013798 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013799 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13800 {
13801 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013802 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013803 break;
13804 }
13805 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013806 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013807 pBuf += sizeof(tANI_U16);
13808 if( wTmp )
13809 {
13810 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013811 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013812 pBuf += wTmp;
13813 }
13814 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013815 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013816 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013817 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13818 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013819 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13820 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013821 pBuf += pParam->operationalRateSet.numRates ;
13822 *pBuf++ = pParam->extendedRateSet.numRates;
13823 if(0 != pParam->extendedRateSet.numRates)
13824 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013825 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13826 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013827 pBuf += pParam->extendedRateSet.numRates;
13828 }
krunal sonie9002db2013-11-25 14:24:17 -080013829
Jeff Johnson295189b2012-06-20 16:38:30 -070013830 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13831 pMsg->length = pal_cpu_to_be16(msgLen);
13832
13833 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013834 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013835 return( status );
13836}
13837
Jeff Johnson295189b2012-06-20 16:38:30 -070013838eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13839{
13840 eHalStatus status = eHAL_STATUS_FAILURE;
13841 tSirSmeStopBssReq *pMsg;
13842 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13843 tANI_U8 *pBuf;
13844 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013845
13846 if(!pSession)
13847 {
13848 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13849 return eHAL_STATUS_FAILURE;
13850 }
13851
Jeff Johnson295189b2012-06-20 16:38:30 -070013852 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013853 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13854 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13855 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013856 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13857 pBuf = &pMsg->sessionId;
13858 //sessionId
13859 *pBuf = (tANI_U8)sessionId;
13860 pBuf++;
13861 // transactionId
13862 *pBuf = 0;
13863 pBuf += sizeof(tANI_U16);
13864 //reason code
13865 *pBuf = 0;
13866 pBuf += sizeof(tSirResultCodes);
13867 // bssid
13868 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13869 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13870 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013871 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
13872 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013873 }
13874 else
13875 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013876 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13877 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013878 }
13879 pBuf += sizeof(tSirMacAddr);
13880 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13881 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013882 status = palSendMBMessage( pMac->hHdd, pMsg );
13883#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053013884 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13885 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13886 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013887 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13888 pMsg->reasonCode = 0;
13889 // bssid
13890 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13891 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13892 {
13893 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13894 }
13895 else
13896 {
13897 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13898 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013899 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013900 pMsg->transactionId = 0;
13901 pMsg->sessionId = (tANI_U8)sessionId;
13902 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13903 status = palSendMBMessage( pMac->hHdd, pMsg );
13904#endif
13905 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013906 return( status );
13907}
13908
Jeff Johnson295189b2012-06-20 16:38:30 -070013909eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13910 tCsrRoamModifyProfileFields *pModProfileFields,
13911 tANI_U32 *pRoamId, v_BOOL_t fForce)
13912{
Jeff Johnson295189b2012-06-20 16:38:30 -070013913 eHalStatus status = eHAL_STATUS_FAILURE;
13914 tANI_U32 roamId = 0;
13915 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013916 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053013917 (fForce || (!vos_mem_compare( &pModProfileFields,
13918 &pSession->connectedProfile.modifyProfileFields,
13919 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013920 {
13921 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13922 if(pRoamId)
13923 {
13924 *pRoamId = roamId;
13925 }
13926
Jeff Johnson295189b2012-06-20 16:38:30 -070013927 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13928 eCsrSmeIssuedReassocToSameAP, roamId,
13929 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013930 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013931 return status;
13932}
Jeff Johnson295189b2012-06-20 16:38:30 -070013933static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13934{
13935 eHalStatus status = eHAL_STATUS_SUCCESS;
13936 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053013937 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013938 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13939 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13940 return (status);
13941}
Jeff Johnson295189b2012-06-20 16:38:30 -070013942eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13943{
13944 eHalStatus status = eHAL_STATUS_SUCCESS;
13945 tListElem *pEntry = NULL;
13946 tSmeCmd *pCommand = NULL;
13947 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013948 do
13949 {
13950 if(pMsg == NULL)
13951 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013952 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013953 status = eHAL_STATUS_FAILURE;
13954 break;
13955 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13957 if(pEntry)
13958 {
13959 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13960 if(eSmeCommandAddStaSession == pCommand->command)
13961 {
13962 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013963 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013964 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013965 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013966 //Remove this command out of the active list
13967 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13968 {
13969 //Now put this command back on the avilable command list
13970 csrReleaseCommand(pMac, pCommand);
13971 }
13972 smeProcessPendingQueue( pMac );
13973 }
13974 else
13975 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013976 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 -070013977 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013978 status = eHAL_STATUS_FAILURE;
13979 break;
13980 }
13981 }
13982 else
13983 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013984 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 -070013985 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013986 status = eHAL_STATUS_FAILURE;
13987 break;
13988 }
13989 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013990 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013991}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013992eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
13993 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070013994{
13995 tSirSmeAddStaSelfReq *pMsg;
13996 tANI_U16 msgLen;
13997 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013998 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013999 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014000 pMsg = vos_mem_malloc(msgLen);
14001 if ( NULL == pMsg ) break;
14002 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014003 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14004 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014005 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014006 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014007 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14008
14009 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14010
Arif Hussain24bafea2013-11-15 15:10:03 -080014011 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14012 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014014 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014015 return( status );
14016}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014017eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14018 tANI_U32 sessionId,
14019 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014020{
14021 eHalStatus status = eHAL_STATUS_SUCCESS;
14022 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014023 pCommand = csrGetCommandBuffer(pMac);
14024 if(NULL == pCommand)
14025 {
14026 status = eHAL_STATUS_RESOURCES;
14027 }
14028 else
14029 {
14030 pCommand->command = eSmeCommandAddStaSession;
14031 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014032 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14033 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014034 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014035 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14036 if( !HAL_STATUS_SUCCESS( status ) )
14037 {
14038 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014039 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014040 }
14041 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014042 return (status);
14043}
Jeff Johnson295189b2012-06-20 16:38:30 -070014044eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14045{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014046 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014047}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014048eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14049 csrRoamCompleteCallback callback,
14050 void *pContext, tANI_U8 *pSelfMacAddr,
14051 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014052{
14053 eHalStatus status = eHAL_STATUS_SUCCESS;
14054 tANI_U32 i;
14055 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014056 *pbSessionId = CSR_SESSION_ID_INVALID;
14057 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14058 {
14059 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14060 {
14061 pSession = CSR_GET_SESSION( pMac, i );
14062 status = eHAL_STATUS_SUCCESS;
14063 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14064 pSession->sessionId = (tANI_U8)i;
14065 pSession->callback = callback;
14066 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014067 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014068 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014069 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14070 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014071 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014072 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014073 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014074 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014075 break;
14076 }
14077#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014078 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14079 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014080 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014081 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014082 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014083 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014084 break;
14085 }
14086#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014087 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014088 break;
14089 }
14090 }
14091 if( CSR_ROAM_SESSION_MAX == i )
14092 {
14093 //No session is available
14094 status = eHAL_STATUS_RESOURCES;
14095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014096 return ( status );
14097}
Jeff Johnson295189b2012-06-20 16:38:30 -070014098eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14099{
14100 eHalStatus status = eHAL_STATUS_SUCCESS;
14101 tListElem *pEntry = NULL;
14102 tSmeCmd *pCommand = NULL;
14103 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014104 do
14105 {
14106 if(pMsg == NULL)
14107 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014108 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014109 status = eHAL_STATUS_FAILURE;
14110 break;
14111 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014112 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14113 if(pEntry)
14114 {
14115 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14116 if(eSmeCommandDelStaSession == pCommand->command)
14117 {
14118 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014119 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014120 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014121 //This session is done.
14122 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014123 if(pCommand->u.delStaSessionCmd.callback)
14124 {
14125
14126 status = sme_ReleaseGlobalLock( &pMac->sme );
14127 if ( HAL_STATUS_SUCCESS( status ) )
14128 {
14129 pCommand->u.delStaSessionCmd.callback(
14130 pCommand->u.delStaSessionCmd.pContext);
14131 status = sme_AcquireGlobalLock( &pMac->sme );
14132 if (! HAL_STATUS_SUCCESS( status ) )
14133 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014134 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014135 return status;
14136 }
14137 }
14138 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014139 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014140 }
14141 }
14142
14143 //Remove this command out of the active list
14144 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14145 {
14146 //Now put this command back on the avilable command list
14147 csrReleaseCommand(pMac, pCommand);
14148 }
14149 smeProcessPendingQueue( pMac );
14150 }
14151 else
14152 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014153 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 -070014154 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014155 status = eHAL_STATUS_FAILURE;
14156 break;
14157 }
14158 }
14159 else
14160 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014161 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 -070014162 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014163 status = eHAL_STATUS_FAILURE;
14164 break;
14165 }
14166 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014167 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014168}
Jeff Johnson295189b2012-06-20 16:38:30 -070014169eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14170{
14171 tSirSmeDelStaSelfReq *pMsg;
14172 tANI_U16 msgLen;
14173 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014174 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014175 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14176 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014177 pMsg = vos_mem_malloc(msgLen);
14178 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14179 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014180 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14181 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014182 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014183 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14184 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014185 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014186 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014187 return( status );
14188}
Jeff Johnson295189b2012-06-20 16:38:30 -070014189eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14190 tSirMacAddr sessionMacAddr,
14191 csrRoamSessionCloseCallback callback,
14192 void *pContext)
14193{
14194 eHalStatus status = eHAL_STATUS_SUCCESS;
14195 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014196 pCommand = csrGetCommandBuffer(pMac);
14197 if(NULL == pCommand)
14198 {
14199 status = eHAL_STATUS_RESOURCES;
14200 }
14201 else
14202 {
14203 pCommand->command = eSmeCommandDelStaSession;
14204 pCommand->sessionId = (tANI_U8)sessionId;
14205 pCommand->u.delStaSessionCmd.callback = callback;
14206 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014207 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14208 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014209 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14210 if( !HAL_STATUS_SUCCESS( status ) )
14211 {
14212 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014213 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014214 }
14215 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014216 return (status);
14217}
Jeff Johnson295189b2012-06-20 16:38:30 -070014218eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14219{
14220 return csrSendMBDelSelfStaReqMsg( pMac,
14221 pCommand->u.delStaSessionCmd.selfMacAddr );
14222}
Jeff Johnson295189b2012-06-20 16:38:30 -070014223static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14224{
14225 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14226 tListElem *pEntry, *pNext;
14227 tSmeCmd *pCommand;
14228 tDblLinkList localList;
14229
14230 vos_mem_zero(&localList, sizeof(tDblLinkList));
14231 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14232 {
14233 smsLog(pMac, LOGE, FL(" failed to open list"));
14234 return;
14235 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014236 csrLLLock(pList);
14237 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14238 while(pEntry != NULL)
14239 {
14240 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14241 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14242 if(pCommand->sessionId == sessionId)
14243 {
14244 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14245 {
14246 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14247 }
14248 }
14249 pEntry = pNext;
14250 }
14251 csrLLUnlock(pList);
14252
14253 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14254 {
14255 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14256 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14257 }
14258 csrLLClose(&localList);
14259}
14260
Jeff Johnson295189b2012-06-20 16:38:30 -070014261void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14262{
14263 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14264 {
14265 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014266 csrRoamStop(pMac, sessionId);
14267 csrFreeConnectBssDesc(pMac, sessionId);
14268 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14269 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014270 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014271#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014272 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014273#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014274 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14275 if (pMac->fScanOffload)
14276 {
14277 purgeSmeSessionCmdList(pMac, sessionId,
14278 &pMac->sme.smeScanCmdPendingList);
14279 }
14280
Jeff Johnson295189b2012-06-20 16:38:30 -070014281 purgeCsrSessionCmdList(pMac, sessionId);
14282 csrInitSession(pMac, sessionId);
14283 }
14284}
14285
Jeff Johnson295189b2012-06-20 16:38:30 -070014286eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14287 tANI_BOOLEAN fSync,
14288 csrRoamSessionCloseCallback callback,
14289 void *pContext )
14290{
14291 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014292 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14293 {
14294 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14295 if(fSync)
14296 {
14297 csrCleanupSession(pMac, sessionId);
14298 }
14299 else
14300 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014301 purgeSmeSessionCmdList(pMac, sessionId,
14302 &pMac->sme.smeCmdPendingList);
14303 if (pMac->fScanOffload)
14304 {
14305 purgeSmeSessionCmdList(pMac, sessionId,
14306 &pMac->sme.smeScanCmdPendingList);
14307 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014308 purgeCsrSessionCmdList(pMac, sessionId);
14309 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14310 pSession->selfMacAddr, callback, pContext);
14311 }
14312 }
14313 else
14314 {
14315 status = eHAL_STATUS_INVALID_PARAMETER;
14316 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014317 return ( status );
14318}
14319
Jeff Johnson295189b2012-06-20 16:38:30 -070014320static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14321{
14322 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014323
14324 if(!pSession)
14325 {
14326 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14327 return;
14328 }
14329
Jeff Johnson295189b2012-06-20 16:38:30 -070014330 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14331 pSession->sessionId = CSR_SESSION_ID_INVALID;
14332 pSession->callback = NULL;
14333 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014334 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14335 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14336 csrFreeRoamProfile( pMac, sessionId );
14337 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14338 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14339 csrFreeConnectBssDesc(pMac, sessionId);
14340 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014341 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14342 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014343 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014344 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014345 pSession->pWpaRsnReqIE = NULL;
14346 }
14347 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014348 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014349 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014350 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014351 pSession->pWpaRsnRspIE = NULL;
14352 }
14353 pSession->nWpaRsnRspIeLength = 0;
14354#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014355 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014356 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014357 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014358 pSession->pWapiReqIE = NULL;
14359 }
14360 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014361 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014362 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014363 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014364 pSession->pWapiRspIE = NULL;
14365 }
14366 pSession->nWapiRspIeLength = 0;
14367#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014368 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014369 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014370 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014371 }
14372 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014373
Kiet Lam64c1b492013-07-12 13:56:44 +053014374 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014375 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014376 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014377 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014378 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014379 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014380}
14381
Jeff Johnson295189b2012-06-20 16:38:30 -070014382eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14383{
14384 eHalStatus status = eHAL_STATUS_FAILURE;
14385 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014386 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14387 {
14388 if( CSR_IS_SESSION_VALID( pMac, i ) )
14389 {
14390 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14391 {
14392 //Found it
14393 status = eHAL_STATUS_SUCCESS;
14394 *pSessionId = i;
14395 break;
14396 }
14397 }
14398 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014399 return( status );
14400}
14401
Jeff Johnson295189b2012-06-20 16:38:30 -070014402//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14403//session because for IBSS, the bssid changes.
14404static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14405{
14406 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14407 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014408 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14409 {
14410 if( CSR_IS_SESSION_VALID( pMac, i ) )
14411 {
14412 pSession = CSR_GET_SESSION( pMac, i );
14413 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14414 {
14415 //Found it
14416 nRet = i;
14417 break;
14418 }
14419 }
14420 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014421 return (nRet);
14422}
Jeff Johnson295189b2012-06-20 16:38:30 -070014423static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14424{
14425 /* Update the current BSS info in ho control block based on connected
14426 profile info from pmac global structure */
14427
Arif Hussain24bafea2013-11-15 15:10:03 -080014428 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14429 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014430 /* Check for user misconfig of RSSI trigger threshold */
14431 pMac->roam.configParam.vccRssiThreshold =
14432 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14433 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14434 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014435 /* Check for user misconfig of UL MAC Loss trigger threshold */
14436 pMac->roam.configParam.vccUlMacLossThreshold =
14437 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14438 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014439#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14440 {
14441 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014442 /* Indicate the neighbor roal algorithm about the connect indication */
14443 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14444 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14445 }
14446#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014447}
14448
Jeff Johnson295189b2012-06-20 16:38:30 -070014449static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14450{
14451 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014452
14453 if(!pSession)
14454 {
14455 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14456 return;
14457 }
14458
Jeff Johnson295189b2012-06-20 16:38:30 -070014459 //Only to handle the case for Handover on infra link
14460 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14461 {
14462 return;
14463 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014464 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14465 csrRoamDeregStatisticsReq(pMac);
14466 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14467#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14468 /* Indicate the neighbor roal algorithm about the disconnect indication */
14469 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14470#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014471
14472 //Remove this code once SLM_Sessionization is supported
14473 //BMPS_WORKAROUND_NOT_NEEDED
14474 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014475 csrIsInfraApStarted( pMac ) &&
14476 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014477 {
14478 pMac->roam.configParam.doBMPSWorkaround = 0;
14479 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014480}
14481
Jeff Johnson295189b2012-06-20 16:38:30 -070014482void csrRoamTlStatsTimerHandler(void *pv)
14483{
14484 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14485 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014486 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14487
Jeff Johnsone7245742012-09-05 17:12:55 -070014488 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14489
Jeff Johnson295189b2012-06-20 16:38:30 -070014490#if 0
14491 // TODO Persession .???
14492 //req TL for stats
14493 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14494 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014495 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014496 }
14497 else
14498 {
14499 //save in SME
14500 csrRoamSaveStatsFromTl(pMac, tlStats);
14501 }
14502#endif
14503 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14504 {
14505 if(pMac->roam.tlStatsReqInfo.periodicity)
14506 {
14507 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014508 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14509 pMac->roam.tlStatsReqInfo.periodicity);
14510 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014511 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014512 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014513 return;
14514 }
14515 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14516 }
14517 }
14518}
Jeff Johnson295189b2012-06-20 16:38:30 -070014519void csrRoamPeStatsTimerHandler(void *pv)
14520{
14521 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14522 eHalStatus status;
14523 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14524 VOS_STATUS vosStatus;
14525 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014526 pPeStatsReqListEntry->timerRunning = FALSE;
14527 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14528 {
14529 // If we entered here, meaning the timer could not be successfully
14530 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14531
14532 /* Destroy the timer */
14533 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14534 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14535 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014536 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014537 }
14538
14539 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014540 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014541 pPeStatsReqListEntry = NULL;
14542 }
14543 else
14544 {
14545 if(!pPeStatsReqListEntry->rspPending)
14546 {
14547 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14548 pPeStatsReqListEntry->staId);
14549 if(!HAL_STATUS_SUCCESS(status))
14550 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014551 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014552 }
14553 else
14554 {
14555 pPeStatsReqListEntry->rspPending = TRUE;
14556 }
14557 }
14558
14559 //send down a req
14560 if(pPeStatsReqListEntry->periodicity &&
14561 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14562 {
14563 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14564 if(ePMC_FULL_POWER == powerState)
14565 {
14566 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14567 {
14568 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14569 }
14570 }
14571 else
14572 {
14573 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14574 {
14575 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14576 }
14577 }
14578 //start timer
14579 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14580 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14581 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014582 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014583 return;
14584 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014585 pPeStatsReqListEntry->timerRunning = TRUE;
14586
14587 }
14588
14589 }
14590}
Jeff Johnson295189b2012-06-20 16:38:30 -070014591void csrRoamStatsClientTimerHandler(void *pv)
14592{
14593 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014594 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14595 {
14596#if 0
14597 // TODO Stats fix for multisession
14598 //start the timer
14599 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14600
14601 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14602 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014603 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014604 }
14605#endif
14606 }
14607#if 0
14608 //send up the stats report
14609 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14610 pStaEntry->staId, pStaEntry->pContext);
14611#endif
14612}
14613
14614
14615
Jeff Johnson295189b2012-06-20 16:38:30 -070014616eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14617{
14618 tAniGetPEStatsReq *pMsg;
14619 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014620 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14621 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014622 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014623 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053014624 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014625 }
14626 // need to initiate a stats request to PE
14627 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14628 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14629 pMsg->staId = staId;
14630 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014631 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014632 if(!HAL_STATUS_SUCCESS(status))
14633 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014634 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070014635 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014636 return status;
14637}
Jeff Johnson295189b2012-06-20 16:38:30 -070014638void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14639{
14640 tAniGetPEStatsRsp *pSmeStatsRsp;
14641 eHalStatus status = eHAL_STATUS_FAILURE;
14642 tListElem *pEntry = NULL;
14643 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14644 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14645 tANI_U32 tempMask = 0;
14646 tANI_U8 counter = 0;
14647 tANI_U8 *pStats = NULL;
14648 tANI_U32 length = 0;
14649 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014650 v_S7_t rssi = 0, snr = 0;
14651 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014652 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014653 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14654 if(pSmeStatsRsp->rc)
14655 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014656 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014657 goto post_update;
14658 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014659 tempMask = pSmeStatsRsp->statsMask;
14660 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014661 /* subtract all statistics from this length, and after processing the entire
14662 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14663 * in this 'stats' message.
14664 */
14665 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014666 //new stats info from PE, fill up the stats strucutres in PMAC
14667 while(tempMask)
14668 {
14669 if(tempMask & 1)
14670 {
14671 switch(counter)
14672 {
14673 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014674 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014675 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14676 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014677 pStats += sizeof(tCsrSummaryStatsInfo);
14678 length -= sizeof(tCsrSummaryStatsInfo);
14679 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014680 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014681 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014682 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14683 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014684 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14685 length -= sizeof(tCsrGlobalClassAStatsInfo);
14686 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014687 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014688 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014689 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14690 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014691 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14692 length -= sizeof(tCsrGlobalClassBStatsInfo);
14693 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014694 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014695 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014696 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14697 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014698 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14699 length -= sizeof(tCsrGlobalClassCStatsInfo);
14700 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014701 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014702 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014703 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14704 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014705 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14706 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014707 }
14708 else
14709 {
14710 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014711 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014712 VOS_ASSERT( 0 );
14713 }
14714 if(!HAL_STATUS_SUCCESS(status))
14715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014716 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014717 }
14718 pStats += sizeof(tCsrPerStaStatsInfo);
14719 length -= sizeof(tCsrPerStaStatsInfo);
14720 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014721 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014722 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014723 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014724 }
14725 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014726 tempMask >>=1;
14727 counter++;
14728 }
14729 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14730 if (length != 0)
14731 {
14732 pRssi = (tANI_U32*)pStats;
14733 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014734 pStats += sizeof(tANI_U32);
14735 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014736 }
14737 else
14738 {
14739 /* If riva is not sending rssi, continue to use the hack */
14740 rssi = RSSI_HACK_BMPS;
14741 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014742
Jeff Johnson295189b2012-06-20 16:38:30 -070014743 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014744
14745 if (length != 0)
14746 {
14747 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014748 pStats += sizeof(tANI_U32);
14749 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014750 }
14751 else
14752 {
14753 linkCapacity = 0;
14754 }
14755
14756 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014757
14758 if (length != 0)
14759 {
14760 pSnr = (tANI_U32*)pStats;
14761 snr = (v_S7_t)*pSnr;
14762 }
14763 else
14764 {
14765 snr = SNR_HACK_BMPS;
14766 }
14767
14768 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014769post_update:
14770 //make sure to update the pe stats req list
14771 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14772 if(pEntry)
14773 {
14774 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14775 pPeStaEntry->rspPending = FALSE;
14776
14777 }
14778 //check the one timer cases
14779 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14780 if(pEntry)
14781 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014782 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014783 if(pTempStaEntry->timerExpired)
14784 {
14785 //send up the stats report
14786 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14787 pTempStaEntry->staId, pTempStaEntry->pContext);
14788 //also remove from the client list
14789 csrRoamRemoveStatListEntry(pMac, pEntry);
14790 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014791 }
14792 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014793}
Jeff Johnson295189b2012-06-20 16:38:30 -070014794tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14795{
14796 tListElem *pEntry = NULL;
14797 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014798 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014799 if(!pEntry)
14800 {
14801 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014802 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014803 return NULL;
14804 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014805 while( pEntry )
14806 {
14807 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014808 if(pTempStaEntry->statsMask == statsMask)
14809 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014810 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014811 break;
14812 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014813 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14814 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014815 return pEntry;
14816}
14817
Jeff Johnson295189b2012-06-20 16:38:30 -070014818tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14819 tANI_BOOLEAN update)
14820{
14821 tListElem *pEntry;
14822 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014823 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014824 if(!pEntry)
14825 {
14826 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014827 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014828 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014829 return NULL;
14830 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014831 while( pEntry )
14832 {
14833 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014834 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14835 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14836 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014837 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014838 if(update)
14839 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014840 pTempStaEntry->periodicity = pStaEntry->periodicity;
14841 pTempStaEntry->callback = pStaEntry->callback;
14842 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014843 }
14844 break;
14845 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014846 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14847 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014848 return pEntry;
14849}
Jeff Johnson295189b2012-06-20 16:38:30 -070014850tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14851{
14852 tListElem *pEntry;
14853 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014854 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014855 if(!pEntry)
14856 {
14857 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014858 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014859 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014860 return NULL;
14861 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014862 while( pEntry )
14863 {
14864 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014865 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14866 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014867 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014868 break;
14869 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014870 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14871 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014872 return pEntry;
14873}
Jeff Johnson295189b2012-06-20 16:38:30 -070014874eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14875 csrRoamLinkQualityIndCallback callback,
14876 void *pContext)
14877{
14878 pMac->roam.linkQualityIndInfo.callback = callback;
14879 pMac->roam.linkQualityIndInfo.context = pContext;
14880 if( NULL == callback )
14881 {
14882 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14883 }
14884 else
14885 {
14886 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014887 /* do we need to invoke the callback to notify client of initial value ?? */
14888 }
14889 return eHAL_STATUS_SUCCESS;
14890}
Jeff Johnson295189b2012-06-20 16:38:30 -070014891void csrRoamVccTrigger(tpAniSirGlobal pMac)
14892{
14893 eCsrRoamLinkQualityInd newVccLinkQuality;
14894 tANI_U32 ul_mac_loss = 0;
14895 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014896 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14897 /*-------------------------------------------------------------------------
14898 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014899 Check for a change in link quality and notify client if necessary
14900 -------------------------------------------------------------------------*/
14901 ul_mac_loss_trigger_threshold =
14902 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014903 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014904 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014905 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014906 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14907 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014908 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014909 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14910 }
14911 else
14912 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014913 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014914 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14915 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014916 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14917 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014918 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14919 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014920 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014921 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14922 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014923 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014924 newVccLinkQuality );
14925
14926 /* we now invoke the callback once to notify client of initial value */
14927 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14928 pMac->roam.linkQualityIndInfo.context );
14929 //event: EVENT_WLAN_VCC
14930 }
14931 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014932 pMac->roam.vccLinkQuality = newVccLinkQuality;
14933
Jeff Johnson295189b2012-06-20 16:38:30 -070014934}
Jeff Johnson295189b2012-06-20 16:38:30 -070014935VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14936 v_U8_t rssiNotification,
14937 void * context)
14938{
14939 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14940 eCsrRoamLinkQualityInd newVccLinkQuality;
14941 // TODO : Session info unavailable
14942 tANI_U32 sessionId = 0;
14943 VOS_STATUS status = VOS_STATUS_SUCCESS;
14944 /*-------------------------------------------------------------------------
14945 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014946 Check for a change in link quality and notify client if necessary
14947 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014948 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014949 pMac->roam.configParam.vccRssiThreshold);
14950 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14951 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014952 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014953 return VOS_STATUS_SUCCESS;
14954 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014955 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14956 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014957 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014958 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14959 }
14960 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14961 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014962 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014963 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14964 }
14965 else
14966 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014967 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014968 //Set to this so the code below won't do anything
14969 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014970 VOS_ASSERT(0);
14971 }
14972
Jeff Johnson295189b2012-06-20 16:38:30 -070014973 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14974 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014975 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014976 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14977 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014978 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014979 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014980 /* we now invoke the callback once to notify client of initial value */
14981 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14982 pMac->roam.linkQualityIndInfo.context );
14983 //event: EVENT_WLAN_VCC
14984 }
14985 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014986 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014987 return status;
14988}
Jeff Johnson295189b2012-06-20 16:38:30 -070014989tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14990 tDblLinkList *pStaList,
14991 tCsrStatsClientReqInfo *pStaEntry)
14992{
14993 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014994 //if same entity requested for same set of stats with different periodicity &
14995 // callback update it
14996 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14997 {
14998
Kiet Lam64c1b492013-07-12 13:56:44 +053014999 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15000 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015001 {
15002 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015003 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015004 return NULL;
15005 }
15006
Jeff Johnson295189b2012-06-20 16:38:30 -070015007 pNewStaEntry->callback = pStaEntry->callback;
15008 pNewStaEntry->pContext = pStaEntry->pContext;
15009 pNewStaEntry->periodicity = pStaEntry->periodicity;
15010 pNewStaEntry->requesterId = pStaEntry->requesterId;
15011 pNewStaEntry->statsMask = pStaEntry->statsMask;
15012 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15013 pNewStaEntry->pMac = pStaEntry->pMac;
15014 pNewStaEntry->staId = pStaEntry->staId;
15015 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15016
15017 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15018 }
15019 return pNewStaEntry;
15020}
15021
Jeff Johnson295189b2012-06-20 16:38:30 -070015022tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15023 tDblLinkList *pStaList,
15024 tCsrPeStatsReqInfo *pStaEntry)
15025{
15026 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015027 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15028 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015029 {
15030 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015031 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015032 return NULL;
15033 }
15034
Jeff Johnson295189b2012-06-20 16:38:30 -070015035 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15036 pNewStaEntry->numClient = pStaEntry->numClient;
15037 pNewStaEntry->periodicity = pStaEntry->periodicity;
15038 pNewStaEntry->statsMask = pStaEntry->statsMask;
15039 pNewStaEntry->pMac = pStaEntry->pMac;
15040 pNewStaEntry->staId = pStaEntry->staId;
15041 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15042 pNewStaEntry->rspPending = pStaEntry->rspPending;
15043
15044 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015045 return pNewStaEntry;
15046}
Jeff Johnson295189b2012-06-20 16:38:30 -070015047eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15048 tCsrRssiCallback callback,
15049 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15050{
15051 eHalStatus status = eHAL_STATUS_SUCCESS;
15052 vos_msg_t msg;
15053 tANI_U32 sessionId;
15054
15055 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015056 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015057 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15058 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015059 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015060 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015061 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015062 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015063 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15064
15065 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15066 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15067 pMsg->sessionId = sessionId;
15068 pMsg->staId = staId;
15069 pMsg->rssiCallback = callback;
15070 pMsg->pDevContext = pContext;
15071 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015072 msg.type = eWNI_SME_GET_RSSI_REQ;
15073 msg.bodyptr = pMsg;
15074 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015075 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15076 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015077 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015078 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015079 status = eHAL_STATUS_FAILURE;
15080 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015081 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015082 return status;
15083}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015084
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015085eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15086 tCsrSnrCallback callback,
15087 tANI_U8 staId, tCsrBssid bssId,
15088 void *pContext)
15089{
15090 eHalStatus status = eHAL_STATUS_SUCCESS;
15091 vos_msg_t msg;
15092 tANI_U32 sessionId;
15093
15094 tAniGetSnrReq *pMsg;
15095
15096 smsLog(pMac, LOG2, FL("called"));
15097
15098 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15099 if (NULL == pMsg )
15100 {
15101 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15102 return status;
15103 }
15104
15105 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15106
15107 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15108 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15109 pMsg->sessionId = sessionId;
15110 pMsg->staId = staId;
15111 pMsg->snrCallback = callback;
15112 pMsg->pDevContext = pContext;
15113 msg.type = eWNI_SME_GET_SNR_REQ;
15114 msg.bodyptr = pMsg;
15115 msg.reserved = 0;
15116
15117 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15118 {
15119 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15120 vos_mem_free((v_VOID_t *)pMsg);
15121 status = eHAL_STATUS_FAILURE;
15122 }
15123
15124 smsLog(pMac, LOG2, FL("returned"));
15125 return status;
15126}
15127
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015128#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
15129eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15130 tCsrRssiCallback callback,
15131 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15132{
15133 eHalStatus status = eHAL_STATUS_SUCCESS;
15134 tAniGetRssiReq *pMsg;
15135
Kiet Lam64c1b492013-07-12 13:56:44 +053015136 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15137 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015138 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015139 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015140 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015141 }
15142 // need to initiate a stats request to PE
15143 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15144 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15145 pMsg->staId = staId;
15146 pMsg->rssiCallback = callback;
15147 pMsg->pDevContext = pContext;
15148 pMsg->pVosContext = pVosContext;
15149 status = palSendMBMessage(pMac->hHdd, pMsg );
15150 if(!HAL_STATUS_SUCCESS(status))
15151 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015152 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015153 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015154 status = eHAL_STATUS_FAILURE;
15155 }
15156 return status;
15157}
15158#endif
15159
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015160
15161
15162#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
15163eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15164 tCsrTsmStatsCallback callback,
15165 tANI_U8 staId,
15166 tCsrBssid bssId,
15167 void *pContext,
15168 void* pVosContext,
15169 tANI_U8 tid)
15170{
15171 eHalStatus status = eHAL_STATUS_SUCCESS;
15172 tAniGetTsmStatsReq *pMsg = NULL;
15173
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015174 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15175 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015176 {
15177 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015178 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015179 }
15180 // need to initiate a stats request to PE
15181 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15182 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15183 pMsg->staId = staId;
15184 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015185 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015186 pMsg->tsmStatsCallback = callback;
15187 pMsg->pDevContext = pContext;
15188 pMsg->pVosContext = pVosContext;
15189 status = palSendMBMessage(pMac->hHdd, pMsg );
15190 if(!HAL_STATUS_SUCCESS(status))
15191 {
15192 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15193 //pMsg is freed by palSendMBMessage
15194 status = eHAL_STATUS_FAILURE;
15195 }
15196 return status;
15197}
15198#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
15199
15200
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015201/* ---------------------------------------------------------------------------
15202 \fn csrGetTLSTAState
15203 \helper function to get teh TL STA State whenever the function is called.
15204
15205 \param staId - The staID to be passed to the TL
15206 to get the relevant TL STA State
15207 \return the state as tANI_U16
15208 ---------------------------------------------------------------------------*/
15209tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15210{
15211 WLANTL_STAStateType tlSTAState;
15212 tlSTAState = WLANTL_STA_INIT;
15213
15214 //request TL for STA State
15215 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15216 {
15217 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15218 }
15219
15220 return tlSTAState;
15221}
15222
Jeff Johnson295189b2012-06-20 16:38:30 -070015223eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15224 tANI_U32 statsMask,
15225 tCsrStatsCallback callback,
15226 tANI_U32 periodicity, tANI_BOOLEAN cache,
15227 tANI_U8 staId, void *pContext)
15228{
15229 tCsrStatsClientReqInfo staEntry;
15230 tCsrStatsClientReqInfo *pStaEntry = NULL;
15231 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15232 tListElem *pEntry = NULL;
15233 tANI_BOOLEAN found = FALSE;
15234 eHalStatus status = eHAL_STATUS_SUCCESS;
15235 tANI_BOOLEAN insertInClientList = FALSE;
15236 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015237 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015238
15239 if( csrIsAllSessionDisconnected(pMac) )
15240 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015241 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015242 return eHAL_STATUS_FAILURE;
15243 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015244
15245 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15246 {
15247 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15248 return eHAL_STATUS_FAILURE;
15249 }
15250
Jeff Johnson295189b2012-06-20 16:38:30 -070015251 if((!statsMask) && (!callback))
15252 {
15253 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015254 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015255 return eHAL_STATUS_FAILURE;
15256 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015257 //for the search list method for deregister
15258 staEntry.requesterId = requesterId;
15259 staEntry.statsMask = statsMask;
15260 //requester wants to deregister or just an error
15261 if((statsMask) && (!callback))
15262 {
15263 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15264 if(!pEntry)
15265 {
15266 //msg
15267 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015268 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015269 return eHAL_STATUS_FAILURE;
15270 }
15271 else
15272 {
15273 //clean up & return
15274 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015275 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015276 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015277 pStaEntry->pPeStaEntry->numClient--;
15278 //check if we need to delete the entry from peStatsReqList too
15279 if(!pStaEntry->pPeStaEntry->numClient)
15280 {
15281 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15282 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015283 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015284
Jeff Johnson295189b2012-06-20 16:38:30 -070015285 //check if we need to stop the tl stats timer too
15286 pMac->roam.tlStatsReqInfo.numClient--;
15287 if(!pMac->roam.tlStatsReqInfo.numClient)
15288 {
15289 if(pMac->roam.tlStatsReqInfo.timerRunning)
15290 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015291 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15292 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015293 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015294 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015295 return eHAL_STATUS_FAILURE;
15296 }
15297 }
15298 pMac->roam.tlStatsReqInfo.periodicity = 0;
15299 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15300 }
15301 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015302 // Destroy the vos timer...
15303 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15304 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15305 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015306 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015307 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015308 csrRoamRemoveStatListEntry(pMac, pEntry);
15309 pStaEntry = NULL;
15310 return eHAL_STATUS_SUCCESS;
15311 }
15312 }
15313
15314 if(cache && !periodicity)
15315 {
15316 //return the cached stats
15317 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15318 }
15319 else
15320 {
15321 //add the request in the client req list
15322 staEntry.callback = callback;
15323 staEntry.pContext = pContext;
15324 staEntry.periodicity = periodicity;
15325 staEntry.pPeStaEntry = NULL;
15326 staEntry.staId = staId;
15327 staEntry.pMac = pMac;
15328 staEntry.timerExpired = FALSE;
15329
15330
Jeff Johnson295189b2012-06-20 16:38:30 -070015331 //if periodic report requested with non cached result from PE/TL
15332 if(periodicity)
15333 {
15334
15335 //if looking for stats from PE
15336 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15337 {
15338
15339 //check if same request made already & waiting for rsp
15340 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15341 periodicity, &found, staId);
15342 if(!pPeStaEntry)
15343 {
15344 //bail out, maxed out on number of req for PE
15345 return eHAL_STATUS_FAILURE;
15346 }
15347 else
15348 {
15349 staEntry.pPeStaEntry = pPeStaEntry;
15350 }
15351
15352 }
15353 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15354 if(statsMask & (1 << eCsrGlobalClassDStats))
15355 {
15356 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15357 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015358 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015359 }
15360 else
15361 {
15362
15363 //update periodicity
15364 if(pMac->roam.tlStatsReqInfo.periodicity)
15365 {
15366 pMac->roam.tlStatsReqInfo.periodicity =
15367 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15368 }
15369 else
15370 {
15371 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15372 }
15373 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15374 {
15375 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15376 }
15377
15378 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15379 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015380 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015381 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015382 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015383 //req TL for class D stats
15384 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15385 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015386 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015387 }
15388 else
15389 {
15390 //save in SME
15391 csrRoamSaveStatsFromTl(pMac, pTlStats);
15392 }
15393 vos_mem_free(pTlStats);
15394 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015395 }
15396 else
15397 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015398 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015399 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015400
Jeff Johnson295189b2012-06-20 16:38:30 -070015401 if(pMac->roam.tlStatsReqInfo.periodicity)
15402 {
15403 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015404 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15405 pMac->roam.tlStatsReqInfo.periodicity);
15406 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015407 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015408 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015409 return eHAL_STATUS_FAILURE;
15410 }
15411 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15412 }
15413 }
15414 }
15415 pMac->roam.tlStatsReqInfo.numClient++;
15416 }
15417
15418 insertInClientList = TRUE;
15419 }
15420 //if one time report requested with non cached result from PE/TL
15421 else if(!cache && !periodicity)
15422 {
15423 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15424 {
15425 //send down a req
15426 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15427 if(!HAL_STATUS_SUCCESS(status))
15428 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015429 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015430 }
15431 //so that when the stats rsp comes back from PE we respond to upper layer
15432 //right away
15433 staEntry.timerExpired = TRUE;
15434 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015435 }
15436 if(statsMask & (1 << eCsrGlobalClassDStats))
15437 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015438 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015439 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015440 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015441 //req TL for class D stats
15442 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15443 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015444 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015445 }
15446 else
15447 {
15448 //save in SME
15449 csrRoamSaveStatsFromTl(pMac, pTlStats);
15450 }
15451 vos_mem_free(pTlStats);
15452 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015453 }
15454 else
15455 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015456 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015457 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015458
15459 }
15460 //if looking for stats from TL only
15461 if(!insertInClientList)
15462 {
15463 //return the stats
15464 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15465 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015466 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015467 if(insertInClientList)
15468 {
15469 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15470 if(!pStaEntry)
15471 {
15472 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015473 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015474 return eHAL_STATUS_FAILURE;
15475 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015476 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015477 //Init & start timer if needed
15478 if(periodicity)
15479 {
15480 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15481 csrRoamStatsClientTimerHandler, pStaEntry );
15482 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15483 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015484 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015485 return eHAL_STATUS_FAILURE;
15486 }
15487 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15488 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15489 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015490 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015491 return eHAL_STATUS_FAILURE;
15492 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015493 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015494 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015495 }
15496 return eHAL_STATUS_SUCCESS;
15497}
15498
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015499#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15500
15501static tSirRetStatus
15502csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15503 tANI_U8* pBD,
15504 tANI_U8 type,
15505 tANI_U8 subType,
15506 tSirMacAddr peerAddr,
15507 tSirMacAddr selfMacAddr)
15508{
15509 tSirRetStatus statusCode = eSIR_SUCCESS;
15510 tpSirMacMgmtHdr pMacHdr;
15511
15512 /* Prepare MAC management header */
15513 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15514
15515 /* Prepare FC */
15516 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15517 pMacHdr->fc.type = type;
15518 pMacHdr->fc.subType = subType;
15519
15520 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015521 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15522 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015523
15524 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15525
15526 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015527 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15528 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015529 return statusCode;
15530} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15531
15532static tSirRetStatus
15533csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15534 tANI_U8 nChannelNum,
15535 tANI_U32 dot11mode,
15536 tSirMacAddr selfMacAddr,
15537 tANI_U8 *pFrame,
15538 tANI_U16 *pusLen)
15539{
15540 tDot11fProbeRequest pr;
15541 tANI_U32 nStatus, nBytes, nPayload;
15542 tSirRetStatus nSirStatus;
15543 /*Bcast tx*/
15544 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15545 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15546
15547
Kiet Lam64c1b492013-07-12 13:56:44 +053015548 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015549
15550 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15551
15552 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15553 {
15554 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15555 }
15556
15557
15558 if (IS_DOT11_MODE_HT(dot11mode))
15559 {
15560 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15561 }
15562
15563
15564 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15565 if ( DOT11F_FAILED( nStatus ) )
15566 {
15567 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15568 "Failed to calculate the packed size f"
15569 "or a Probe Request (0x%08x).\n", nStatus );
15570
15571
15572 nPayload = sizeof( tDot11fProbeRequest );
15573 }
15574 else if ( DOT11F_WARNED( nStatus ) )
15575 {
15576 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15577 "There were warnings while calculating"
15578 "the packed size for a Probe Request ("
15579 "0x%08x).\n", nStatus );
15580 }
15581
15582 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15583
15584 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015585 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015586
15587
15588 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015589 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015590
15591 if ( eSIR_SUCCESS != nSirStatus )
15592 {
15593 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15594 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15595 nSirStatus );
15596 return nSirStatus;
15597 }
15598
15599
15600 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15601 sizeof( tSirMacMgmtHdr ),
15602 nPayload, &nPayload );
15603 if ( DOT11F_FAILED( nStatus ) )
15604 {
15605 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15606 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15607 return eSIR_FAILURE;
15608 }
15609 else if ( DOT11F_WARNED( nStatus ) )
15610 {
15611 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015612 "There were warnings while packing a Probe Request (0x%08x).\n",
15613 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015614 }
15615
15616 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15617 return eSIR_SUCCESS;
15618}
15619
15620eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15621{
15622 vos_msg_t msg;
15623 tSirRoamOffloadScanReq *pRequestBuf;
15624 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15625 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015626 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015627 tANI_U8 *ChannelList = NULL;
15628 tANI_U32 sessionId;
15629 eHalStatus status = eHAL_STATUS_SUCCESS;
15630 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015631 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015632 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015633 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015634 tSirBssDescription *pBssDesc = NULL;
15635 tDot11fBeaconIEs *pIes = NULL;
15636 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080015637 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015638
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015639 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15640
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015641 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015642 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015643 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015644 return eHAL_STATUS_FAILURE;
15645 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015646
15647 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15648 {
15649 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15650 return eHAL_STATUS_FAILURE;
15651 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015652 status = csrRoamGetSessionIdFromBSSID(pMac,
15653 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15654 &sessionId);
15655 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15656 * It is important to ensure that the command is passed down to the FW only
15657 * if the Infra Station is in a connected state.A connected station could also be
15658 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15659 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15660 * irrespective of whichever state we are in.*/
15661 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15662 (command != ROAM_SCAN_OFFLOAD_STOP))
15663 {
15664 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
15665 pMac->roam.neighborRoamInfo.neighborRoamState, command);
15666 return eHAL_STATUS_FAILURE;
15667 }
15668
15669 if ( !HAL_STATUS_SUCCESS( status ) )
15670 {
15671 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15672 return eHAL_STATUS_FAILURE;
15673 }
15674 pSession = CSR_GET_SESSION( pMac, sessionId );
krunal soni587bf012014-02-04 12:35:11 -080015675 if (NULL == pSession)
15676 {
15677 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15678 "%s:pSession is null", __func__);
15679 return eHAL_STATUS_FAILURE;
15680 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015681 pBssDesc = pSession->pConnectBssDesc;
15682 if (pBssDesc == NULL)
15683 {
15684 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: pBssDesc not found for current session", __func__);
15685 return eHAL_STATUS_FAILURE;
15686 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015687 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15688 if (NULL == pRequestBuf)
15689 {
15690 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15691 return eHAL_STATUS_FAILED_ALLOC;
15692 }
15693
Kiet Lam64c1b492013-07-12 13:56:44 +053015694 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015695 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15696 * host driver reloads, but Riva still up and running*/
15697 if(command == ROAM_SCAN_OFFLOAD_STOP)
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015698 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015699 pRequestBuf->RoamScanOffloadEnabled = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015700 /*For a STOP Command, there is no need to
15701 * go through filling up all the below parameters
15702 * since they are not required for the STOP command*/
15703 goto send_roam_scan_offload_cmd;
15704 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015705 else
15706 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015707 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15708 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015709 sizeof(tCsrBssid));
15710 pRequestBuf->ConnectedNetwork.ssId.length =
15711 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15712 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15713 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15714 pRequestBuf->ConnectedNetwork.ssId.length);
15715 pRequestBuf->ConnectedNetwork.authentication =
15716 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15717 pRequestBuf->ConnectedNetwork.encryption =
15718 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15719 pRequestBuf->ConnectedNetwork.mcencryption =
15720 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015721 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
15722 {
15723 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015724 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015725 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15726 }
15727 else
15728 {
15729 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
15730 operationChannel = pSession->connectedProfile.operationChannel;
15731
15732 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
15733 {
15734 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15735 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
15736 vos_mem_free(pRequestBuf);
15737 return eHAL_STATUS_FAILURE;
15738 }
15739 if (pIes->SuppRates.present)
15740 {
15741 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
15742 /*Check for both basic rates and extended rates.*/
15743 for (i = 0; i < pIes->SuppRates.num_rates; i++)
15744 {
15745 /*Check if the Rate is Mandatory or Not*/
15746 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
15747 && (pIes->SuppRates.rates[i] & 0x80))
15748 {
15749 /*Retrieve the actual data rate*/
15750 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
15751 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15752 if (minRate == 0)
15753 minRate = dataRate;
15754 else
15755 minRate = (minRate < dataRate) ? minRate:dataRate;
15756 }
15757 }
15758
15759 if (pIes->ExtSuppRates.present)
15760 {
15761 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
15762 {
15763 /*Check if the Rate is Mandatory or Not*/
15764 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
15765 && (pIes->ExtSuppRates.rates[i] & 0x80))
15766 {
15767 /*Retrieve the actual data rate*/
15768 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
15769 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15770 if (minRate == 0)
15771 minRate = dataRate;
15772 else
15773 minRate = (minRate < dataRate) ? minRate:dataRate;
15774 }
15775 }
15776 }
15777 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
15778 }
15779 else
15780 {
15781 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15782 "%s: Supp Rates not present in pIes", __func__);
15783 vos_mem_free(pRequestBuf);
15784 return eHAL_STATUS_FAILURE;
15785 }
15786 if (NULL != pIes)
15787 {
15788 vos_mem_free(pIes);
15789 pIes = NULL;
15790 }
15791 switch (minRate)
15792 {
15793 case 1:
15794 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
15795 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
15796 break;
15797 case 2:
15798 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
15799 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
15800 break;
15801 case 5:
15802 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
15803 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
15804 break;
15805 case 6:
15806 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15807 {
15808 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
15809 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
15810 }
15811 else
15812 {
15813 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
15814 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
15815 }
15816 break;
15817 case 11:
15818 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
15819 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
15820 break;
15821 case 12:
15822 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15823 {
15824 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
15825 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
15826 }
15827 else
15828 {
15829 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
15830 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
15831 }
15832 break;
15833 case 24:
15834 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15835 {
15836 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
15837 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
15838 }
15839 else
15840 {
15841 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
15842 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
15843 }
15844 break;
15845 default:
15846 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
15847 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15848 break;
15849 }
15850 }
15851 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15852 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
15853 operationChannel, minRate,
15854 pRequestBuf->RxSensitivityThreshold,
15855 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015856 pRequestBuf->RoamRssiDiff =
15857 pMac->roam.configParam.RoamRssiDiff;
15858 pRequestBuf->Command = command;
15859 pRequestBuf->StartScanReason = reason;
15860 pRequestBuf->NeighborScanTimerPeriod =
15861 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
15862 pRequestBuf->NeighborRoamScanRefreshPeriod =
15863 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
15864 pRequestBuf->NeighborScanChannelMinTime =
15865 pNeighborRoamInfo->cfgParams.minChannelScanTime;
15866 pRequestBuf->NeighborScanChannelMaxTime =
15867 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
15868 pRequestBuf->EmptyRefreshScanPeriod =
15869 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080015870 /* MAWC feature */
15871 pRequestBuf->MAWCEnabled =
15872 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015873#ifdef FEATURE_WLAN_CCX
15874 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
15875#endif
15876 if (
15877#ifdef FEATURE_WLAN_CCX
15878 ((pNeighborRoamInfo->isCCXAssoc) &&
15879 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
15880 eANI_BOOLEAN_FALSE)) ||
15881 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
15882#endif // CCX
15883 currChannelListInfo->numOfChannels == 0)
15884 {
15885
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015886 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
15887 * Give Preference to INI Channels.*/
15888 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
15889 {
15890 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
15891 /*The INI channels need to be filtered with respect to the current
15892 * band that is supported.*/
15893 eBand = pMac->roam.configParam.bandCapability;
15894 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015895 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015896 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15897 "Invalid band, No operation carried out (Band %d)", eBand);
15898 vos_mem_free(pRequestBuf);
15899 return eHAL_STATUS_FAILURE;
15900 }
15901 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
15902 {
15903 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
15904 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
15905 (eCSR_BAND_ALL == eBand))
15906 {
15907 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
15908 csrRoamIsChannelValid(pMac, *ChannelList) &&
15909 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
15910 {
15911 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15912 }
15913 }
15914 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015915 }
15916 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15917 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015918 }
15919 else
15920 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015921 ChannelList = pMac->scan.occupiedChannels.channelList;
15922 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
15923 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015924 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
15925 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
15926 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015927 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015928 }
15929 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015930 }
15931 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15932 /* If the profile changes as to what it was earlier, inform the FW through
15933 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
15934 * for the earlier profile and try to learn them afresh.*/
15935 if (reason == REASON_FLUSH_CHANNEL_LIST)
15936 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
15937 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015938 if (csrNeighborRoamIsNewConnectedProfile(pMac))
15939 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
15940 else
15941 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015942 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015943 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015944 }
15945#ifdef FEATURE_WLAN_CCX
15946 else
15947 {
15948 /* If CCX is enabled, and a neighbor Report is received,then
15949 * Ignore the INI Channels or the Occupied Channel List. Consider
15950 * the channels in the neighbor list sent by the CCX AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015951 if (currChannelListInfo->numOfChannels != 0)
15952 {
15953 ChannelList = currChannelListInfo->ChannelList;
15954 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015955 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015956 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15957 {
15958 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15959 }
15960 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015961 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015962 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15963 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15964 }
15965 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015966#endif
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015967 for (i = 0, j = 0; i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
15968 {
15969 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
15970 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
15971 }
15972 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15973 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
15974 pRequestBuf->ChannelCacheType,
15975 pRequestBuf->ConnectedNetwork.ChannelCount,
15976 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015977 num_channels = 0;
15978 ChannelList = NULL;
15979
15980 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070015981 host_channels = sizeof(pMac->roam.validChannelList);
15982 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015983 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070015984 ChannelList = pMac->roam.validChannelList;
15985 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015986 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070015987 else
15988 {
15989 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15990 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070015991 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070015992 return eHAL_STATUS_FAILURE;
15993 }
15994 for(i=0; i<pMac->roam.numValidChannels; i++)
15995 {
15996 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15997 {
15998 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15999 }
16000 ChannelList++;
16001 }
16002 pRequestBuf->ValidChannelCount = num_channels;
16003
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016004 pRequestBuf->MDID.mdiePresent =
16005 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16006 pRequestBuf->MDID.mobilityDomain =
16007 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016008 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16009
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016010 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016011 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16012 * where RFS is the RF Switching time. It is twice RFS to consider the
16013 * time to go off channel and return to the home channel. */
16014 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16015 {
16016 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16017 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16018 " Hence enforcing home away time to disable (0)",
16019 __func__, pRequestBuf->HomeAwayTime,
16020 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16021 pRequestBuf->HomeAwayTime = 0;
16022 }
16023 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016024
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016025 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16026 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16027 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16028 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16029 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16030
16031 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16032 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016033send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016034 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016035 msg.reserved = 0;
16036 msg.bodyptr = pRequestBuf;
16037 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16038 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016039 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16040 vos_mem_free(pRequestBuf);
16041 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016042 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016043 else
16044 {
16045 if (ROAM_SCAN_OFFLOAD_START == command)
16046 bRoamScanOffloadStarted = VOS_TRUE;
16047 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16048 bRoamScanOffloadStarted = VOS_FALSE;
16049 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016050
16051 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16052 return status;
16053}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016054
16055eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16056{
16057 switch(reason)
16058 {
16059 case 0:
16060 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16061 break;
16062 case REASON_OS_REQUESTED_ROAMING_NOW:
16063 csrNeighborRoamProceedWithHandoffReq(pMac);
16064 break;
16065 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016066 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 -070016067 }
16068 return eHAL_STATUS_SUCCESS;
16069}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016070#endif
16071
Jeff Johnson295189b2012-06-20 16:38:30 -070016072tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16073 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16074{
16075 tANI_BOOLEAN found = FALSE;
16076 eHalStatus status = eHAL_STATUS_SUCCESS;
16077 tCsrPeStatsReqInfo staEntry;
16078 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16079 tListElem *pStaEntry = NULL;
16080 VOS_STATUS vosStatus;
16081 tPmcPowerState powerState;
16082 *pFound = FALSE;
16083
16084 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16085 if(pStaEntry)
16086 {
16087 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16088 if(pTempStaEntry->periodicity)
16089 {
16090 pTempStaEntry->periodicity =
16091 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16092 }
16093 else
16094 {
16095 pTempStaEntry->periodicity = periodicity;
16096 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016097 pTempStaEntry->numClient++;
16098 found = TRUE;
16099 }
16100 else
16101 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016102 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016103 staEntry.numClient = 1;
16104 staEntry.periodicity = periodicity;
16105 staEntry.pMac = pMac;
16106 staEntry.rspPending = FALSE;
16107 staEntry.staId = staId;
16108 staEntry.statsMask = statsMask;
16109 staEntry.timerRunning = FALSE;
16110 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16111 if(!pTempStaEntry)
16112 {
16113 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016114 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016115 return NULL;
16116 }
16117 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016118 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16119 if(ePMC_FULL_POWER == powerState)
16120 {
16121 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16122 {
16123 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16124 }
16125 }
16126 else
16127 {
16128 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16129 {
16130 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16131 }
16132 }
16133 if(!pTempStaEntry->timerRunning)
16134 {
16135 //send down a req in case of one time req, for periodic ones wait for timer to expire
16136 if(!pTempStaEntry->rspPending &&
16137 !pTempStaEntry->periodicity)
16138 {
16139 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16140 if(!HAL_STATUS_SUCCESS(status))
16141 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016142 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016143 }
16144 else
16145 {
16146 pTempStaEntry->rspPending = TRUE;
16147 }
16148 }
16149 if(pTempStaEntry->periodicity)
16150 {
16151 if(!found)
16152 {
16153
16154 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16155 csrRoamPeStatsTimerHandler, pTempStaEntry );
16156 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16157 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016158 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016159 return NULL;
16160 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016161 }
16162 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016163 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016164 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16165 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16166 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016167 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016168 return NULL;
16169 }
16170 pTempStaEntry->timerRunning = TRUE;
16171 }
16172 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016173 *pFound = found;
16174 return pTempStaEntry;
16175}
16176
Jeff Johnson295189b2012-06-20 16:38:30 -070016177/*
16178 pStaEntry is no longer invalid upon the return of this function.
16179*/
16180static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16181{
16182 if(pEntry)
16183 {
16184 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16185 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016186 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016187 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016188 }
16189 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016190
16191void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16192{
16193 tListElem *pEntry;
16194 tCsrPeStatsReqInfo *pTempStaEntry;
16195 VOS_STATUS vosStatus;
16196 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016197 if(!pEntry)
16198 {
16199 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016200 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016201 return;
16202 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016203 while( pEntry )
16204 {
16205 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016206 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16207 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016208 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016209 if(pTempStaEntry->timerRunning)
16210 {
16211 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16212 /* If we are not able to stop the timer here, just remove
16213 * the entry from the linked list. Destroy the timer object
16214 * and free the memory in the timer CB
16215 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016216 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016217 {
16218 /* the timer is successfully stopped */
16219 pTempStaEntry->timerRunning = FALSE;
16220
16221 /* Destroy the timer */
16222 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16223 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16224 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016225 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016226 }
16227 }
16228 else
16229 {
16230 // the timer could not be stopped. Hence destroy and free the
16231 // memory for the PE stat entry in the timer CB.
16232 pTempStaEntry->timerStopFailed = TRUE;
16233 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016234 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016235
16236 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16237 {
16238 // Only free the memory if we could stop the timer successfully
16239 if(!pTempStaEntry->timerStopFailed)
16240 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016241 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016242 pTempStaEntry = NULL;
16243 }
16244 break;
16245 }
16246
16247 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16248 }
16249 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016250 return;
16251}
16252
16253
Jeff Johnsone7245742012-09-05 17:12:55 -070016254void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016255{
16256
Jeff Johnsone7245742012-09-05 17:12:55 -070016257 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16258 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16259 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16260 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16261 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16262 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16263 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016264 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016265 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16266 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16267 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16268 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16269 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16270 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016271 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016272 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16273 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016274
16275}
16276
Jeff Johnson295189b2012-06-20 16:38:30 -070016277void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16278 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16279{
16280 tANI_U8 stats[500];
16281 tANI_U8 *pStats = NULL;
16282 tANI_U32 tempMask = 0;
16283 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016284 if(!callback)
16285 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016286 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016287 return;
16288 }
16289 if(!statsMask)
16290 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016291 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016292 return;
16293 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016294 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016295 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016296 while(tempMask)
16297 {
16298 if(tempMask & 1)
16299 {
16300 //new stats info from PE, fill up the stats strucutres in PMAC
16301 switch(counter)
16302 {
16303 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016304 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016305 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16306 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016307 pStats += sizeof(tCsrSummaryStatsInfo);
16308 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016309 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016310 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016311 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16312 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016313 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016314 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016315 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016316 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016317 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16318 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016319 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016320 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016321 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016322 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016323 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16324 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016325 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016326 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016327 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016328 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016329 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16330 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016331 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016332 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016333 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016334 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016335 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16336 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016337 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016338 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016339 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016340 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016341 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016342 }
16343 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016344 tempMask >>=1;
16345 counter++;
16346 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016347 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016348}
16349
Jeff Johnson295189b2012-06-20 16:38:30 -070016350eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16351{
16352 tListElem *pEntry = NULL;
16353 tListElem *pPrevEntry = NULL;
16354 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16355 eHalStatus status = eHAL_STATUS_SUCCESS;
16356 VOS_STATUS vosStatus;
16357 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016358 if(!pEntry)
16359 {
16360 //list empty
16361 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016362 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016363 return status;
16364 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016365 while( pEntry )
16366 {
16367 if(pPrevEntry)
16368 {
16369 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16370 //send up the stats report
16371 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16372 pTempStaEntry->staId, pTempStaEntry->pContext);
16373 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16374 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016375 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016376 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16377 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016378 pTempStaEntry->pPeStaEntry->numClient--;
16379 //check if we need to delete the entry from peStatsReqList too
16380 if(!pTempStaEntry->pPeStaEntry->numClient)
16381 {
16382 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16383 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016384 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016385 //check if we need to stop the tl stats timer too
16386 pMac->roam.tlStatsReqInfo.numClient--;
16387 if(!pMac->roam.tlStatsReqInfo.numClient)
16388 {
16389 if(pMac->roam.tlStatsReqInfo.timerRunning)
16390 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016391 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16392 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016393 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016394 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016395 //we will continue
16396 }
16397 }
16398 pMac->roam.tlStatsReqInfo.periodicity = 0;
16399 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16400 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016401 if (pTempStaEntry->periodicity)
16402 {
16403 //While creating StaEntry in csrGetStatistics,
16404 //Initializing and starting timer only when periodicity is set.
16405 //So Stop and Destroy timer only when periodicity is set.
16406
Jeff Johnsone7245742012-09-05 17:12:55 -070016407 vos_timer_stop( &pTempStaEntry->timer );
16408 // Destroy the vos timer...
16409 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16410 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16411 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016412 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016413 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016414 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016415
Jeff Johnson295189b2012-06-20 16:38:30 -070016416
16417 pPrevEntry = pEntry;
16418 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16419 }
16420 //the last one
16421 if(pPrevEntry)
16422 {
16423 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16424 //send up the stats report
16425 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16426 pTempStaEntry->staId, pTempStaEntry->pContext);
16427 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16428 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016429 return status;
16430
16431}
16432
Jeff Johnson295189b2012-06-20 16:38:30 -070016433eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16434 tRequestFullPowerReason *pReason,
16435 tANI_BOOLEAN *pfNeedPower )
16436{
16437 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16438 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16439 tPmcState pmcState;
16440 eHalStatus status = eHAL_STATUS_SUCCESS;
16441 // TODO : Session info unavailable
16442 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016443 if( pfNeedPower )
16444 {
16445 *pfNeedPower = eANI_BOOLEAN_FALSE;
16446 }
16447 //We only handle CSR commands
16448 if( !(eSmeCsrCommandMask & pCommand->command) )
16449 {
16450 return eHAL_STATUS_SUCCESS;
16451 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016452 //Check PMC state first
16453 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016454 switch( pmcState )
16455 {
16456 case REQUEST_IMPS:
16457 case IMPS:
16458 if( eSmeCommandScan == pCommand->command )
16459 {
16460 switch( pCommand->u.scanCmd.reason )
16461 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016462#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16463 case eCsrScanGetLfrResult:
16464#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016465 case eCsrScanGetResult:
16466 case eCsrScanBGScanAbort:
16467 case eCsrScanBGScanEnable:
16468 case eCsrScanGetScanChnInfo:
16469 //Internal process, no need for full power
16470 fNeedFullPower = eANI_BOOLEAN_FALSE;
16471 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016472 default:
16473 //Other scans are real scan, ask for power
16474 fNeedFullPower = eANI_BOOLEAN_TRUE;
16475 break;
16476 } //switch
16477 }
16478 else
16479 {
16480 //ask for power for roam and status change
16481 fNeedFullPower = eANI_BOOLEAN_TRUE;
16482 }
16483 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016484 case REQUEST_BMPS:
16485 case BMPS:
16486 case REQUEST_START_UAPSD:
16487 case UAPSD:
16488 //We treat WOWL same as BMPS
16489 case REQUEST_ENTER_WOWL:
16490 case WOWL:
16491 if( eSmeCommandRoam == pCommand->command )
16492 {
16493 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16494 tCsrScanResult *pScanResult;
16495 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016496 switch ( pCommand->u.roamCmd.roamReason )
16497 {
16498 case eCsrForcedDisassoc:
16499 case eCsrForcedDisassocMICFailure:
16500 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16501 fNeedFullPower = eANI_BOOLEAN_TRUE;
16502 break;
16503 case eCsrSmeIssuedDisassocForHandoff:
16504 case eCsrForcedDeauth:
16505 case eCsrHddIssuedReassocToSameAP:
16506 case eCsrSmeIssuedReassocToSameAP:
16507 fNeedFullPower = eANI_BOOLEAN_TRUE;
16508 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016509 case eCsrCapsChange:
16510 fNeedFullPower = eANI_BOOLEAN_TRUE;
16511 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016512 default:
16513 //Check whether the profile is already connected. If so, no need for full power
16514 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16515 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16516 {
16517 //Only need to check the first one
16518 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16519 if( pEntry )
16520 {
16521 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16522#if 0
16523 // TODO : Session Specific info pConnectBssDesc
16524 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16525 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16526 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16527 {
16528 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16529 // with Authenticating first. To force this, stop the current association (Disassociate) and
16530 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16531 // a new Association.
16532 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16533 {
16534 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16535 {
16536 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16537 //No need for full power
16538 //Set the flag so the code later can avoid to do the above
16539 //check again.
16540 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16541 break;
16542 }
16543 }
16544 }
16545#endif
16546 }
16547 }
16548 //If we are here, full power is needed
16549 fNeedFullPower = eANI_BOOLEAN_TRUE;
16550 break;
16551 }
16552 }
16553 else if( eSmeCommandWmStatusChange == pCommand->command )
16554 {
16555 //need full power for all
16556 fNeedFullPower = eANI_BOOLEAN_TRUE;
16557 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16558 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016559#ifdef FEATURE_WLAN_TDLS
16560 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16561 {
16562 //TDLS link is getting established. need full power
16563 fNeedFullPower = eANI_BOOLEAN_TRUE;
16564 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16565 }
16566#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016567 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016568 case REQUEST_STOP_UAPSD:
16569 case REQUEST_EXIT_WOWL:
16570 if( eSmeCommandRoam == pCommand->command )
16571 {
16572 fNeedFullPower = eANI_BOOLEAN_TRUE;
16573 switch ( pCommand->u.roamCmd.roamReason )
16574 {
16575 case eCsrForcedDisassoc:
16576 case eCsrForcedDisassocMICFailure:
16577 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16578 break;
16579 default:
16580 break;
16581 }
16582 }
16583 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016584 case STOPPED:
16585 case REQUEST_STANDBY:
16586 case STANDBY:
16587 case LOW_POWER:
16588 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016589 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016590 status = eHAL_STATUS_FAILURE;
16591 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016592 case FULL_POWER:
16593 case REQUEST_FULL_POWER:
16594 default:
16595 //No need to ask for full power. This has to be FULL_POWER state
16596 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016597 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016598 if( pReason )
16599 {
16600 *pReason = reason;
16601 }
16602 if( pfNeedPower )
16603 {
16604 *pfNeedPower = fNeedFullPower;
16605 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016606 return ( status );
16607}
16608
Jeff Johnson295189b2012-06-20 16:38:30 -070016609static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16610{
16611 eHalStatus status = eHAL_STATUS_SUCCESS;
16612 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16613 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016614 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016615 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16616 {
16617 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16618 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016619 return ( status );
16620}
16621
Jeff Johnson295189b2012-06-20 16:38:30 -070016622tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16623{
16624 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016625 if( pCmd )
16626 {
16627 pMac->roam.sPendingCommands++;
16628 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016629 return ( pCmd );
16630}
16631
Jeff Johnson295189b2012-06-20 16:38:30 -070016632void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16633{
16634 if (pMac->roam.sPendingCommands > 0)
16635 {
16636 //All command allocated through csrGetCommandBuffer need to
16637 //decrement the pending count when releasing.
16638 pMac->roam.sPendingCommands--;
16639 smeReleaseCommand( pMac, pCommand );
16640 }
16641 else
16642 {
16643 smsLog(pMac, LOGE, FL( "no pending commands"));
16644 VOS_ASSERT(0);
16645 }
16646}
16647
Jeff Johnson295189b2012-06-20 16:38:30 -070016648//Return SUCCESS is the command is queued, failed
16649eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16650{
16651 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016652 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16653 {
16654 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16655 pCommand->u.scanCmd.reason);
16656 return eHAL_STATUS_CSR_WRONG_STATE;
16657 }
16658
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016659 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16660 {
16661 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16662 &pCommand->Link, LL_ACCESS_LOCK);
16663 // process the command queue...
16664 smeProcessPendingQueue(pMac);
16665 status = eHAL_STATUS_SUCCESS;
16666 goto end;
16667 }
16668
Jeff Johnson295189b2012-06-20 16:38:30 -070016669 //We can call request full power first before putting the command into pending Q
16670 //because we are holding SME lock at this point.
16671 status = csrRequestFullPower( pMac, pCommand );
16672 if( HAL_STATUS_SUCCESS( status ) )
16673 {
16674 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016675 //make sure roamCmdPendingList is not empty first
16676 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16677 if( fNoCmdPending )
16678 {
16679 smePushCommand( pMac, pCommand, fHighPriority );
16680 }
16681 else
16682 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016683 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016684 //no list lock is needed since SME lock is held
16685 if( !fHighPriority )
16686 {
16687 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16688 }
16689 else {
16690 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16691 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016692 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016693 }
16694 else if( eHAL_STATUS_PMC_PENDING == status )
16695 {
16696 //no list lock is needed since SME lock is held
16697 if( !fHighPriority )
16698 {
16699 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16700 }
16701 else {
16702 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16703 }
16704 //Let caller know the command is queue
16705 status = eHAL_STATUS_SUCCESS;
16706 }
16707 else
16708 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016709 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016710 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016711 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016712 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016713end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016714 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016715}
Jeff Johnson295189b2012-06-20 16:38:30 -070016716eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16717{
16718 eHalStatus status = eHAL_STATUS_SUCCESS;
16719 tSirUpdateAPWPSIEsReq *pMsg;
16720 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16721
16722 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16723 if (NULL == pSession)
16724 {
16725 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16726 return eHAL_STATUS_FAILURE;
16727 }
16728
Jeff Johnson295189b2012-06-20 16:38:30 -070016729 do
16730 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016731 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
16732 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16733 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016734 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
16735
16736 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070016737 VOS_ASSERT(pBuf);
16738
Jeff Johnson295189b2012-06-20 16:38:30 -070016739 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016740 // transactionId
16741 *pBuf = 0;
16742 *( pBuf + 1 ) = 0;
16743 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070016744 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016745 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16746 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016747 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016748 //sessionId
16749 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016750 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016751 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070016752 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070016753 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016754 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016755 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016756 return ( status );
16757}
Jeff Johnson295189b2012-06-20 16:38:30 -070016758eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
16759{
16760 eHalStatus status = eHAL_STATUS_SUCCESS;
16761 tSirUpdateAPWPARSNIEsReq *pMsg;
16762 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016763 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16764 if (NULL == pSession)
16765 {
16766 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16767 return eHAL_STATUS_FAILURE;
16768 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016769 do
16770 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016771 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
16772 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16773 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016774 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016775 pBuf = (tANI_U8 *)&pMsg->transactionId;
16776 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016777 // transactionId
16778 *pBuf = 0;
16779 *( pBuf + 1 ) = 0;
16780 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070016781 VOS_ASSERT(pBuf);
16782
Jeff Johnson295189b2012-06-20 16:38:30 -070016783 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016784 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16785 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016786 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016787 // sessionId
16788 *pBuf++ = (tANI_U8)sessionId;
16789
16790 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016791 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070016792 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070016793 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016794 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016795 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016796 return ( status );
16797}
Jeff Johnson295189b2012-06-20 16:38:30 -070016798
16799#ifdef WLAN_FEATURE_VOWIFI_11R
16800//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
16801eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
16802{
16803 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16804 tpSirFTPreAuthReq pftPreAuthReq;
16805 tANI_U16 auth_req_len = 0;
16806 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016807 auth_req_len = sizeof(tSirFTPreAuthReq);
16808 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053016809 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070016810 {
16811 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
16812 return eHAL_STATUS_RESOURCES;
16813 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016814 // Save the SME Session ID here. We need it while processing the preauth response
16815 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016816 vos_mem_zero(pftPreAuthReq, auth_req_len);
16817
16818 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
16819 sizeof(pBssDescription->length) + pBssDescription->length);
16820
16821 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
16822
16823 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
16824
Kiet Lam64c1b492013-07-12 13:56:44 +053016825 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
16826 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
16827 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
16828 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016829
Jeff Johnson295189b2012-06-20 16:38:30 -070016830#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080016831 if (csrRoamIs11rAssoc(pMac) &&
16832 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070016833 {
16834 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053016835 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
16836 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070016837 }
16838 else
16839#endif
16840 {
16841 pftPreAuthReq->ft_ies_length = 0;
16842 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070016843 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
16844 sizeof(pBssDescription->length) + pBssDescription->length);
16845 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070016846 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
16847}
Jeff Johnson295189b2012-06-20 16:38:30 -070016848/*--------------------------------------------------------------------------
16849 * This will receive and process the FT Pre Auth Rsp from the current
16850 * associated ap.
16851 *
16852 * This will invoke the hdd call back. This is so that hdd can now
16853 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
16854 ------------------------------------------------------------------------*/
16855void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
16856{
16857 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16858 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016859#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016860 tCsrRoamInfo roamInfo;
16861#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016862
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016863#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016864 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016865 if (status != eHAL_STATUS_SUCCESS) {
16866 /*
16867 * Bail out if pre-auth was not even processed.
16868 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016869 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
16870 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016871 return;
16872 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016873#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016874 /* The below function calls/timers should be invoked only if the pre-auth is successful */
16875 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
16876 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070016877 // Implies a success
16878 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016879 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
16880 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070016881 /* No need to notify qos module if this is a non 11r roam*/
16882 if (csrRoamIs11rAssoc(pMac))
16883 {
16884 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
16885 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016886 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
16887 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016888 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
16889 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070016890 if (eHAL_STATUS_SUCCESS != status)
16891 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016892 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016893 return;
16894 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016895 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016896 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
16897 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016898 if (csrRoamIs11rAssoc(pMac))
16899 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
16900 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
16901
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016902#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16903 if (csrRoamIsCCXAssoc(pMac))
16904 {
16905 /* read TSF */
16906 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
16907
16908 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080016909 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016910 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
16911 }
16912#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016913#ifdef FEATURE_WLAN_LFR
16914 // If Legacy Fast Roaming is enabled, signal the supplicant
16915 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053016916 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016917 {
16918 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016919 vos_mem_copy((void *)&roamInfo.bssid,
16920 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016921 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
16922 }
16923
16924#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016925
16926 // Done with it, init it.
16927 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
16928}
16929#endif
16930#ifdef FEATURE_WLAN_BTAMP_UT_RF
16931void csrRoamJoinRetryTimerHandler(void *pv)
16932{
16933 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
16934 tpAniSirGlobal pMac = pInfo->pMac;
16935 tANI_U32 sessionId = pInfo->sessionId;
16936 tCsrRoamSession *pSession;
16937
16938 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16939 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016940 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016941 pSession = CSR_GET_SESSION( pMac, sessionId );
16942 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
16943 {
16944 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
16945 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016946 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016947 }
16948 }
16949 }
16950}
Jeff Johnson295189b2012-06-20 16:38:30 -070016951eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
16952{
16953 eHalStatus status = eHAL_STATUS_FAILURE;
16954 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16955
16956 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
16957 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016958 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070016959 pSession->maxRetryCount--;
16960 pSession->joinRetryTimerInfo.pMac = pMac;
16961 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016962 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
16963 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016964 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016965 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016966 }
16967 }
16968 else
16969 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016970 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070016971 pSession->maxRetryCount);
16972 }
16973
16974 return (status);
16975}
Jeff Johnson295189b2012-06-20 16:38:30 -070016976eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
16977{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016978 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070016979 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16980 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016981 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070016982 }
16983
16984 return eHAL_STATUS_SUCCESS;
16985}
16986#endif
16987
16988
16989/*
16990 pBuf points to the beginning of the message
16991 LIM packs disassoc rsp as below,
16992 messageType - 2 bytes
16993 messageLength - 2 bytes
16994 sessionId - 1 byte
16995 transactionId - 2 bytes (tANI_U16)
16996 reasonCode - 4 bytes (sizeof(tSirResultCodes))
16997 peerMacAddr - 6 bytes
16998 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
16999*/
17000static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17001{
17002 if(pBuf && pRsp)
17003 {
17004 pBuf += 4; //skip type and length
17005 pRsp->sessionId = *pBuf++;
17006 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17007 pBuf += 2;
17008 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17009 pBuf += 4;
17010 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17011 }
17012}
17013
Jeff Johnsond13512a2012-07-17 11:42:19 -070017014eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17015{
17016 static uNvTables nvTables;
17017 eHalStatus status = eHAL_STATUS_SUCCESS;
17018 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17019
17020 /* read the country code from NV and use it */
17021 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17022 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017023 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17024 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017025 return status;
17026 }
17027 else
17028 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017029 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017030 status = eHAL_STATUS_FAILURE;
17031 return status;
17032 }
17033}
17034
17035eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17036{
Kiet Lam64c1b492013-07-12 13:56:44 +053017037 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017038 return eHAL_STATUS_SUCCESS;
17039}
schang86c22c42013-03-13 18:41:24 -070017040
17041eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17042{
17043 tSirSetTxPowerReq *pMsg = NULL;
17044 eHalStatus status = eHAL_STATUS_SUCCESS;
17045 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17046
17047 if (!pSession)
17048 {
17049 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17050 return eHAL_STATUS_FAILURE;
17051 }
17052
Kiet Lam64c1b492013-07-12 13:56:44 +053017053 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17054 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17055 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17056 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17057 pMsg->length = sizeof(tSirSetTxPowerReq);
17058 pMsg->mwPower = mW;
17059 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17060 sizeof(tSirMacAddr));
17061 status = palSendMBMessage(pMac->hHdd, pMsg);
17062 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017063 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017064 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17065 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017066 }
17067 return status;
17068}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017069
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017070eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17071{
17072 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17073 eHalStatus status = eHAL_STATUS_SUCCESS;
17074 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17075
17076 if (!pSession)
17077 {
17078 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17079 return eHAL_STATUS_FAILURE;
17080 }
17081 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17082 {
17083 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
17084 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17085 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17086 pMsg->length = sizeof(tANI_U8);
17087 pMsg->seesionId = sessionId;
17088 status = palSendMBMessage(pMac->hHdd, pMsg);
17089 if (!HAL_STATUS_SUCCESS(status))
17090 {
17091 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17092 //pMsg is freed by palSendMBMessage
17093 }
17094 }
17095 else
17096 {
17097 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17098 status = eHAL_STATUS_FAILURE;
17099 }
17100 return status;
17101}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017102/* Returns whether a session is in VOS_STA_MODE...or not */
17103tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17104{
17105 tCsrRoamSession *pSession = NULL;
17106 pSession = CSR_GET_SESSION ( pMac, sessionId );
17107 if(!pSession)
17108 {
17109 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17110 return eANI_BOOLEAN_FALSE;
17111 }
17112 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17113 {
17114 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17115 return eANI_BOOLEAN_FALSE;
17116 }
17117 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17118 {
17119 return eANI_BOOLEAN_FALSE;
17120 }
17121 /* There is a possibility that the above check may fail,because
17122 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17123 * when it is connected.So,we may sneak through the above check even
17124 * if we are not a STA mode INFRA station. So, if we sneak through
17125 * the above condition, we can use the following check if we are
17126 * really in STA Mode.*/
17127
17128 if ( NULL != pSession->pCurRoamProfile )
17129 {
17130 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17131 {
17132 return eANI_BOOLEAN_TRUE;
17133 } else {
17134 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17135 return eANI_BOOLEAN_FALSE;
17136 }
17137 }
17138
17139 return eANI_BOOLEAN_FALSE;
17140}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017141
17142#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17143eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17144 tCsrHandoffRequest *pHandoffInfo)
17145{
17146 eHalStatus status = eHAL_STATUS_SUCCESS;
17147 vos_msg_t msg;
17148
17149 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017150 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17151 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017152 {
17153 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017154 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017155 }
17156 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17157 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17158 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17159 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017160 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017161 pHandoffInfo->bssid,
17162 6);
17163 msg.type = eWNI_SME_HANDOFF_REQ;
17164 msg.bodyptr = pMsg;
17165 msg.reserved = 0;
17166 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17167 {
17168 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017169 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017170 status = eHAL_STATUS_FAILURE;
17171 }
17172 return status;
17173}
17174#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017175
17176#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
17177/* ---------------------------------------------------------------------------
17178 \fn csrSetCCKMIe
17179 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17180 data structure and this IE will be packed inside reassociation request
17181 \param pMac - pMac global structure
17182 \param sessionId - Current session id
17183 \param pCckmIe - pointer to CCKM IE data
17184 \param ccKmIeLen - length of the CCKM IE
17185 \- return Success or failure
17186 -------------------------------------------------------------------------*/
17187VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17188 const tANI_U8 *pCckmIe,
17189 const tANI_U8 ccKmIeLen)
17190{
17191 eHalStatus status = eHAL_STATUS_SUCCESS;
17192 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17193
17194 if (!pSession)
17195 {
17196 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17197 return eHAL_STATUS_FAILURE;
17198 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017199 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017200 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17201 return status;
17202}
17203
17204/* ---------------------------------------------------------------------------
17205 \fn csrRoamReadTSF
17206 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17207 probe response reception from the hand off AP to arrive at the latest TSF value.
17208 \param pMac - pMac global structure
17209 \param pTimestamp - output TSF timestamp
17210 \- return Success or failure
17211 -------------------------------------------------------------------------*/
17212VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17213{
17214 eHalStatus status = eHAL_STATUS_SUCCESS;
17215 tCsrNeighborRoamBSSInfo handoffNode;
17216 tANI_U32 timer_diff = 0;
17217 tANI_U32 timeStamp[2];
17218 tpSirBssDescription pBssDescription = NULL;
17219
17220 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17221 pBssDescription = handoffNode.pBssDescription;
17222
17223 // Get the time diff in milli seconds
17224 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17225 // Convert msec to micro sec timer
17226 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17227
17228 timeStamp[0] = pBssDescription->timeStamp[0];
17229 timeStamp[1] = pBssDescription->timeStamp[1];
17230
17231 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17232
Kiet Lamf2f201e2013-11-16 21:24:16 +053017233 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017234 sizeof (tANI_U32) * 2);
17235 return status;
17236}
17237
17238#endif /*FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
17239