blob: 1f8ecad1d370bce8cb3ad90dd0068a3d8afb0c1e [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -08002 * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/** ------------------------------------------------------------------------- *
43 ------------------------------------------------------------------------- *
Jeff Johnsone7245742012-09-05 17:12:55 -070044
Jeff Johnson295189b2012-06-20 16:38:30 -070045
46 \file csrApiRoam.c
47
48 Implementation for the Common Roaming interfaces.
49
Jeff Johnson295189b2012-06-20 16:38:30 -070050
51 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070052/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070053 EDIT HISTORY FOR FILE
54
Jeff Johnson295189b2012-06-20 16:38:30 -070055 This section contains comments describing changes made to the module.
56 Notice that changes are listed in reverse chronological order.
57
Jeff Johnson295189b2012-06-20 16:38:30 -070058 when who what, where, why
59---------- --- --------------------------------------------------------
6006/03/10 js Added support to hostapd driven
61 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070062===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070063#include "aniGlobal.h" //for tpAniSirGlobal
64#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070066#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070067#include "palApi.h"
68#include "csrInsideApi.h"
69#include "smsDebug.h"
70#include "logDump.h"
71#include "smeQosInternal.h"
72#include "wlan_qct_tl.h"
73#include "smeInside.h"
74#include "vos_diag_core_event.h"
75#include "vos_diag_core_log.h"
76#include "csrApi.h"
77#include "pmc.h"
78#include "vos_nvitem.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070079#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
80#include "csrNeighborRoam.h"
81#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070082#if defined(FEATURE_WLAN_CCX) && !defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -070083#include "csrCcx.h"
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070084#endif /* FEATURE_WLAN_CCX && !FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070085#define CSR_NUM_IBSS_START_CHANNELS_50 4
86#define CSR_NUM_IBSS_START_CHANNELS_24 3
87#define CSR_DEF_IBSS_START_CHANNEL_50 36
88#define CSR_DEF_IBSS_START_CHANNEL_24 1
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080089#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 -070090#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
91/*---------------------------------------------------------------------------
92 OBIWAN recommends [8 10]% : pick 9%
93---------------------------------------------------------------------------*/
94#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070095/*---------------------------------------------------------------------------
96 OBIWAN recommends -85dBm
97---------------------------------------------------------------------------*/
98#define CSR_VCC_RSSI_THRESHOLD 80
99#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
100#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
101#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
102#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -0700103//We use constatnt 4 here
104//This macro returns true when higher AC parameter is bigger than lower AC for a difference
105//The bigger the number, the less chance of TX
106//It must put lower AC as the first parameter.
107#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700108//Flag to send/do not send disassoc frame over the air
109#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700110#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700111#define MAX_CB_VALUE_IN_INI (2)
112
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700113#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
114static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
115#endif
116
Jeff Johnson295189b2012-06-20 16:38:30 -0700117/*--------------------------------------------------------------------------
118 Static Type declarations
119 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800120static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122/*--------------------------------------------------------------------------
123 Type declarations
124 ------------------------------------------------------------------------*/
125#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700126int diagAuthTypeFromCSRType(eCsrAuthType authType)
127{
128 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700129 switch(authType)
130 {
131 case eCSR_AUTH_TYPE_SHARED_KEY:
132 n = AUTH_SHARED;
133 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700134 case eCSR_AUTH_TYPE_WPA:
135 n = AUTH_WPA_EAP;
136 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700137 case eCSR_AUTH_TYPE_WPA_PSK:
138 n = AUTH_WPA_PSK;
139 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700140 case eCSR_AUTH_TYPE_RSN:
141 n = AUTH_WPA2_EAP;
142 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700143 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700144#ifdef WLAN_FEATURE_11W
145 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
146#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700147 n = AUTH_WPA2_PSK;
148 break;
149#ifdef FEATURE_WLAN_WAPI
150 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
151 n = AUTH_WAPI_CERT;
152 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700153 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
154 n = AUTH_WAPI_PSK;
155 break;
156#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700157 default:
158 break;
159 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700160 return (n);
161}
Jeff Johnson295189b2012-06-20 16:38:30 -0700162int diagEncTypeFromCSRType(eCsrEncryptionType encType)
163{
164 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700165 switch(encType)
166 {
167 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
168 case eCSR_ENCRYPT_TYPE_WEP40:
169 n = ENC_MODE_WEP40;
170 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700171 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
172 case eCSR_ENCRYPT_TYPE_WEP104:
173 n = ENC_MODE_WEP104;
174 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700175 case eCSR_ENCRYPT_TYPE_TKIP:
176 n = ENC_MODE_TKIP;
177 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700178 case eCSR_ENCRYPT_TYPE_AES:
179 n = ENC_MODE_AES;
180 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700181#ifdef FEATURE_WLAN_WAPI
182 case eCSR_ENCRYPT_TYPE_WPI:
183 n = ENC_MODE_SMS4;
184 break;
185#endif /* FEATURE_WLAN_WAPI */
186 default:
187 break;
188 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 return (n);
190}
Jeff Johnson295189b2012-06-20 16:38:30 -0700191#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700192static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
193static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700194static void initConfigParam(tpAniSirGlobal pMac);
195static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
196 eCsrRoamCompleteResult Result, void *Context );
197static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
198 tCsrRoamProfile *pProfile,
199 tANI_BOOLEAN *pfSameIbss );
200static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
201static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700202 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
203static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700204eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
205static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
206eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
207eHalStatus csrRoamClose(tpAniSirGlobal pMac);
208void csrRoamMICErrorTimerHandler(void *pv);
209void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
210tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
211
212static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
213static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
214static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700215eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
216eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
217static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700218static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700219static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700220static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
221eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
222 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
223 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
224 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
225 tANI_U8 *pKeyRsc );
226static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
227 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
228 tCsrRoamProfile *pProfile );
229void csrRoamStatisticsTimerHandler(void *pv);
230void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700231static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
232VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
233 v_U8_t rssiNotification,
234 void * context);
235static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
236void csrRoamVccTrigger(tpAniSirGlobal pMac);
237eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
238/*
239 pStaEntry is no longer invalid upon the return of this function.
240*/
241static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700242static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700243static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700244tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
245 tDblLinkList *pStaList,
246 tCsrStatsClientReqInfo *pStaEntry);
247void csrRoamStatsClientTimerHandler(void *pv);
248tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
249 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
250void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
251 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700252void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700253void csrRoamTlStatsTimerHandler(void *pv);
254void csrRoamPeStatsTimerHandler(void *pv);
255tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
256void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
257tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
258eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
259static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
260static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
261static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
262static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
263 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
264//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
265static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
266void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
267#ifdef FEATURE_WLAN_BTAMP_UT_RF
268void csrRoamJoinRetryTimerHandler(void *pv);
269#endif
270extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700271extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700272static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700273void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700274
275//Initialize global variables
276static void csrRoamInitGlobals(tpAniSirGlobal pMac)
277{
278 if(pMac)
279 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800280 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
281 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 }
283 return;
284}
285
Jeff Johnson295189b2012-06-20 16:38:30 -0700286static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
287{
288 if(pMac)
289 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800290 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700291 }
292 return;
293}
Jeff Johnson295189b2012-06-20 16:38:30 -0700294eHalStatus csrOpen(tpAniSirGlobal pMac)
295{
296 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530297#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700298 static uNvTables nvTables;
299 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700300 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530301#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700302 tANI_U32 i;
303
304 do
305 {
306 /* Initialize CSR Roam Globals */
307 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700308 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
309 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
310
311 initConfigParam(pMac);
312 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
313 break;
314 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
315 break;
316 pMac->roam.nextRoamId = 1; //Must not be 0
317 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
318 break;
319 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
320 break;
321 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
322 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530323
324#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700325 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
326 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
327 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530328 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
329 WNI_CFG_COUNTRY_CODE_LEN);
330 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 }
332 else
333 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800334 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700335 //hardcoded for now
336 pMac->scan.countryCodeDefault[0] = 'U';
337 pMac->scan.countryCodeDefault[1] = 'S';
338 pMac->scan.countryCodeDefault[2] = 'I';
339 //status = eHAL_STATUS_SUCCESS;
340 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700341 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530342
343 if (!('0' == pMac->scan.countryCodeDefault[0] &&
344 '0' == pMac->scan.countryCodeDefault[1]))
345 {
346 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
347 &regId, COUNTRY_NV);
348 }
349 else
350 {
351 regId = REGDOMAIN_WORLD;
352 }
Abhishek Singha306a442013-11-07 18:39:01 +0530353 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700354 pMac->scan.domainIdDefault = regId;
355 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530356 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
357 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700358 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530359#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700360 }while(0);
361
362 return (status);
363}
364
Mihir Shetee1093ba2014-01-21 20:13:32 +0530365/* --------------------------------------------------------------------------
366 \fn csrInitChannels
367 \brief This function must be called to initialize CSR channel lists
368 \return eHalStatus
369 ----------------------------------------------------------------------------*/
370eHalStatus csrInitChannels(tpAniSirGlobal pMac)
371{
372 eHalStatus status = eHAL_STATUS_SUCCESS;
373 static uNvTables nvTables;
374 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
375 v_REGDOMAIN_t regId;
376
377 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
378 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
379 {
380 vos_mem_copy(pMac->scan.countryCodeDefault,
381 nvTables.defaultCountryTable.countryCode,
382 WNI_CFG_COUNTRY_CODE_LEN);
383 }
384 else
385 {
386 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
387 //hardcoded for now
388 pMac->scan.countryCodeDefault[0] = 'U';
389 pMac->scan.countryCodeDefault[1] = 'S';
390 pMac->scan.countryCodeDefault[2] = 'I';
391 }
392 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
393
394 if (!('0' == pMac->scan.countryCodeDefault[0] &&
395 '0' == pMac->scan.countryCodeDefault[1]))
396 {
397 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
398 &regId, COUNTRY_NV);
399 }
400 else
401 {
402 regId = REGDOMAIN_WORLD;
403 }
404
405 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
406 pMac->scan.domainIdDefault = regId;
407 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
408 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
409 WNI_CFG_COUNTRY_CODE_LEN);
410 status = csrInitGetChannels( pMac );
411
412 return status;
413}
414
Jeff Johnson295189b2012-06-20 16:38:30 -0700415eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
416{
417 eHalStatus status = eHAL_STATUS_SUCCESS;
418 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
419 v_REGDOMAIN_t regId;
420 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700421 if(NULL == apCntryCode)
422 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530423 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700424 return eHAL_STATUS_FAILURE;
425 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530426 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700427 /* To get correct Regulatory domain from NV table
428 * 2 character Country code should be used
429 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700430 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
431/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700432 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700433
434 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
435 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800436 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700437 return eHAL_STATUS_FAILURE;
438 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700439*/
Kiet Lam6c583332013-10-14 05:37:09 +0530440 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
441 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700442 if (status != eHAL_STATUS_SUCCESS)
443 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700444 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700445 return status;
446 }
Abhishek Singha306a442013-11-07 18:39:01 +0530447 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 if (status != eHAL_STATUS_SUCCESS)
449 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700450 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700451 return status;
452 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 pMac->scan.domainIdDefault = regId;
454 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530456 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
457
Jeff Johnson295189b2012-06-20 16:38:30 -0700458 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530459 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
460
Jeff Johnson295189b2012-06-20 16:38:30 -0700461 /* If 2 bytes country code, 3rd byte must be filled with space */
462 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
463 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530464 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700465 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530466 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
467 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700469 return status;
470}
Jeff Johnson295189b2012-06-20 16:38:30 -0700471eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
472{
473 eHalStatus status = eHAL_STATUS_SUCCESS;
474 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
475 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530476 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
477 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
479 {
480 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
481 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
482 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
483 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
484 }
485 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
486
487 return status;
488}
Jeff Johnson295189b2012-06-20 16:38:30 -0700489eHalStatus csrClose(tpAniSirGlobal pMac)
490{
491 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800492
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 csrRoamClose(pMac);
494 csrScanClose(pMac);
495 csrLLClose(&pMac->roam.statsClientReqList);
496 csrLLClose(&pMac->roam.peStatsReqList);
497 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 /* DeInit Globals */
499 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700500 return (status);
501}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530502
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800503eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530504{
505 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800506 tCsrScanStruct *pScan = &pMac->scan;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530507 tANI_U8 numChan = pScan->base20MHzChannels.numChannels;
508 tANI_U32 bufLen = sizeof(tSirUpdateChanList) +
509 (sizeof(tSirUpdateChanParam) * (numChan - 1));
510 vos_msg_t msg;
511 tANI_U8 i;
512
513 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
514 if (!pChanList)
515 {
516 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
517 "Failed to allocate memory for tSirUpdateChanList");
518 return eHAL_STATUS_FAILED_ALLOC;
519 }
520
521 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
522 msg.reserved = 0;
523 msg.bodyptr = pChanList;
524 pChanList->numChan = numChan;
525 for (i = 0; i < pChanList->numChan; i++)
526 {
527 pChanList->chanParam[i].chanId = pScan->defaultPowerTable[i].chanId;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800528 pChanList->chanParam[i].pwr = cfgGetRegulatoryMaxTransmitPower(pMac,
529 pScan->defaultPowerTable[i].chanId);
530 if (vos_nv_getChannelEnabledState(pChanList->chanParam[i].chanId) ==
531 NV_CHANNEL_DFS)
532 pChanList->chanParam[i].dfsSet = VOS_TRUE;
533 else
534 pChanList->chanParam[i].dfsSet = VOS_FALSE;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530535 }
536
537 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
538 {
539 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
540 "%s: Failed to post msg to WDA", __func__);
541 vos_mem_free(pChanList);
542 return eHAL_STATUS_FAILURE;
543 }
544
545 return eHAL_STATUS_SUCCESS;
546}
547
Jeff Johnson295189b2012-06-20 16:38:30 -0700548eHalStatus csrStart(tpAniSirGlobal pMac)
549{
550 eHalStatus status = eHAL_STATUS_SUCCESS;
551 tANI_U32 i;
552
553 do
554 {
555 //save the global vos context
556 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
557 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
558 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
559
560 status = csrRoamStart(pMac);
561 if(!HAL_STATUS_SUCCESS(status)) break;
562 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
563 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
564 if(!HAL_STATUS_SUCCESS(status)) break;
565 pMac->roam.sPendingCommands = 0;
566 csrScanEnable(pMac);
567#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
568 status = csrNeighborRoamInit(pMac);
569#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
570 pMac->roam.tlStatsReqInfo.numClient = 0;
571 pMac->roam.tlStatsReqInfo.periodicity = 0;
572 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
573 //init the link quality indication also
574 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
575 if(!HAL_STATUS_SUCCESS(status))
576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800577 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700578 break;
579 }
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800580#ifdef QCA_WIFI_2_0
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530581 if (pMac->fScanOffload)
582 {
583 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
584 "Scan offload is enabled, update default chan list");
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800585 status = csrUpdateChannelList(pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530586 }
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800587#else
588 status = csrUpdateChannelList(pMac);
589#endif
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530590
Jeff Johnson295189b2012-06-20 16:38:30 -0700591 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700592#if defined(ANI_LOGDUMP)
593 csrDumpInit(pMac);
594#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700595 return (status);
596}
597
Kiet Lama72a2322013-11-15 11:18:11 +0530598eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700599{
600 tANI_U32 sessionId;
601 tANI_U32 i;
602
603 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
604 {
605 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
606 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 csrScanDisable(pMac);
608 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
609 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
611
612#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
613 csrNeighborRoamClose(pMac);
614#endif
615 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700616 // deregister from PMC since we register during csrStart()
617 // (ignore status since there is nothing we can do if it fails)
618 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700619 //Reset the domain back to the deault
620 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800621 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700622
623 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
624 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530625 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700626 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
627 }
628
Kiet Lama72a2322013-11-15 11:18:11 +0530629#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
630 /* When HAL resets all the context information
631 * in HAL is lost, so we might need to send the
632 * scan offload request again when it comes
633 * out of reset for scan offload to be functional
634 */
635 if (HAL_STOP_TYPE_SYS_RESET == stopType)
636 {
637 bRoamScanOffloadStarted = VOS_FALSE;
638 }
639#endif
640
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 return (eHAL_STATUS_SUCCESS);
642}
643
Jeff Johnson295189b2012-06-20 16:38:30 -0700644eHalStatus csrReady(tpAniSirGlobal pMac)
645{
646 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700647 csrScanGetSupportedChannels( pMac );
648 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
649 //use it to init the background scan list
650 csrInitBGScanChannelList(pMac);
651 /* HDD issues the init scan */
652 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800653 /* If the gScanAgingTime is set to '0' then scan results aging timeout
654 based on timer feature is not enabled*/
655 if(0 != pMac->scan.scanResultCfgAgingTime )
656 {
657 csrScanStartResultCfgAgingTimer(pMac);
658 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 //Store the AC weights in TL for later use
660 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 status = csrInitChannelList( pMac );
662 if ( ! HAL_STATUS_SUCCESS( status ) )
663 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800664 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 status );
666 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 return (status);
668}
Jeff Johnson295189b2012-06-20 16:38:30 -0700669void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
670{
671 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700672 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
673 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
674}
Jeff Johnson295189b2012-06-20 16:38:30 -0700675void csrSetGlobalCfgs( tpAniSirGlobal pMac )
676{
Jeff Johnsone7245742012-09-05 17:12:55 -0700677
Jeff Johnson295189b2012-06-20 16:38:30 -0700678 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
679 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
680 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
681 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
682 NULL, eANI_BOOLEAN_FALSE);
683 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700684 /* 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
685 * Once session is established we will use the session related params stored in PE session for CB mode
686 */
687 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700688 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
689
690 //Update the operating mode to configured value during initialization,
691 //So that client can advertise full capabilities in Probe request frame.
692 csrSetDefaultDot11Mode( pMac );
693}
694
Jeff Johnson295189b2012-06-20 16:38:30 -0700695eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
696{
697 eHalStatus status = eHAL_STATUS_SUCCESS;
698 tANI_U32 i;
699 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 do
701 {
702 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
703 {
704 pSession = CSR_GET_SESSION( pMac, i );
705 pSession->roamingTimerInfo.pMac = pMac;
706 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
707 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
709 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530710 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
711 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700712 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530713 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800715 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 break;
717 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530718 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
719 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
720 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800722 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 return eHAL_STATUS_FAILURE;
724 }
725 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 return (status);
727}
728
Jeff Johnson295189b2012-06-20 16:38:30 -0700729eHalStatus csrRoamClose(tpAniSirGlobal pMac)
730{
731 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
733 {
734 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
735 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530736 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
737 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
738 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
739 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 return (eHAL_STATUS_SUCCESS);
741}
742
Jeff Johnson295189b2012-06-20 16:38:30 -0700743eHalStatus csrRoamStart(tpAniSirGlobal pMac)
744{
745 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 return (eHAL_STATUS_SUCCESS);
747}
748
Jeff Johnson295189b2012-06-20 16:38:30 -0700749void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
750{
751 csrRoamStopRoamingTimer(pMac, sessionId);
752 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
753 csrRoamDeregStatisticsReq(pMac);
754}
Jeff Johnson295189b2012-06-20 16:38:30 -0700755eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
756{
757 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800758 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 {
760 status = eHAL_STATUS_SUCCESS;
761 *pState = pMac->roam.roamSession[sessionId].connectState;
762 }
763 return (status);
764}
765
Jeff Johnson295189b2012-06-20 16:38:30 -0700766eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
767{
768 eHalStatus status = eHAL_STATUS_FAILURE;
769 tANI_U32 size = 0;
770 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700771
772 if(!pSession)
773 {
774 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
775 return eHAL_STATUS_FAILURE;
776 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700777
778 if(pProfile)
779 {
780 if(pSession->pConnectBssDesc)
781 {
782 do
783 {
784 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
785 if(size)
786 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530787 pProfile->pBssDesc = vos_mem_malloc(size);
788 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530790 vos_mem_copy(pProfile->pBssDesc,
791 pSession->pConnectBssDesc, size);
792 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 }
794 else
795 break;
796 }
797 else
798 {
799 pProfile->pBssDesc = NULL;
800 }
801 pProfile->AuthType = pSession->connectedProfile.AuthType;
802 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
803 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
804 pProfile->BSSType = pSession->connectedProfile.BSSType;
805 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
806 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530807 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
808 sizeof(tCsrBssid));
809 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
810 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700811#ifdef WLAN_FEATURE_VOWIFI_11R
812 if (pSession->connectedProfile.MDID.mdiePresent)
813 {
814 pProfile->MDID.mdiePresent = 1;
815 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
816 }
817 else
818 {
819 pProfile->MDID.mdiePresent = 0;
820 pProfile->MDID.mobilityDomain = 0;
821 }
822#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700823#ifdef FEATURE_WLAN_CCX
824 pProfile->isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700825 if (csrIsAuthTypeCCX(pSession->connectedProfile.AuthType))
826 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530827 vos_mem_copy (pProfile->ccxCckmInfo.krk,
828 pSession->connectedProfile.ccxCckmInfo.krk,
829 CSR_KRK_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 pProfile->ccxCckmInfo.reassoc_req_num=
831 pSession->connectedProfile.ccxCckmInfo.reassoc_req_num;
832 pProfile->ccxCckmInfo.krk_plumbed =
833 pSession->connectedProfile.ccxCckmInfo.krk_plumbed;
834 }
835#endif
836 }while(0);
837 }
838 }
839
840 return (status);
841}
842
Jeff Johnson295189b2012-06-20 16:38:30 -0700843eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
844{
845 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700846
847 if((csrIsConnStateConnected(pMac, sessionId)) ||
848 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 {
850 if(pProfile)
851 {
852 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
853 }
854 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 return (status);
856}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700857
Jeff Johnson295189b2012-06-20 16:38:30 -0700858eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
859{
860 eHalStatus status = eHAL_STATUS_SUCCESS;
861
Kiet Lam64c1b492013-07-12 13:56:44 +0530862 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700863 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530864 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530866 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700867 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530868 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700869 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530870 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
871
Jeff Johnson295189b2012-06-20 16:38:30 -0700872 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
873 return (status);
874}
875
Jeff Johnson295189b2012-06-20 16:38:30 -0700876static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
877{
878 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 if( pConnectedInfo->pbFrames )
880 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530881 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700882 pConnectedInfo->pbFrames = NULL;
883 }
884 pConnectedInfo->nBeaconLength = 0;
885 pConnectedInfo->nAssocReqLength = 0;
886 pConnectedInfo->nAssocRspLength = 0;
887 pConnectedInfo->staId = 0;
888#ifdef WLAN_FEATURE_VOWIFI_11R
889 pConnectedInfo->nRICRspLength = 0;
890#endif
891#ifdef FEATURE_WLAN_CCX
892 pConnectedInfo->nTspecIeLength = 0;
893#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700894 return ( status );
895}
896
Jeff Johnson295189b2012-06-20 16:38:30 -0700897
898
Jeff Johnsone7245742012-09-05 17:12:55 -0700899
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700900void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
901{
902 csrReinitPreauthCmd(pMac, pCommand);
903 csrReleaseCommand( pMac, pCommand );
904}
905
Jeff Johnson295189b2012-06-20 16:38:30 -0700906void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
907{
908 csrReinitRoamCmd(pMac, pCommand);
909 csrReleaseCommand( pMac, pCommand );
910}
911
Jeff Johnson295189b2012-06-20 16:38:30 -0700912void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
913{
914 csrReinitScanCmd(pMac, pCommand);
915 csrReleaseCommand( pMac, pCommand );
916}
917
Jeff Johnson295189b2012-06-20 16:38:30 -0700918void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
919{
920 csrReinitWmStatusChangeCmd(pMac, pCommand);
921 csrReleaseCommand( pMac, pCommand );
922}
923
Jeff Johnson295189b2012-06-20 16:38:30 -0700924void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
925{
Kiet Lam64c1b492013-07-12 13:56:44 +0530926 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700927}
928
Jeff Johnson295189b2012-06-20 16:38:30 -0700929void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
930{
Kiet Lam64c1b492013-07-12 13:56:44 +0530931 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700932}
933
Jeff Johnson295189b2012-06-20 16:38:30 -0700934void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
935{
936 csrReinitSetKeyCmd(pMac, pCommand);
937 csrReleaseCommand( pMac, pCommand );
938}
Jeff Johnson295189b2012-06-20 16:38:30 -0700939void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
940{
941 csrReinitRemoveKeyCmd(pMac, pCommand);
942 csrReleaseCommand( pMac, pCommand );
943}
Jeff Johnson295189b2012-06-20 16:38:30 -0700944void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
945{
946
947 if( eSmeCsrCommandMask & pCommand->command )
948 {
949 switch (pCommand->command)
950 {
951 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800952 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -0800953 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
954 __func__, pCommand->u.scanCmd.reason,
955 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700956 if (NULL != pCommand->u.scanCmd.callback)
957 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800958 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700959 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
960 }
961 csrReleaseCommandScan( pMac, pCommand );
962 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 case eSmeCommandRoam:
964 csrReleaseCommandRoam( pMac, pCommand );
965 break;
966
967 case eSmeCommandWmStatusChange:
968 csrReleaseCommandWmStatusChange( pMac, pCommand );
969 break;
970
971 case eSmeCommandSetKey:
972 csrReleaseCommandSetKey( pMac, pCommand );
973 break;
974
975 case eSmeCommandRemoveKey:
976 csrReleaseCommandRemoveKey( pMac, pCommand );
977 break;
978
979 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800980 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 csrReleaseCommand( pMac, pCommand );
982 break;
983 }
984 }
985}
986
Jeff Johnson295189b2012-06-20 16:38:30 -0700987void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
988{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800989 smsLog( pMac, LOG1, " CSR RoamSubstate: [ %d <== %d ]", NewSubstate, pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700990
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 if(pMac->roam.curSubState[sessionId] == NewSubstate)
992 {
993 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700994 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700995 pMac->roam.curSubState[sessionId] = NewSubstate;
996}
997
Jeff Johnson295189b2012-06-20 16:38:30 -0700998eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
999{
1000 eCsrRoamState PreviousState;
1001
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +05301002 smsLog( pMac, LOG1, "CSR RoamState[%hu]: [ %d <== %d ]", sessionId,
1003 NewRoamState, pMac->roam.curState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001004
1005 PreviousState = pMac->roam.curState[sessionId];
1006
1007 if ( NewRoamState != pMac->roam.curState[sessionId] )
1008 {
1009 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1010 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1011 {
1012 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1013 }
1014
1015 pMac->roam.curState[sessionId] = NewRoamState;
1016 }
1017 return( PreviousState );
1018}
1019
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001020void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001021{
1022 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001023 if(catOffset)
1024 {
1025 pMac->roam.configParam.bCatRssiOffset = catOffset;
1026 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1027 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001028 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 -07001029 }
1030 }
1031}
1032
Jeff Johnson295189b2012-06-20 16:38:30 -07001033static void initConfigParam(tpAniSirGlobal pMac)
1034{
1035 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001036 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
1037 pMac->roam.configParam.channelBondingMode24GHz = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1038 pMac->roam.configParam.channelBondingMode5GHz = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001039
Jeff Johnson295189b2012-06-20 16:38:30 -07001040 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1041 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1042 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1043 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1044 pMac->roam.configParam.HeartbeatThresh24 = 40;
1045 pMac->roam.configParam.HeartbeatThresh50 = 40;
1046 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1047 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1048 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001049 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001050 pMac->roam.configParam.RTSThreshold = 2346;
1051 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1052 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1053 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1054 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1055 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1056 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1057 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1058 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1059 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1060 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1061 {
1062 pMac->roam.configParam.BssPreferValue[i] = i;
1063 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001064 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1066 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1067 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001068 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1069 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
1070 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1071 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1072 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1073 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001074 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1075 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001076 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001077#ifdef WLAN_AP_STA_CONCURRENCY
1078 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1079 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1080 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1081 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1082 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001083 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1084 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001085#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001086 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1087 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1088 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1089 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001090#ifdef WLAN_FEATURE_VOWIFI_11R
1091 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1092#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001093#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1094 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1095 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1096 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1097 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1098 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1099 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1100 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1101 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1102 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1103 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1104 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001105 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001106#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001107#ifdef WLAN_FEATURE_11AC
1108 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1109#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001110
1111 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1112 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001113
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001114 //Remove this code once SLM_Sessionization is supported
1115 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001116 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001117
Jeff Johnsone7245742012-09-05 17:12:55 -07001118}
Jeff Johnson295189b2012-06-20 16:38:30 -07001119eCsrBand csrGetCurrentBand(tHalHandle hHal)
1120{
1121 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1122 return pMac->roam.configParam.bandCapability;
1123}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001124
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001125
1126#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
1127/*
1128 This function flushes the roam scan cache
1129*/
1130eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1131{
1132 eHalStatus status = eHAL_STATUS_SUCCESS;
1133 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1134
1135 /* Free up the memory first (if required) */
1136 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1137 {
1138 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1139 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1140 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1141 }
1142 return status;
1143}
1144#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
1145
1146
Srinivas Girigowdade697412013-02-14 16:31:48 -08001147#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001148/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001149 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001150*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001151eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001152{
1153 eHalStatus status = eHAL_STATUS_SUCCESS;
1154 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1155
1156 /* Free up the memory first (if required) */
1157 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1158 {
1159 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1160 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001161 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001162 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001163 return status;
1164}
1165
1166
1167
1168/*
1169 This function flushes the roam scan cache and creates fresh cache
1170 based on the input channel list
1171*/
1172eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1173 const tANI_U8 *pChannelList,
1174 const tANI_U8 numChannels)
1175{
1176 eHalStatus status = eHAL_STATUS_SUCCESS;
1177 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1178
Srinivas Girigowdade697412013-02-14 16:31:48 -08001179 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1180
1181 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1182 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1183
1184 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1185 {
1186 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1187 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1188 return eHAL_STATUS_RESOURCES;
1189 }
1190
1191 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301192 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1193 pChannelList,
1194 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001195 return status;
1196}
1197
1198/* This function modifies the bgscan channel list set via config ini or
1199 runtime, whenever the band changes.
1200 if the band is auto, then no operation is performed on the channel list
1201 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1202 if the band is 5G, then make sure channel list contains only 5G valid channels
1203*/
1204eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1205 eCsrBand eBand)
1206{
1207 eHalStatus status = eHAL_STATUS_SUCCESS;
1208 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1209 tANI_U8 outNumChannels = 0;
1210 tANI_U8 inNumChannels = 0;
1211 tANI_U8 *inPtr = NULL;
1212 tANI_U8 i = 0;
1213 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1214
1215 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1216
1217 {
1218 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1219 "No update required for channel list "
1220 "either cfg.ini channel list is not set up or "
1221 "auto band (Band %d)", eBand);
1222 return status;
1223 }
1224
1225 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1226 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1227 if (eCSR_BAND_24 == eBand)
1228 {
1229 for (i = 0; i < inNumChannels; i++)
1230 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001231 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001232 {
1233 ChannelList[outNumChannels++] = inPtr[i];
1234 }
1235 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001236 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001237 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001238 }
1239 else if (eCSR_BAND_5G == eBand)
1240 {
1241 for (i = 0; i < inNumChannels; i++)
1242 {
1243 /* Add 5G Non-DFS channel */
1244 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001245 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001246 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1247 {
1248 ChannelList[outNumChannels++] = inPtr[i];
1249 }
1250 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001251 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001252 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001253 }
1254 else if (eCSR_BAND_ALL == eBand)
1255 {
1256 for (i = 0; i < inNumChannels; i++)
1257 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001258 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001259 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1260 {
1261 ChannelList[outNumChannels++] = inPtr[i];
1262 }
1263 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001264 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001265 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001266 }
1267 else
1268 {
1269 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1270 "Invalid band, No operation carried out (Band %d)", eBand);
1271 status = eHAL_STATUS_INVALID_PARAMETER;
1272 }
1273
1274 return status;
1275}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001276#endif
1277
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001278#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
1279/* This function modifies the roam scan channel list as per AP neighbor
1280 report; AP neighbor report may be empty or may include only other AP
1281 channels; in any case, we merge the channel list with the learned occupied
1282 channels list.
1283 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1284 if the band is 5G, then make sure channel list contains only 5G valid channels
1285*/
1286eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1287 tANI_U8 *pChannelList,
1288 tANI_U8 numChannels,
1289 const eCsrBand eBand)
1290{
1291 eHalStatus status = eHAL_STATUS_SUCCESS;
1292 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1293 tANI_U8 outNumChannels = 0;
1294 tANI_U8 inNumChannels = numChannels;
1295 tANI_U8 *inPtr = pChannelList;
1296 tANI_U8 i = 0;
1297 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1298 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1299 tANI_U8 mergedOutputNumOfChannels = 0;
1300 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1301
1302 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1303 * report Channels. This increases the chances of the DUT to get a candidate AP while
1304 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1305 if (pMac->scan.occupiedChannels.numChannels)
1306 {
1307 csrNeighborRoamMergeChannelLists(pMac,
1308 &pMac->scan.occupiedChannels.channelList[0],
1309 pMac->scan.occupiedChannels.numChannels,
1310 inPtr,
1311 inNumChannels,
1312 &mergedOutputNumOfChannels);
1313 inNumChannels = mergedOutputNumOfChannels;
1314 }
1315
1316 if (eCSR_BAND_24 == eBand)
1317 {
1318 for (i = 0; i < inNumChannels; i++)
1319 {
1320 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1321 {
1322 ChannelList[outNumChannels++] = inPtr[i];
1323 }
1324 }
1325 }
1326 else if (eCSR_BAND_5G == eBand)
1327 {
1328 for (i = 0; i < inNumChannels; i++)
1329 {
1330 /* Add 5G Non-DFS channel */
1331 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1332 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1333 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1334 {
1335 ChannelList[outNumChannels++] = inPtr[i];
1336 }
1337 }
1338 }
1339 else if (eCSR_BAND_ALL == eBand)
1340 {
1341 for (i = 0; i < inNumChannels; i++)
1342 {
1343 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1344 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1345 {
1346 ChannelList[outNumChannels++] = inPtr[i];
1347 }
1348 }
1349 }
1350 else
1351 {
1352 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1353 "Invalid band, No operation carried out (Band %d)", eBand);
1354 return eHAL_STATUS_INVALID_PARAMETER;
1355 }
1356
1357 /* if roaming within band is enabled, then select only the
1358 in band channels .
1359 This is required only if the band capability is set to ALL,
1360 E.g., if band capability is only 2.4G then all the channels in the
1361 list are already filtered for 2.4G channels, hence ignore this check*/
1362
1363 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1364 {
1365 csrNeighborRoamChannelsFilterByCurrentBand(
1366 pMac,
1367 ChannelList,
1368 outNumChannels,
1369 tmpChannelList,
1370 &outNumChannels);
Kiet Lamf2f201e2013-11-16 21:24:16 +05301371 vos_mem_copy(ChannelList,
1372 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001373 }
1374
1375 /* Prepare final roam scan channel list */
1376 if(outNumChannels)
1377 {
1378 /* Clear the channel list first */
1379 if (NULL != currChannelListInfo->ChannelList)
1380 {
1381 vos_mem_free(currChannelListInfo->ChannelList);
1382 currChannelListInfo->ChannelList = NULL;
1383 currChannelListInfo->numOfChannels = 0;
1384 }
1385
1386 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1387 if (NULL == currChannelListInfo->ChannelList)
1388 {
1389 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1390 "Failed to allocate memory for roam scan channel list");
1391 currChannelListInfo->numOfChannels = 0;
1392 return VOS_STATUS_E_RESOURCES;
1393 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301394 vos_mem_copy(currChannelListInfo->ChannelList,
1395 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001396 }
1397 return status;
1398}
1399#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
1400
Jeff Johnson295189b2012-06-20 16:38:30 -07001401eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1402{
1403 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1404 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1406 (eBand == eCSR_BAND_24))
1407 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001408 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001410 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001411 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001412 pMac->roam.configParam.uCfgDot11Mode, eBand);
1413 return eHAL_STATUS_INVALID_PARAMETER;
1414 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1416 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1417 (eBand == eCSR_BAND_5G))
1418 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001419 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001421 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001422 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001423 pMac->roam.configParam.uCfgDot11Mode, eBand);
1424 return eHAL_STATUS_INVALID_PARAMETER;
1425 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001426 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001427 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001428 pMac->roam.configParam.eBand = eBand;
1429 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001430 csrScanGetSupportedChannels( pMac );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001431#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001432 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1433 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001434#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 status = csrInitGetChannels( pMac );
1436 if (eHAL_STATUS_SUCCESS == status)
1437 csrInitChannelList( hHal );
1438 return status;
1439}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001440
1441
Jeff Johnsone7245742012-09-05 17:12:55 -07001442/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1443 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1444 * Ideally we should have kept the ini value and enum value same and representing the same
1445 * cb values as in 11n standard i.e.
1446 * Set to 1 (SCA) if the secondary channel is above the primary channel
1447 * Set to 3 (SCB) if the secondary channel is below the primary channel
1448 * Set to 0 (SCN) if no secondary channel is present
1449 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1450 * 0 - secondary none
1451 * 1 - secondary LOW
1452 * 2 - secondary HIGH
1453 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1454 * The enum values are as follows:
1455 * PHY_SINGLE_CHANNEL_CENTERED = 0
1456 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1457 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1458 */
1459ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1460{
1461
1462 ePhyChanBondState phyCbState;
1463 switch (cbIniValue) {
1464 // secondary none
1465 case 0:
1466 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1467 break;
1468 // secondary LOW
1469 case 1:
1470 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1471 break;
1472 // secondary HIGH
1473 case 2:
1474 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1475 break;
1476#ifdef WLAN_FEATURE_11AC
1477 case 3:
1478 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1479 break;
1480 case 4:
1481 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1482 break;
1483 case 5:
1484 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1485 break;
1486 case 6:
1487 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1488 break;
1489 case 7:
1490 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1491 break;
1492 case 8:
1493 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1494 break;
1495 case 9:
1496 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1497 break;
1498#endif
1499 default:
1500 // If an invalid value is passed, disable CHANNEL BONDING
1501 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1502 break;
1503 }
1504 return phyCbState;
1505}
1506
1507v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1508{
1509
1510 v_U32_t cbIniValue;
1511 switch (phyCbState) {
1512 // secondary none
1513 case PHY_SINGLE_CHANNEL_CENTERED:
1514 cbIniValue = 0;
1515 break;
1516 // secondary LOW
1517 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1518 cbIniValue = 1;
1519 break;
1520 // secondary HIGH
1521 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1522 cbIniValue = 2;
1523 break;
1524#ifdef WLAN_FEATURE_11AC
1525 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1526 cbIniValue = 3;
1527 break;
1528 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1529 cbIniValue = 4;
1530 break;
1531 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1532 cbIniValue = 5;
1533 break;
1534 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1535 cbIniValue = 6;
1536 break;
1537 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1538 cbIniValue = 7;
1539 break;
1540 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1541 cbIniValue = 8;
1542 break;
1543 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1544 cbIniValue = 9;
1545 break;
1546#endif
1547 default:
1548 // return some invalid value
1549 cbIniValue = 10;
1550 break;
1551 }
1552 return cbIniValue;
1553}
Jeff Johnson295189b2012-06-20 16:38:30 -07001554
1555eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1556{
1557 eHalStatus status = eHAL_STATUS_SUCCESS;
1558
1559 if(pParam)
1560 {
1561 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1562 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1563 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1564 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1565 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1566 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1567
1568 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001569 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1570
Jeff Johnsone7245742012-09-05 17:12:55 -07001571 /* channelBondingMode5GHz plays a dual role right now
1572 * 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
1573 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1574 */
1575 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001577 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001578 }
1579 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1580 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1581 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001582 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001583 }
1584 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1586 pMac->roam.configParam.phyMode = pParam->phyMode;
1587 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1588 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1589 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1590 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1591 pMac->roam.configParam.TxRate = pParam->TxRate;
1592 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1593 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1594 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1595 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1596 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001597 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001598 //if HDD passed down non zero values then only update,
1599 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001600 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001601 {
1602 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1603 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001604 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 {
1606 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1607 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001608 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 {
1610 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1611 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001612 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 {
1614 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1615 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001616 if (pParam->nActiveMaxChnTimeBtc)
1617 {
1618 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1619 }
1620 if (pParam->nActiveMinChnTimeBtc)
1621 {
1622 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1623 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001624#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001625 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001626 {
1627 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1628 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001629 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001630 {
1631 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1632 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001633 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001634 {
1635 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1636 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001637 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001638 {
1639 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1640 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001641 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001642 {
1643 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1644 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001645 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001646 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001647 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1648 }
1649 if (pParam->nNumP2PChanCombinedConc)
1650 {
1651 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001652 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001653#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001654 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001655 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 {
1657 //Change the unit from second to microsecond
1658 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1660 {
1661 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1662 }
1663 else
1664 {
1665 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1666 }
1667 }
1668 else
1669 {
1670 pMac->roam.configParam.impsSleepTime = 0;
1671 }
1672 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1674 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 //if HDD passed down non zero values for age params, then only update,
1676 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001677 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 {
1679 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1680 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 if(pParam->scanAgeTimeNCNPS)
1682 {
1683 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1684 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 if(pParam->scanAgeTimeNCPS)
1686 {
1687 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1688 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001689 if(pParam->scanAgeTimeCNPS)
1690 {
1691 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1692 }
1693 if(pParam->scanAgeTimeCPS)
1694 {
1695 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1696 }
1697
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001698 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001699 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1700 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1701 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1702 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1703 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1705 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1707 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1708 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1709 //Assign this before calling CsrInit11dInfo
1710 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 if( csrIs11dSupported( pMac ) )
1712 {
1713 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1714 }
1715 else
1716 {
1717 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1718 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001719
1720 /* Initialize the power + channel information if 11h is enabled.
1721 If 11d is enabled this information has already been initialized */
1722 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1723 {
1724 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1725 }
1726
1727
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301728#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301729 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1730 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001731 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001732#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001733#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001735 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001736 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001737 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001738 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001739 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001740 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001741 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001742 pMac->roam.configParam.nProbes = pParam->nProbes;
1743 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001744#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001745#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1746 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001747 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001748#endif
1749#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001750 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001751 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001752#endif
1753
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301754#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07001755 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1756#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001757#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301758 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1759 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001760 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1761 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1762 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1763 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1764 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1765 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1766 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1767 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 {
1769 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001770 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 -07001771 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1772 {
1773 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1774 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001775 }
1776#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001777 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1778 pMac->scan.fValidateList = pParam->fValidateList;
1779 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1780 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001781 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001782 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001783 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1784 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1785 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1786 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1787 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1788 * single session
1789 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001790 //Remove this code once SLM_Sessionization is supported
1791 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001792 pMac->roam.configParam.doBMPSWorkaround = 0;
1793
Jeff Johnsone7245742012-09-05 17:12:55 -07001794#ifdef WLAN_FEATURE_11AC
1795 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001796 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001797 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001798 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001799#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001800 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001801
1802 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001803 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001804 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1805 pParam->isCoalesingInIBSSAllowed;
Jeff Johnson295189b2012-06-20 16:38:30 -07001806 }
1807
1808 return status;
1809}
1810
Jeff Johnson295189b2012-06-20 16:38:30 -07001811eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1812{
1813 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001814 if(pParam)
1815 {
1816 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1817 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1818 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1819 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1820 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1821 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001822 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1823 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001824 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1825 pParam->phyMode = pMac->roam.configParam.phyMode;
1826 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1827 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1828 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1829 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1830 pParam->TxRate = pMac->roam.configParam.TxRate;
1831 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1832 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1833 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1834 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1835 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001836 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1837 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1838 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1839 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001840 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1841 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1842 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001843#ifdef WLAN_AP_STA_CONCURRENCY
1844 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1845 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1846 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1847 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1848 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001849 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1850 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001851#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 //Change the unit from microsecond to second
1853 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1854 pParam->eBand = pMac->roam.configParam.eBand;
1855 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1856 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1857 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1858 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1859 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1860 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1861 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1862 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1863 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1864 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1865 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1866 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1867 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001868 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1869 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1870 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1871 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001872 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1873 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1874 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1875 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1876 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001877 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001878 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001879 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001880 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001881
1882#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301883 vos_mem_copy(&pParam->neighborRoamConfig,
1884 &pMac->roam.configParam.neighborRoamConfig,
1885 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001886#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001887#ifdef WLAN_FEATURE_11AC
1888 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001889 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001890 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001891 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001892#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001893#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301894 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1895 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001896#endif
1897#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1898 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1899 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1900 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1901 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1902 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001903 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001904 pParam->nProbes = pMac->roam.configParam.nProbes;
1905 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001906#endif
1907#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1908 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1909 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1910#endif
1911#ifdef FEATURE_WLAN_LFR
1912 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1913#endif
1914
1915#ifdef FEATURE_WLAN_CCX
1916 pParam->isCcxIniFeatureEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
1917#endif
1918#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301919 vos_mem_copy(&pParam->neighborRoamConfig,
1920 &pMac->roam.configParam.neighborRoamConfig,
1921 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001922 {
1923 int i;
1924 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1925 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1926 {
1927 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1928 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001929 }
1930#endif
1931
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001932 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001933
krunal soni5afa96c2013-09-06 22:19:02 -07001934 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001935 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07001936
krunal sonie9002db2013-11-25 14:24:17 -08001937 pParam->isCoalesingInIBSSAllowed =
1938 pMac->roam.configParam.isCoalesingInIBSSAllowed;
1939
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 csrSetChannels(pMac, pParam);
1941
1942 status = eHAL_STATUS_SUCCESS;
1943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001944 return (status);
1945}
1946
Jeff Johnson295189b2012-06-20 16:38:30 -07001947eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1948{
1949 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1950 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1951 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1952 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001953 do
1954 {
1955 if(eCSR_BAND_24 == eBand)
1956 {
1957 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1958 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1959 }
1960 if(eCSR_BAND_5G == eBand)
1961 {
1962 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1963 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1964 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1965 )
1966 {
1967 break;
1968 }
1969 }
1970 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1971 {
1972 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1973 }
1974 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1975 {
1976 newPhyMode = eCSR_DOT11_MODE_AUTO;
1977 }
1978 else
1979 {
1980 //Check for dual band and higher capability first
1981 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1982 {
1983 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1984 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1985 }
1986 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1987 {
1988 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1989 if(eCSR_BAND_24 == eBand) break;
1990 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1991 eBand = eCSR_BAND_5G;
1992 }
1993 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1994 {
1995 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1996 if(eCSR_BAND_5G == eBand) break;
1997 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1998 eBand = eCSR_BAND_24;
1999 }
2000 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2001 {
2002 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2003 if(eCSR_BAND_5G == eBand) break;
2004 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2005 eBand = eCSR_BAND_24;
2006 }
2007 else if(eCSR_DOT11_MODE_11n & phyMode)
2008 {
2009 newPhyMode = eCSR_DOT11_MODE_11n;
2010 }
2011 else if(eCSR_DOT11_MODE_abg & phyMode)
2012 {
2013 newPhyMode = eCSR_DOT11_MODE_abg;
2014 }
2015 else if(eCSR_DOT11_MODE_11a & phyMode)
2016 {
2017 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2018 {
2019 if(eCSR_BAND_ALL == eBand)
2020 {
2021 newPhyMode = eCSR_DOT11_MODE_abg;
2022 }
2023 else
2024 {
2025 //bad setting
2026 break;
2027 }
2028 }
2029 else
2030 {
2031 newPhyMode = eCSR_DOT11_MODE_11a;
2032 eBand = eCSR_BAND_5G;
2033 }
2034 }
2035 else if(eCSR_DOT11_MODE_11g & phyMode)
2036 {
2037 newPhyMode = eCSR_DOT11_MODE_11g;
2038 eBand = eCSR_BAND_24;
2039 }
2040 else if(eCSR_DOT11_MODE_11b & phyMode)
2041 {
2042 newPhyMode = eCSR_DOT11_MODE_11b;
2043 eBand = eCSR_BAND_24;
2044 }
2045 else
2046 {
2047 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002048 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 newPhyMode = eCSR_DOT11_MODE_AUTO;
2050 }
2051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 //Done validating
2053 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 //Now we need to check whether a restart is needed.
2055 if(eBand != pMac->roam.configParam.eBand)
2056 {
2057 fRestartNeeded = eANI_BOOLEAN_TRUE;
2058 break;
2059 }
2060 if(newPhyMode != pMac->roam.configParam.phyMode)
2061 {
2062 fRestartNeeded = eANI_BOOLEAN_TRUE;
2063 break;
2064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002065 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002066 if(HAL_STATUS_SUCCESS(status))
2067 {
2068 pMac->roam.configParam.eBand = eBand;
2069 pMac->roam.configParam.phyMode = newPhyMode;
2070 if(pfRestartNeeded)
2071 {
2072 *pfRestartNeeded = fRestartNeeded;
2073 }
2074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002075 return (status);
2076}
2077
Jeff Johnson295189b2012-06-20 16:38:30 -07002078void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2079{
2080 tANI_U8 Index;
2081 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 // for dual band NICs, don't need to trim the channel list....
2083 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2084 {
2085 // 2.4 GHz band operation requires the channel list to be trimmed to
2086 // the 2.4 GHz channels only...
2087 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2088 {
2089 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2090 Index++ )
2091 {
2092 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2093 {
2094 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2095 cChannels++;
2096 }
2097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002098 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2099 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2100 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2101 // only if we need to.
2102 //
2103 // The amount of memory to clear is the number of channesl that we trimmed
2104 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2105
2106 if ( pChannelList->numChannels > cChannels )
2107 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302108 vos_mem_set(&pChannelList->channelList[ cChannels ],
2109 sizeof( pChannelList->channelList[ 0 ] ) *
2110 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002111 }
2112
2113 pChannelList->numChannels = cChannels;
2114 }
2115 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2116 {
2117 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2118 {
2119 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2120 {
2121 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2122 cChannels++;
2123 }
2124 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002125 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2126 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2127 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2128 // only if we need to.
2129 //
2130 // The amount of memory to clear is the number of channesl that we trimmed
2131 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2132 if ( pChannelList->numChannels > cChannels )
2133 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302134 vos_mem_set(&pChannelList->channelList[ cChannels ],
2135 sizeof( pChannelList->channelList[ 0 ] ) *
2136 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 }
2138
2139 pChannelList->numChannels = cChannels;
2140 }
2141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002142}
Jeff Johnson295189b2012-06-20 16:38:30 -07002143#define INFRA_AP_DEFAULT_CHANNEL 6
2144eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2145{
2146 tANI_U8 index= 0;
2147 eHalStatus status = eHAL_STATUS_FAILURE;
2148 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2149 {
2150 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2151 status = eHAL_STATUS_SUCCESS;
2152 break;
2153 }
2154 }
2155 return status;
2156}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002157
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002158
Jeff Johnson295189b2012-06-20 16:38:30 -07002159eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2160{
2161 eHalStatus status = eHAL_STATUS_SUCCESS;
2162 tANI_U8 num20MHzChannelsFound = 0;
2163 VOS_STATUS vosStatus;
2164 tANI_U8 Index = 0;
2165 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002166
Jeff Johnson295189b2012-06-20 16:38:30 -07002167
2168 //TODO: this interface changed to include the 40MHz channel list
2169 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2170 // Read the scan channel list (including the power limit) from EEPROM
2171 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2172 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2173 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002175 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 status = eHAL_STATUS_FAILURE;
2177 }
2178 else
2179 {
2180 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2181 {
2182 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2183 }
2184 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2185 // Move the channel list to the global data
2186 // structure -- this will be used as the scan list
2187 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2188 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 }
2191 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2192 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2193 {
2194 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2195 }
2196 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2197 {
2198 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2199 }
2200 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2201 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 return (status);
2203}
2204
Jeff Johnson295189b2012-06-20 16:38:30 -07002205eHalStatus csrInitChannelList( tHalHandle hHal )
2206{
2207 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2208 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2210 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002211 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2212 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002213 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002214 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002215
2216 return (status);
2217}
Jeff Johnson295189b2012-06-20 16:38:30 -07002218eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2219 tCsrUpdateConfigParam *pUpdateConfigParam)
2220{
2221 eHalStatus status = eHAL_STATUS_FAILURE;
2222 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2224 status = CsrInit11dInfo(pMac, ps11dinfo);
2225 return status;
2226}
2227
Jeff Johnson295189b2012-06-20 16:38:30 -07002228static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2229{
2230 eHalStatus status = eHAL_STATUS_FAILURE;
2231 tANI_U8 index;
2232 tANI_U32 count=0;
2233 tSirMacChanInfo *pChanInfo;
2234 tSirMacChanInfo *pChanInfoStart;
2235 tANI_BOOLEAN applyConfig = TRUE;
2236
2237 if(!ps11dinfo)
2238 {
2239 return (status);
2240 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002241 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2242 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302243 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2244 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2245 ps11dinfo->Channels.channelList,
2246 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 }
2248 else
2249 {
2250 //No change
2251 return (eHAL_STATUS_SUCCESS);
2252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302254
2255 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2256 WNI_CFG_COUNTRY_CODE_LEN);
2257
2258
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 //Tush: at csropen get this initialized with default, during csr reset if this
2260 // already set with some value no need initilaize with default again
2261 if(0 == pMac->scan.countryCodeCurrent[0])
2262 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302263 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2264 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302267 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2268 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002269 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302270 vos_mem_set(pChanInfo,
2271 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2272 0);
2273
Jeff Johnson295189b2012-06-20 16:38:30 -07002274 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002275 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2276 {
2277 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2278 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2279 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2280 pChanInfo++;
2281 count++;
2282 }
2283 if(count)
2284 {
2285 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2286 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302287 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002288 }
2289 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2290 if( HAL_STATUS_SUCCESS(status) )
2291 {
2292 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2293 {
2294 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2295 {
2296 applyConfig = FALSE;
2297 }
2298 }
2299
2300 if(TRUE == applyConfig)
2301 {
2302 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002303 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002304 }
2305
2306 }
2307 return (status);
2308}
2309/* Initialize the Channel + Power List in the local cache and in the CFG */
2310eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2311{
2312 tANI_U8 index;
2313 tANI_U32 count=0;
2314 tSirMacChanInfo *pChanInfo;
2315 tSirMacChanInfo *pChanInfoStart;
2316
2317 if(!ps11dinfo || !pMac)
2318 {
2319 return eHAL_STATUS_FAILURE;
2320 }
2321
Kiet Lam64c1b492013-07-12 13:56:44 +05302322 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2323 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002324 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302325 vos_mem_set(pChanInfo,
2326 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2327 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002328 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002329
2330 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2331 {
2332 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2333 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2334 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2335 pChanInfo++;
2336 count++;
2337 }
2338 if(count)
2339 {
2340 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2341 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302342 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002343 }
2344
Jeff Johnsone7245742012-09-05 17:12:55 -07002345 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002346}
2347
2348//pCommand may be NULL
2349//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2350void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2351{
2352 tListElem *pEntry, *pNextEntry;
2353 tSmeCmd *pDupCommand;
2354 tDblLinkList localList;
2355
2356 vos_mem_zero(&localList, sizeof(tDblLinkList));
2357 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2358 {
2359 smsLog(pMac, LOGE, FL(" failed to open list"));
2360 return;
2361 }
2362 csrLLLock( &pMac->sme.smeCmdPendingList );
2363 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2364 while( pEntry )
2365 {
2366 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2367 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 // Remove the previous command if..
2369 // - the new roam command is for the same RoamReason...
2370 // - the new roam command is a NewProfileList.
2371 // - the new roam command is a Forced Dissoc
2372 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2373 if (
2374 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2375 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002376 /* This peermac check is requried for Softap/GO scenarios
2377 * For STA scenario below OR check will suffice as pCommand will
2378 * always be NULL for STA scenarios
2379 */
2380 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2382 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2383 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2384 ||
2385 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002386 ( (sessionId == pDupCommand->sessionId) &&
2387 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002388 ((eCsrForcedDisassoc == eRoamReason) ||
2389 (eCsrHddIssued == eRoamReason))
2390 )
2391 )
2392 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002393 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002394 // Remove the 'stale' roam command from the pending list...
2395 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2396 {
2397 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2398 }
2399 }
2400 pEntry = pNextEntry;
2401 }
2402 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2403
2404 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2405 {
2406 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2407 //Tell caller that the command is cancelled
2408 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2409 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2410 csrReleaseCommandRoam(pMac, pDupCommand);
2411 }
2412 csrLLClose(&localList);
2413}
Jeff Johnson295189b2012-06-20 16:38:30 -07002414eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2415 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2416{
2417 eHalStatus status = eHAL_STATUS_SUCCESS;
2418#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2419 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2420#endif
2421 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2423 {
2424 pSession = CSR_GET_SESSION( pMac, sessionId );
2425 }
2426 else
2427 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002428 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 VOS_ASSERT(0);
2430 return eHAL_STATUS_FAILURE;
2431 }
krunal soni587bf012014-02-04 12:35:11 -08002432
2433 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2434 {
2435 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2436 return eHAL_STATUS_FAILURE;
2437 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002438
krunal soni587bf012014-02-04 12:35:11 -08002439 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2440
krunal soni7f7d2c92014-02-06 15:08:43 -08002441 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002442 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002443 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002445 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2446 /*
2447 * Decrement bRefAssocStartCnt for FT reassoc failure.
2448 * Reason: For FT reassoc failures, we first call
2449 * csrRoamCallCallback before notifying a failed roam
2450 * completion through csrRoamComplete. The latter in
2451 * turn calls csrRoamProcessResults which tries to
2452 * once again call csrRoamCallCallback if bRefAssocStartCnt
2453 * is non-zero. Since this is redundant for FT reassoc
2454 * failure, decrement bRefAssocStartCnt.
2455 */
2456 pSession->bRefAssocStartCnt--;
2457 }
2458
Jeff Johnson295189b2012-06-20 16:38:30 -07002459 if(NULL != pSession->callback)
2460 {
2461 if( pRoamInfo )
2462 {
2463 pRoamInfo->sessionId = (tANI_U8)sessionId;
2464 }
2465
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302466 /* avoid holding the global lock when making the roaming callback, original change came
2467 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2468 is possible on other OS ports where the callback may need to take locks to protect
2469 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2471 that may actually depend on the lock being held */
2472 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2473 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2474 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2475 }
2476 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2477 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2478#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302479 vos_mem_set(&connectionStatus,
2480 sizeof(vos_event_wlan_status_payload_type), 0);
2481
krunal soni7f7d2c92014-02-06 15:08:43 -08002482 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 {
2484 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2485 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2486 if(NULL != pRoamInfo->pBssDesc)
2487 {
2488 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2489 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002491 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2492 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2493 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302494 vos_mem_copy(connectionStatus.ssid,
2495 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2496
Jeff Johnson295189b2012-06-20 16:38:30 -07002497 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2498 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002500 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2501 {
2502 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2503 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2504 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2505 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002506 if(eCSR_ROAM_RESULT_FORCED == u2)
2507 {
2508 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2509 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2510 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002512 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2513 {
2514 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2515 connectionStatus.reason = eCSR_REASON_DISASSOC;
2516 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002518 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2519 {
2520 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2521 connectionStatus.reason = eCSR_REASON_DEAUTH;
2522 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002524#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2525
2526 return (status);
2527}
Jeff Johnson295189b2012-06-20 16:38:30 -07002528// Returns whether handoff is currently in progress or not
2529tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2530{
2531#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2532 return csrNeighborRoamIsHandoffInProgress(pMac);
2533#else
2534 return eANI_BOOLEAN_FALSE;
2535#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002536}
Jeff Johnson295189b2012-06-20 16:38:30 -07002537eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2538 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2539{
2540 eHalStatus status = eHAL_STATUS_SUCCESS;
2541 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2542 tANI_U16 reasonCode;
2543 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002544
2545 if(!pSession)
2546 {
2547 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2548 return eHAL_STATUS_FAILURE;
2549 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002550
2551 //Restore AC weight in case we change it
2552 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2553 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002554 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 -07002555 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2556 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2557 }
2558
2559 if ( fMICFailure )
2560 {
2561 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2562 }
2563 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2564 {
2565 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002566 }
2567 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 {
2569 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2570 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002571#ifdef WLAN_FEATURE_VOWIFI_11R
2572 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2573 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2574 {
2575 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302576 vos_mem_copy(&bssId,
2577 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2578 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002579 }
2580 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002581#endif
2582 if(pSession->pConnectBssDesc)
2583 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302584 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002586
Jeff Johnson295189b2012-06-20 16:38:30 -07002587
Arif Hussain24bafea2013-11-15 15:10:03 -08002588 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2589 " subState = %d reason=%d",
2590 MAC_ADDR_ARRAY(bssId), NewSubstate, reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002591
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2593
2594 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2595
2596 if(HAL_STATUS_SUCCESS(status))
2597 {
2598 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002599#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2600 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2601 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2602 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002603 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2605 }
2606#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002607 }
2608 else
2609 {
2610 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2611 }
2612
Jeff Johnson295189b2012-06-20 16:38:30 -07002613 return (status);
2614}
Jeff Johnson295189b2012-06-20 16:38:30 -07002615
Jeff Johnson295189b2012-06-20 16:38:30 -07002616/* ---------------------------------------------------------------------------
2617 \fn csrRoamIssueDisassociateStaCmd
2618 \brief csr function that HDD calls to disassociate a associated station
2619 \param sessionId - session Id for Soft AP
2620 \param pPeerMacAddr - MAC of associated station to delete
2621 \param reason - reason code, be one of the tSirMacReasonCodes
2622 \return eHalStatus
2623 ---------------------------------------------------------------------------*/
2624eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2625 tANI_U32 sessionId,
2626 tANI_U8 *pPeerMacAddr,
2627 tANI_U32 reason)
2628{
2629 eHalStatus status = eHAL_STATUS_SUCCESS;
2630 tSmeCmd *pCommand;
2631
2632 do
2633 {
2634 pCommand = csrGetCommandBuffer( pMac );
2635 if ( !pCommand )
2636 {
2637 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2638 status = eHAL_STATUS_RESOURCES;
2639 break;
2640 }
2641 pCommand->command = eSmeCommandRoam;
2642 pCommand->sessionId = (tANI_U8)sessionId;
2643 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2644 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2645 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2646 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2647 if( !HAL_STATUS_SUCCESS( status ) )
2648 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002649 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 csrReleaseCommandRoam( pMac, pCommand );
2651 }
2652 }while(0);
2653
2654 return status;
2655}
2656
2657
Jeff Johnson295189b2012-06-20 16:38:30 -07002658/* ---------------------------------------------------------------------------
2659 \fn csrRoamIssueDeauthSta
2660 \brief csr function that HDD calls to delete a associated station
2661 \param sessionId - session Id for Soft AP
2662 \param pPeerMacAddr - MAC of associated station to delete
2663 \param reason - reason code, be one of the tSirMacReasonCodes
2664 \return eHalStatus
2665 ---------------------------------------------------------------------------*/
2666eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2667 tANI_U32 sessionId,
2668 tANI_U8 *pPeerMacAddr,
2669 tANI_U32 reason)
2670{
2671 eHalStatus status = eHAL_STATUS_SUCCESS;
2672 tSmeCmd *pCommand;
2673
2674 do
2675 {
2676 pCommand = csrGetCommandBuffer( pMac );
2677 if ( !pCommand )
2678 {
2679 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2680 status = eHAL_STATUS_RESOURCES;
2681 break;
2682 }
2683 pCommand->command = eSmeCommandRoam;
2684 pCommand->sessionId = (tANI_U8)sessionId;
2685 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2686 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2687 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2688 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2689 if( !HAL_STATUS_SUCCESS( status ) )
2690 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002691 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002692 csrReleaseCommandRoam( pMac, pCommand );
2693 }
2694 }while(0);
2695
2696 return status;
2697}
Jeff Johnson295189b2012-06-20 16:38:30 -07002698eHalStatus
2699csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2700 tANI_BOOLEAN bEnable )
2701{
2702 eHalStatus status = eHAL_STATUS_FAILURE;
2703 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2704 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 if (!pSession)
2706 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002707 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002708 return (status);
2709 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002710 if (pSession->pConnectBssDesc)
2711 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302712 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 }
2714 else
2715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002716 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002717 return (status);
2718 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002719 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2720 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002721 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2722 return (status);
2723}
Jeff Johnson295189b2012-06-20 16:38:30 -07002724eHalStatus
2725csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2726 VOS_MODULE_ID modId, void *pUsrContext,
2727 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2728{
2729 eHalStatus status = eHAL_STATUS_SUCCESS;
2730 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2731 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002732 if (!pSession)
2733 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002734 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 return (status);
2736 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 if(pSession->pConnectBssDesc)
2738 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302739 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 }
2741 else
2742 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002743 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 return (status);
2745 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002746 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2747 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002748 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2749 return (status);
2750}
Jeff Johnson295189b2012-06-20 16:38:30 -07002751eHalStatus
2752csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2753 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2754{
2755 eHalStatus status = eHAL_STATUS_SUCCESS;
2756 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2757 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2758
2759 if (!pSession)
2760 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002761 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 return (status);
2763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002764 if(pSession->pConnectBssDesc)
2765 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302766 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 }
2768 else
2769 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002770 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002771 return (status);
2772 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002773 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2774 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002775
2776 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2777
2778 return (status);
2779}
Jeff Johnson295189b2012-06-20 16:38:30 -07002780eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2781{
2782 eHalStatus status = eHAL_STATUS_SUCCESS;
2783 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2784 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002785
2786 if (!pSession)
2787 {
2788 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2789 return eHAL_STATUS_FAILURE;
2790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002791
2792 if(pSession->pConnectBssDesc)
2793 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302794 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002796 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2797 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002798 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2799
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302800 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002801 if(!HAL_STATUS_SUCCESS(status))
2802 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302803 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2804 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002805 }
2806
Jeff Johnson295189b2012-06-20 16:38:30 -07002807 return (status);
2808}
2809
Jeff Johnson295189b2012-06-20 16:38:30 -07002810eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2811{
2812 eHalStatus status = eHAL_STATUS_SUCCESS;
2813 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2814 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002815
2816 if(!pSession)
2817 {
2818 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2819 return eHAL_STATUS_FAILURE;
2820 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002821
2822 // If no BSS description was found in this connection (happens with start IBSS), then
2823 // nix the BSS description that we keep around for the connected BSS) and get out...
2824 if(NULL == pBssDesc)
2825 {
2826 csrFreeConnectBssDesc(pMac, sessionId);
2827 }
2828 else
2829 {
2830 size = pBssDesc->length + sizeof( pBssDesc->length );
2831 if(NULL != pSession->pConnectBssDesc)
2832 {
2833 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2834 {
2835 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2836 csrFreeConnectBssDesc(pMac, sessionId);
2837 }
2838 }
2839 if(NULL == pSession->pConnectBssDesc)
2840 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302841 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002842 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302843 if (NULL == pSession->pConnectBssDesc)
2844 status = eHAL_STATUS_FAILURE;
2845 else
2846 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2847 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002848 return (status);
2849}
2850
Jeff Johnson295189b2012-06-20 16:38:30 -07002851eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2852 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2853 tDot11fBeaconIEs *pIes)
2854{
2855 eHalStatus status = eHAL_STATUS_SUCCESS;
2856 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002857 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302858 if (pIes == NULL)
2859 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002860
Jeff Johnson295189b2012-06-20 16:38:30 -07002861 do
2862 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302863 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2864 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 //get qos
2866 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2867 //get SSID
2868 if(pIes->SSID.present)
2869 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302870 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2872 }
2873 else
2874 pBssConfig->SSID.length = 0;
2875 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2876 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002877 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 //Return failed if profile doesn't have an SSID either.
2879 if(pProfile->SSIDs.numOfSSIDs == 0)
2880 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002881 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002882 status = eHAL_STATUS_FAILURE;
2883 break;
2884 }
2885 }
2886 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2887 {
2888 pBssConfig->eBand = eCSR_BAND_5G;
2889 }
2890 else
2891 {
2892 pBssConfig->eBand = eCSR_BAND_24;
2893 }
2894 //phymode
2895 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2896 {
2897 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2898 }
2899 else
2900 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002901 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002902 //force it
2903 if(eCSR_BAND_24 == pBssConfig->eBand)
2904 {
2905 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2906 }
2907 else
2908 {
2909 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2910 }
2911 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 //Qos
2913 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2914 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2915 {
2916 //Joining BSS is not 11n capable and WMM is disabled on client.
2917 //Disable QoS and WMM
2918 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2919 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302920
2921 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302922 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302923 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2924 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2925 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2926 {
2927 //Joining BSS is 11n capable and WMM is disabled on AP.
2928 //Assume all HT AP's are QOS AP's and enable WMM
2929 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2930 }
2931
Jeff Johnson295189b2012-06-20 16:38:30 -07002932 //auth type
2933 switch( pProfile->negotiatedAuthType )
2934 {
2935 default:
2936 case eCSR_AUTH_TYPE_WPA:
2937 case eCSR_AUTH_TYPE_WPA_PSK:
2938 case eCSR_AUTH_TYPE_WPA_NONE:
2939 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2940 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2941 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002942 case eCSR_AUTH_TYPE_SHARED_KEY:
2943 pBssConfig->authType = eSIR_SHARED_KEY;
2944 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 case eCSR_AUTH_TYPE_AUTOSWITCH:
2946 pBssConfig->authType = eSIR_AUTO_SWITCH;
2947 break;
2948 }
2949 //short slot time
2950 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2951 {
2952 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2953 }
2954 else
2955 {
2956 pBssConfig->uShortSlotTime = 0;
2957 }
2958 if(pBssConfig->BssCap.ibss)
2959 {
2960 //We don't support 11h on IBSS
2961 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2962 }
2963 else
2964 {
2965 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2966 }
2967 //power constraint
2968 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2969 //heartbeat
2970 if ( CSR_IS_11A_BSS( pBssDesc ) )
2971 {
2972 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2973 }
2974 else
2975 {
2976 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2977 }
2978 //Join timeout
2979 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002980 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002981 if ( pBssDesc->beaconInterval )
2982 {
2983 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002984 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002985 }
2986 else
2987 {
2988 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2989 }
2990 //validate CB
2991 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2992 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002993 return (status);
2994}
2995
Jeff Johnson295189b2012-06-20 16:38:30 -07002996static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2997 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2998{
2999 eHalStatus status = eHAL_STATUS_SUCCESS;
3000 tANI_U8 operationChannel = 0;
3001 tANI_U8 qAPisEnabled = FALSE;
3002 //SSID
3003 pBssConfig->SSID.length = 0;
3004 if(pProfile->SSIDs.numOfSSIDs)
3005 {
3006 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303007 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3008 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 }
3010 else
3011 {
3012 //SSID must present
3013 return eHAL_STATUS_FAILURE;
3014 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003015 //Settomg up the capabilities
3016 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3017 {
3018 pBssConfig->BssCap.ibss = 1;
3019 }
3020 else
3021 {
3022 pBssConfig->BssCap.ess = 1;
3023 }
3024 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3025 {
3026 pBssConfig->BssCap.privacy = 1;
3027 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 pBssConfig->eBand = pMac->roam.configParam.eBand;
3029 //phymode
3030 if(pProfile->ChannelInfo.ChannelList)
3031 {
3032 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3035 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 //QOS
3037 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 if ( pBssConfig->BssCap.ess == 1 )
3039 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 /*For Softap case enable WMM*/
3041 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3042 qAPisEnabled = TRUE;
3043 }
3044 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003045 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3046 qAPisEnabled = TRUE;
3047 } else {
3048 qAPisEnabled = FALSE;
3049 }
3050 } else {
3051 qAPisEnabled = TRUE;
3052 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003053 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3054 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3055 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3056 )
3057 {
3058 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3059 } else {
3060 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3061 }
3062
3063 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003064 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 {
3066 default:
3067 case eCSR_AUTH_TYPE_WPA:
3068 case eCSR_AUTH_TYPE_WPA_PSK:
3069 case eCSR_AUTH_TYPE_WPA_NONE:
3070 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3071 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3072 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 case eCSR_AUTH_TYPE_SHARED_KEY:
3074 pBssConfig->authType = eSIR_SHARED_KEY;
3075 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 case eCSR_AUTH_TYPE_AUTOSWITCH:
3077 pBssConfig->authType = eSIR_AUTO_SWITCH;
3078 break;
3079 }
3080 //short slot time
3081 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3082 {
3083 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3084 }
3085 else
3086 {
3087 pBssConfig->uShortSlotTime = 0;
3088 }
3089 //power constraint. We don't support 11h on IBSS
3090 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3091 pBssConfig->uPowerLimit = 0;
3092 //heartbeat
3093 if ( eCSR_BAND_5G == pBssConfig->eBand )
3094 {
3095 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3096 }
3097 else
3098 {
3099 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3100 }
3101 //Join timeout
3102 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003103
Jeff Johnson295189b2012-06-20 16:38:30 -07003104 return (status);
3105}
Jeff Johnson295189b2012-06-20 16:38:30 -07003106static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3107{
3108 eHalStatus status = eHAL_STATUS_FAILURE;
3109 tDot11fBeaconIEs *pIes = NULL;
3110
3111 do
3112 {
3113 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3114 {
3115 //err msg
3116 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003117 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 break;
3119 }
3120 //check if the AP is QAP & it supports APSD
3121 if( CSR_IS_QOS_BSS(pIes) )
3122 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303123 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 }
3125 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303126
3127 if (NULL != pIes)
3128 {
3129 vos_mem_free(pIes);
3130 }
3131
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 return status;
3133}
3134
Jeff Johnson295189b2012-06-20 16:38:30 -07003135void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3136{
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3138 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3139 // See !!Note: below in this function...
3140 tANI_U32 PrivacyEnabled = 0;
3141 tANI_U32 RsnEnabled = 0;
3142 tANI_U32 WepDefaultKeyId = 0;
3143 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3144 tANI_U32 Key0Length = 0;
3145 tANI_U32 Key1Length = 0;
3146 tANI_U32 Key2Length = 0;
3147 tANI_U32 Key3Length = 0;
3148
3149 // Reserve for the biggest key
3150 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3151 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3152 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3153 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3154
3155 switch ( pProfile->negotiatedUCEncryptionType )
3156 {
3157 case eCSR_ENCRYPT_TYPE_NONE:
3158
3159 // for NO encryption, turn off Privacy and Rsn.
3160 PrivacyEnabled = 0;
3161 RsnEnabled = 0;
3162
3163 // WEP key length and Wep Default Key ID don't matter in this case....
3164
3165 // clear out the WEP keys that may be hanging around.
3166 Key0Length = 0;
3167 Key1Length = 0;
3168 Key2Length = 0;
3169 Key3Length = 0;
3170
3171 break;
3172
3173 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303174 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003175
3176 // Privacy is ON. NO RSN for Wep40 static key.
3177 PrivacyEnabled = 1;
3178 RsnEnabled = 0;
3179
3180 // Set the Wep default key ID.
3181 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003182 // Wep key size if 5 bytes (40 bits).
3183 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3184
3185 // set encryption keys in the CFG database or clear those that are not present in this profile.
3186 if ( pProfile->Keys.KeyLength[0] )
3187 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303188 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3189 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3191 }
3192 else
3193 {
3194 Key0Length = 0;
3195 }
3196
3197 if ( pProfile->Keys.KeyLength[1] )
3198 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303199 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3200 WNI_CFG_WEP_KEY_LENGTH_5);
3201 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 }
3203 else
3204 {
3205 Key1Length = 0;
3206 }
3207
3208 if ( pProfile->Keys.KeyLength[2] )
3209 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303210 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3211 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3213 }
3214 else
3215 {
3216 Key2Length = 0;
3217 }
3218
3219 if ( pProfile->Keys.KeyLength[3] )
3220 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303221 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3222 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3224 }
3225 else
3226 {
3227 Key3Length = 0;
3228 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003229 break;
3230
3231 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303232 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003233
3234 // Privacy is ON. NO RSN for Wep40 static key.
3235 PrivacyEnabled = 1;
3236 RsnEnabled = 0;
3237
3238 // Set the Wep default key ID.
3239 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3240
3241 // Wep key size if 13 bytes (104 bits).
3242 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3243
3244 // set encryption keys in the CFG database or clear those that are not present in this profile.
3245 if ( pProfile->Keys.KeyLength[0] )
3246 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303247 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3248 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3250 }
3251 else
3252 {
3253 Key0Length = 0;
3254 }
3255
3256 if ( pProfile->Keys.KeyLength[1] )
3257 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303258 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3259 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003260 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3261 }
3262 else
3263 {
3264 Key1Length = 0;
3265 }
3266
3267 if ( pProfile->Keys.KeyLength[2] )
3268 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303269 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3270 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003271 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3272 }
3273 else
3274 {
3275 Key2Length = 0;
3276 }
3277
3278 if ( pProfile->Keys.KeyLength[3] )
3279 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303280 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3281 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3283 }
3284 else
3285 {
3286 Key3Length = 0;
3287 }
3288
3289 break;
3290
Jeff Johnson295189b2012-06-20 16:38:30 -07003291 case eCSR_ENCRYPT_TYPE_TKIP:
3292 case eCSR_ENCRYPT_TYPE_AES:
3293#ifdef FEATURE_WLAN_WAPI
3294 case eCSR_ENCRYPT_TYPE_WPI:
3295#endif /* FEATURE_WLAN_WAPI */
3296 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3297 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3298 PrivacyEnabled = (0 != fPrivacy);
3299
3300 // turn on RSN enabled for WPA associations
3301 RsnEnabled = 1;
3302
3303 // WEP key length and Wep Default Key ID don't matter in this case....
3304
3305 // clear out the static WEP keys that may be hanging around.
3306 Key0Length = 0;
3307 Key1Length = 0;
3308 Key2Length = 0;
3309 Key3Length = 0;
3310
3311 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003312 default:
3313 PrivacyEnabled = 0;
3314 RsnEnabled = 0;
3315 break;
3316 }
3317
3318 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3319 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3320 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3321 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3322 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3323 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3324 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3325 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3326}
3327
Jeff Johnson295189b2012-06-20 16:38:30 -07003328static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3329{
3330 tANI_U32 len = 0;
3331 if(pSSID->length <= WNI_CFG_SSID_LEN)
3332 {
3333 len = pSSID->length;
3334 }
3335 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3336}
3337
Jeff Johnson295189b2012-06-20 16:38:30 -07003338eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3339{
3340 eHalStatus status = eHAL_STATUS_SUCCESS;
3341 tANI_U32 QoSEnabled;
3342 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 // set the CFG enable/disable variables based on the qosType being configured...
3344 switch( qosType )
3345 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3347 QoSEnabled = FALSE;
3348 WmeEnabled = TRUE;
3349 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003350 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3351 QoSEnabled = FALSE;
3352 WmeEnabled = TRUE;
3353 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003354 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3355 QoSEnabled = FALSE;
3356 WmeEnabled = TRUE;
3357 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003358 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3359 QoSEnabled = TRUE;
3360 WmeEnabled = FALSE;
3361 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003362 case eCSR_MEDIUM_ACCESS_11e_HCF:
3363 QoSEnabled = TRUE;
3364 WmeEnabled = FALSE;
3365 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003366 default:
3367 case eCSR_MEDIUM_ACCESS_DCF:
3368 QoSEnabled = FALSE;
3369 WmeEnabled = FALSE;
3370 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 }
3372 //save the WMM setting for later use
3373 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303374 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 return (status);
3376}
Jeff Johnson295189b2012-06-20 16:38:30 -07003377static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3378 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3379{
3380 eHalStatus status = eHAL_STATUS_FAILURE;
3381 int i;
3382 eCsrCfgDot11Mode cfgDot11Mode;
3383 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303384 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3385 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003387
3388 if( NULL != pIes )
3389 {
3390 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003391 // Originally, we thought that for 11a networks, the 11a rates are always
3392 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3393 // appear in the Operational Rate set. Consequently, in either case, we
3394 // would blindly put the rates we support into our Operational Rate set
3395 // (including the basic rates, which we have already verified are
3396 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 // However, it turns out that this is not always the case. Some AP's
3398 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3399 // too. Now, we're a little more careful:
3400 pDstRate = pOpRateSet->rate;
3401 if(pIes->SuppRates.present)
3402 {
3403 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3404 {
3405 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3406 {
3407 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003408 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003409 }
3410 }
3411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003412 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3413 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3414 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3415 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3416 {
3417 // If there are Extended Rates in the beacon, we will reflect those
3418 // extended rates that we support in out Extended Operational Rate
3419 // set:
3420 pDstRate = pExRateSet->rate;
3421 if(pIes->ExtSuppRates.present)
3422 {
3423 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3424 {
3425 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3426 {
3427 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3428 pExRateSet->numRates++;
3429 }
3430 }
3431 }
3432 }
3433 }//Parsing BSSDesc
3434 else
3435 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003436 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003437 }
3438 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3439 return status;
3440}
3441
3442static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3443 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3444{
3445 int i;
3446 tANI_U8 *pDstRate;
3447 eCsrCfgDot11Mode cfgDot11Mode;
3448 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3449 tANI_U32 OperationalRatesLength = 0;
3450 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3451 tANI_U32 ExtendedOperationalRatesLength = 0;
3452 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3453 tANI_U32 ProprietaryOperationalRatesLength = 0;
3454 tANI_U32 PropRatesEnable = 0;
3455 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3456 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 if( NULL != pIes )
3459 {
3460 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 // Originally, we thought that for 11a networks, the 11a rates are always
3462 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3463 // appear in the Operational Rate set. Consequently, in either case, we
3464 // would blindly put the rates we support into our Operational Rate set
3465 // (including the basic rates, which we have already verified are
3466 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 // However, it turns out that this is not always the case. Some AP's
3468 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3469 // too. Now, we're a little more careful:
3470 pDstRate = OperationalRates;
3471 if(pIes->SuppRates.present)
3472 {
3473 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3474 {
3475 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3476 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3477 {
3478 *pDstRate++ = pIes->SuppRates.rates[ i ];
3479 OperationalRatesLength++;
3480 }
3481 }
3482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3484 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3485 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3486 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3487 {
3488 // If there are Extended Rates in the beacon, we will reflect those
3489 // extended rates that we support in out Extended Operational Rate
3490 // set:
3491 pDstRate = ExtendedOperationalRates;
3492 if(pIes->ExtSuppRates.present)
3493 {
3494 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3495 {
3496 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3497 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3498 {
3499 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3500 ExtendedOperationalRatesLength++;
3501 }
3502 }
3503 }
3504 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 // Enable proprietary MAC features if peer node is Airgo node and STA
3506 // user wants to use them
3507 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3508 {
3509 PropRatesEnable = 1;
3510 }
3511 else
3512 {
3513 PropRatesEnable = 0;
3514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 // For ANI network companions, we need to populate the proprietary rate
3516 // set with any proprietary rates we found in the beacon, only if user
3517 // allows them...
3518 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3519 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3520 {
3521 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3522 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3523 {
3524 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3525 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303526 vos_mem_copy(ProprietaryOperationalRates,
3527 pIes->Airgo.PropSuppRates.rates,
3528 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 }
3530 else {
3531 // No proprietary modes...
3532 ProprietaryOperationalRatesLength = 0;
3533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 /* Get MCS Rate */
3535 pDstRate = MCSRateIdxSet;
3536 if ( pIes->HTCaps.present )
3537 {
3538 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3539 {
3540 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3541 {
3542 MCSRateLength++;
3543 *pDstRate++ = i;
3544 }
3545 }
3546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003547 // Set the operational rate set CFG variables...
3548 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3549 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3550 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3551 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3552 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3553 ProprietaryOperationalRates,
3554 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3555 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3556 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3557 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3558 }//Parsing BSSDesc
3559 else
3560 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003561 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 }
3563}
3564
Jeff Johnson295189b2012-06-20 16:38:30 -07003565static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3566 tCsrRoamProfile *pProfile )
3567{
3568 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3569 { 8,
3570 { SIR_MAC_RATE_6,
3571 SIR_MAC_RATE_9,
3572 SIR_MAC_RATE_12,
3573 SIR_MAC_RATE_18,
3574 SIR_MAC_RATE_24,
3575 SIR_MAC_RATE_36,
3576 SIR_MAC_RATE_48,
3577 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003578 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3579 { 4,
3580 { SIR_MAC_RATE_1,
3581 SIR_MAC_RATE_2,
3582 SIR_MAC_RATE_5_5,
3583 SIR_MAC_RATE_11 } } };
3584
3585
3586 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3587 { SIR_MAC_RATE_72,
3588 SIR_MAC_RATE_96,
3589 SIR_MAC_RATE_108 } };
3590 eCsrCfgDot11Mode cfgDot11Mode;
3591 eCsrBand eBand;
3592 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3593 tANI_U32 OperationalRatesLength = 0;
3594 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3595 tANI_U32 ExtendedOperationalRatesLength = 0;
3596 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3597 tANI_U32 ProprietaryOperationalRatesLength = 0;
3598 tANI_U32 PropRatesEnable = 0;
3599 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003600 if(pProfile->ChannelInfo.ChannelList)
3601 {
3602 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3603 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003605 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3606 // networks, the 11b rates appear in the Operational Rate set. In either case,
3607 // we can blindly put the rates we support into our Operational Rate set
3608 // (including the basic rates, which we have already verified are supported
3609 // earlier in the roaming decision).
3610 if ( eCSR_BAND_5G == eBand )
3611 {
3612 // 11a rates into the Operational Rate Set.
3613 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3614 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303615 vos_mem_copy(OperationalRates,
3616 DefaultSupportedRates11a.supportedRateSet.rate,
3617 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003618
3619 // Nothing in the Extended rate set.
3620 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 // populate proprietary rates if user allows them
3622 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3623 {
3624 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3625 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303626 vos_mem_copy(ProprietaryOperationalRates,
3627 DefaultSupportedPropRates.propRate,
3628 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003629 }
3630 else
3631 {
3632 // No proprietary modes
3633 ProprietaryOperationalRatesLength = 0;
3634 }
3635 }
3636 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3637 {
3638 // 11b rates into the Operational Rate Set.
3639 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3640 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303641 vos_mem_copy(OperationalRates,
3642 DefaultSupportedRates11b.supportedRateSet.rate,
3643 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 // Nothing in the Extended rate set.
3645 ExtendedOperationalRatesLength = 0;
3646 // No proprietary modes
3647 ProprietaryOperationalRatesLength = 0;
3648 }
3649 else
3650 {
3651 // 11G
3652
3653 // 11b rates into the Operational Rate Set.
3654 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3655 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303656 vos_mem_copy(OperationalRates,
3657 DefaultSupportedRates11b.supportedRateSet.rate,
3658 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003659
3660 // 11a rates go in the Extended rate set.
3661 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3662 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303663 vos_mem_copy(ExtendedOperationalRates,
3664 DefaultSupportedRates11a.supportedRateSet.rate,
3665 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003666
3667 // populate proprietary rates if user allows them
3668 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3669 {
3670 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3671 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303672 vos_mem_copy(ProprietaryOperationalRates,
3673 DefaultSupportedPropRates.propRate,
3674 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 }
3676 else
3677 {
3678 // No proprietary modes
3679 ProprietaryOperationalRatesLength = 0;
3680 }
3681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003682 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3683 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3684 {
3685 PropRatesEnable = 1;
3686 }
3687 else
3688 {
3689 PropRatesEnable = 0;
3690 }
3691
3692 // Set the operational rate set CFG variables...
3693 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3694 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3695 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3696 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3697 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3698 ProprietaryOperationalRates,
3699 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3700 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003701}
Jeff Johnson295189b2012-06-20 16:38:30 -07003702void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3703{
3704 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003705
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3707 tANI_U32 sessionId;
3708 tSmeCmd *pCommand = NULL;
3709
3710 if(NULL == pEntry)
3711 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003712 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003713 return;
3714 }
3715 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3716 sessionId = pCommand->sessionId;
3717
3718 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3719 {
3720 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3721 }
3722}
3723
Jeff Johnson295189b2012-06-20 16:38:30 -07003724//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3725tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3726{
3727 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3728 {
3729 return (WNI_CFG_PHY_MODE_11B);
3730 }
3731 else
3732 {
3733 if(eCSR_BAND_24 == band)
3734 return (WNI_CFG_PHY_MODE_11G);
3735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 return (WNI_CFG_PHY_MODE_11A);
3737}
Jeff Johnson295189b2012-06-20 16:38:30 -07003738
Jeff Johnsone7245742012-09-05 17:12:55 -07003739
3740#ifdef WLAN_FEATURE_11AC
3741ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3742{
3743 switch ( aniCBMode )
3744 {
3745 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3746 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3747 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3748 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3749 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3750 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3751 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3752 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3753 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003754 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003755 return PHY_SINGLE_CHANNEL_CENTERED;
3756 }
3757}
3758#endif
3759
Jeff Johnson295189b2012-06-20 16:38:30 -07003760//pIes may be NULL
3761eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3762 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303763 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003764{
3765 eHalStatus status = eHAL_STATUS_SUCCESS;
3766 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3767 tANI_U8 channel = 0;
3768 //Make sure we have the domain info for the BSS we try to connect to.
3769 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303770 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003771 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303772 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003773 {
3774 //Make sure the 11d info from this BSSDesc can be applied
3775 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303776 if (VOS_TRUE == resetCountry)
3777 {
3778 csrApplyCountryInformation(pMac, FALSE);
3779 }
3780 else
3781 {
3782 csrApplyCountryInformation(pMac, TRUE);
3783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 }
Kiran4a17ebe2013-01-31 10:43:43 -08003785 if ((csrIs11dSupported (pMac)) && pIes)
3786 {
3787 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003788 {
Kiran4a17ebe2013-01-31 10:43:43 -08003789 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003790 }
3791 else
3792 {
3793 //Let's also update the below to make sure we don't update CC while
3794 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303795 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003796 pBssDesc->bssId, sizeof(tSirMacAddr));
3797 }
Kiran4a17ebe2013-01-31 10:43:43 -08003798 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 //Qos
3801 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3802 //SSID
3803 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3804 //fragment threshold
3805 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3806 //RTS threshold
3807 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3808
3809 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3810
3811 //Auth type
3812 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3813 //encryption type
3814 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3815 //short slot time
3816 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003817 //11d
3818 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3819 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3820 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 /*//11h
3822 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3823 */
3824 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3825 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003826
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003827 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 {
3829 channel = pProfile->operationChannel;
3830 }
3831 else
3832 {
3833 if(pBssDesc)
3834 {
3835 channel = pBssDesc->channelId;
3836 }
3837 }
3838 if(0 != channel)
3839 {
3840 if(CSR_IS_CHANNEL_24GHZ(channel))
3841 {//for now if we are on 2.4 Ghz, CB will be always disabled
3842 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3843 }
3844 else
3845 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003846 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 }
3848 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003849#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003850 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3851 // in function csrConvertCBIniValueToPhyCBState()
3852 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3853 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003854 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003855 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003856 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003857 }
3858 else
3859 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003860 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003861 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003862 }
3863 else
3864#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003865 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3866 //Rate
3867 //Fixed Rate
3868 if(pBssDesc)
3869 {
3870 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3871 }
3872 else
3873 {
3874 csrSetCfgRateSetFromProfile(pMac, pProfile);
3875 }
3876 //Make this the last CFG to set. The callback will trigger a join_req
3877 //Join time out
3878 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3879
3880 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003881 return (status);
3882}
3883
Jeff Johnson295189b2012-06-20 16:38:30 -07003884eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3885 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3886{
3887 eHalStatus status;
3888 tBssConfigParam *pBssConfig;
3889 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003890
3891 if(!pSession)
3892 {
3893 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3894 return eHAL_STATUS_FAILURE;
3895 }
3896
Kiet Lam64c1b492013-07-12 13:56:44 +05303897 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
3898 if ( NULL == pBssConfig )
3899 status = eHAL_STATUS_FAILURE;
3900 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303902 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3904 if(HAL_STATUS_SUCCESS(status))
3905 {
3906 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003907 /* This will allow to pass cbMode during join req */
3908 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 //For IBSS, we need to prepare some more information
3910 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003912 )
3913 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003914 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 }
3916 // If we are in an IBSS, then stop the IBSS...
3917 ////Not worry about WDS connection for now
3918 if ( csrIsConnStateIbss( pMac, sessionId ) )
3919 {
3920 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3921 }
3922 else
3923 {
3924 // if we are in an Infrastructure association....
3925 if ( csrIsConnStateInfra( pMac, sessionId ) )
3926 {
3927 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3928 // across SSIDs (roaming to a new SSID)... //
3929 //Not worry about WDS connection for now
3930 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303931 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003932 {
3933 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303934 status = csrRoamIssueDisassociate( pMac, sessionId,
3935 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303937 else
3938 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003939 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3940 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303941 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003942 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303943 // Set parameters for this Bss.
3944 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3945 pBssDesc, pBssConfig,
3946 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003949 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303950 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003951 {
3952 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3953 // Nothing to stop.
3954 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003955 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303956 )
3957 {
3958 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3959 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3960 // Set parameters for this Bss.
3961 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3962 pBssDesc, pBssConfig,
3963 pIes, is11rRoamingFlag);
3964 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 }
3966 }
3967 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05303968 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 return (status);
3971}
3972
Jeff Johnson295189b2012-06-20 16:38:30 -07003973eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3974 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3975{
3976 eCsrJoinState eRoamState = eCsrContinueRoaming;
3977 eHalStatus status;
3978 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3979 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3980 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003981
3982 if(!pSession)
3983 {
3984 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3985 return (eCsrStopRoaming);
3986 }
3987
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 if( CSR_IS_WDS_STA( pProfile ) )
3989 {
3990 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3991 if( !HAL_STATUS_SUCCESS( status ) )
3992 {
3993 eRoamState = eCsrStopRoaming;
3994 }
3995 }
3996 else
3997 {
3998 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
3999 {
4000 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4001 return (eCsrStopRoaming);
4002 }
4003 if ( csrIsInfraBssDesc( pBssDesc ) )
4004 {
4005 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4006 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4007 // have changed and handle the changes (without disturbing the current association).
4008
4009 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4010 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4011 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4012 )
4013 {
4014 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4015 // with Authenticating first. To force this, stop the current association (Disassociate) and
4016 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4017 // a new Association.
4018 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4019 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004020 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4022 {
4023 eRoamState = eCsrReassocToSelfNoCapChange;
4024 }
4025 else
4026 {
4027 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304029 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4031 if(HAL_STATUS_SUCCESS(status))
4032 {
4033 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004034 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304036 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4037 pBssDesc, &bssConfig,
4038 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 if(!HAL_STATUS_SUCCESS(status))
4040 {
4041 eRoamState = eCsrStopRoaming;
4042 }
4043 }
4044 else
4045 {
4046 eRoamState = eCsrStopRoaming;
4047 }
4048 }//same profile
4049 }
4050 else
4051 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304052 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4054 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304055 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4056 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304060 }
4061 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 {
4063 // 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 +05304064 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 // work much better.
4066 //
4067 //
4068 // stop the existing network before attempting to join the new network...
4069 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4070 {
4071 eRoamState = eCsrStopRoaming;
4072 }
4073 }
4074 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304075 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 {
4077 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4078 {
4079 eRoamState = eCsrStopRoaming;
4080 }
4081 }
4082 if( pIesLocal && !pScanResult->pvIes )
4083 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304084 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 }
4086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004087 return( eRoamState );
4088}
4089
Jeff Johnson295189b2012-06-20 16:38:30 -07004090eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4091 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4092{
4093 eHalStatus status = eHAL_STATUS_SUCCESS;
4094 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304095 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004096 roamInfo.pBssDesc = pBssDesc;
4097 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4098 return (status);
4099}
Jeff Johnson295189b2012-06-20 16:38:30 -07004100//In case no matching BSS is found, use whatever default we can find
4101static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4102{
4103 //Need to get all negotiated types in place first
4104 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004105 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 {
4107 default:
4108 case eCSR_AUTH_TYPE_WPA:
4109 case eCSR_AUTH_TYPE_WPA_PSK:
4110 case eCSR_AUTH_TYPE_WPA_NONE:
4111 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4112 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4113 break;
4114
4115 case eCSR_AUTH_TYPE_SHARED_KEY:
4116 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4117 break;
4118
4119 case eCSR_AUTH_TYPE_AUTOSWITCH:
4120 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4121 break;
4122 }
4123 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4124 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4125 //In this case, the multicast encryption needs to follow the uncast ones.
4126 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4127 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4128}
4129
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004130
4131static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4132{
4133 switch(pCommand->u.roamCmd.roamReason)
4134 {
4135 case eCsrLostLink1:
4136 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4137 break;
4138 case eCsrLostLink2:
4139 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4140 break;
4141 case eCsrLostLink3:
4142 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4143 break;
4144 default:
4145 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4146 pCommand->u.roamCmd.roamReason);
4147 break;
4148 }
4149}
4150
Jeff Johnson295189b2012-06-20 16:38:30 -07004151static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4152{
4153 eHalStatus status;
4154 tCsrScanResult *pScanResult = NULL;
4155 eCsrJoinState eRoamState = eCsrStopRoaming;
4156 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4157 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4158 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4159#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4160 v_U8_t acm_mask = 0;
4161#endif
4162 tANI_U32 sessionId = pCommand->sessionId;
4163 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4164 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4165 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004166
4167 if(!pSession)
4168 {
4169 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4170 return (eCsrStopRoaming);
4171 }
4172
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 do
4174 {
4175 // Check for Cardbus eject condition, before trying to Roam to any BSS
4176 //***if( !balIsCardPresent(pAdapter) ) break;
4177
Kiet Lam64c1b492013-07-12 13:56:44 +05304178 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004179 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 if(NULL != pBSSList)
4181 {
4182 // When handling AP's capability change, continue to associate to
4183 // same BSS and make sure pRoamBssEntry is not Null.
4184 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4185 {
4186 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4187 {
4188 //Try the first BSS
4189 pCommand->u.roamCmd.pLastRoamBss = NULL;
4190 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4191 }
4192 else
4193 {
4194 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4195 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4196 {
4197 //Done with all the BSSs
4198 //In this case, will tell HDD the completion
4199 break;
4200 }
4201 else
4202 {
4203 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304204 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4206 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4207 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4208 pRoamInfo = &roamInfo;
4209 }
4210 }
4211 while(pCommand->u.roamCmd.pRoamBssEntry)
4212 {
4213 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 /*If concurrency enabled take the concurrent connected channel first. */
4215 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004216 if (vos_concurrent_sessions_running() &&
4217 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 {
4219 concurrentChannel =
4220 csrGetConcurrentOperationChannel(pMac);
4221 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004222 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004223 if ((concurrentChannel) &&
4224 (concurrentChannel ==
4225 pScanResult->Result.BssDescriptor.channelId))
4226 {
4227 //make this 0 because we do not want the
4228 //below check to pass as we don't want to
4229 //connect on other channel
4230 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4231 FL("Concurrent channel match =%d"),
4232 concurrentChannel);
4233 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004234 }
4235 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004236
4237 if (!concurrentChannel)
4238 {
4239
4240 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4241 sessionId, &pScanResult->Result.BssDescriptor,
4242 pCommand->u.roamCmd.roamId)))
4243 {
4244 //Ok to roam this
4245 break;
4246 }
4247 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004248 else
4249 {
4250 eRoamState = eCsrStopRoamingDueToConcurrency;
4251 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4253 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4254 {
4255 //Done with all the BSSs
4256 fDone = eANI_BOOLEAN_TRUE;
4257 break;
4258 }
4259 }
4260 if(fDone)
4261 {
4262 break;
4263 }
4264 }
4265 }
4266 //We have something to roam, tell HDD when it is infra.
4267 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4268 //For WDS, the indication is eCSR_ROAM_WDS_IND
4269 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4270 {
4271 if(pRoamInfo)
4272 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004273 if(pSession->bRefAssocStartCnt)
4274 {
4275 pSession->bRefAssocStartCnt--;
4276 //Complete the last association attemp because a new one is about to be tried
4277 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4278 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004279 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004280 }
4281 }
4282 /* If the roaming has stopped, not to continue the roaming command*/
4283 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4284 {
4285 //No need to complete roaming here as it already completes
4286 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4287 pCommand->u.roamCmd.roamReason);
4288 eRoamState = eCsrStopRoaming;
4289 csrSetAbortRoamingCommand(pMac, pCommand);
4290 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004291 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304292 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004293 if(pScanResult)
4294 {
4295 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4297 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004298 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 fDone = eANI_BOOLEAN_TRUE;
4300 eRoamState = eCsrStopRoaming;
4301 break;
4302 }
4303 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4304 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4305 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4306 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4307 CSR_IS_QOS_BSS(pIesLocal) &&
4308 CSR_IS_UAPSD_BSS(pIesLocal) )
4309 {
4310#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4312 pIesLocal);
4313 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4314#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004315 }
4316 else
4317 {
4318 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4319 }
4320 if( pIesLocal && !pScanResult->Result.pvIes)
4321 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304322 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004323 }
4324 }
4325 else
4326 {
4327 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4328 }
4329 roamInfo.pProfile = pProfile;
4330 pSession->bRefAssocStartCnt++;
4331 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4332 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4333 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4335 {
4336 // If this is a start IBSS profile, then we need to start the IBSS.
4337 if ( CSR_IS_START_IBSS(pProfile) )
4338 {
4339 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004340 // Attempt to start this IBSS...
4341 csrRoamAssignDefaultParam( pMac, pCommand );
4342 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4343 if(HAL_STATUS_SUCCESS(status))
4344 {
4345 if ( fSameIbss )
4346 {
4347 eRoamState = eCsrStartIbssSameIbss;
4348 }
4349 else
4350 {
4351 eRoamState = eCsrContinueRoaming;
4352 }
4353 }
4354 else
4355 {
4356 //it somehow fail need to stop
4357 eRoamState = eCsrStopRoaming;
4358 }
4359 break;
4360 }
4361 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004362 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004363 )
4364 {
4365 // Attempt to start this WDS...
4366 csrRoamAssignDefaultParam( pMac, pCommand );
4367 /* For AP WDS, we dont have any BSSDescription */
4368 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4369 if(HAL_STATUS_SUCCESS(status))
4370 {
4371 eRoamState = eCsrContinueRoaming;
4372 }
4373 else
4374 {
4375 //it somehow fail need to stop
4376 eRoamState = eCsrStopRoaming;
4377 }
4378 }
4379 else
4380 {
4381 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004382 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 eRoamState = eCsrStopRoaming;
4384 break;
4385 }
4386 }
4387 else //We have BSS
4388 {
4389 //Need to assign these value because they are used in csrIsSameProfile
4390 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4391 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4392 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4393 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4394 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4395 {
4396 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4397 {
4398 eRoamState = eCsrStartIbssSameIbss;
4399 break;
4400 }
4401 }
4402 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4403 {
4404 //trying to connect to the one already connected
4405 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4406 eRoamState = eCsrReassocToSelfNoCapChange;
4407 break;
4408 }
4409 // Attempt to Join this Bss...
4410 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4411 break;
4412 }
4413
4414 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004415 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4416 {
4417 //Need to indicate association_completion if association_start has been done
4418 if(pSession->bRefAssocStartCnt > 0)
4419 {
4420 pSession->bRefAssocStartCnt--;
4421 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004422 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004423 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4424 eCSR_ROAM_ASSOCIATION_COMPLETION,
4425 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4426 }
4427 }
4428
4429 return( eRoamState );
4430}
4431
Jeff Johnson295189b2012-06-20 16:38:30 -07004432static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4433{
4434 eHalStatus status = eHAL_STATUS_SUCCESS;
4435 eCsrJoinState RoamState;
4436 tANI_U32 sessionId = pCommand->sessionId;
4437
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 //***if( hddIsRadioStateOn( pAdapter ) )
4439 {
4440 // Attept to join a Bss...
4441 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004442
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004444 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 {
4446 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004447 // and if connected in Infrastructure mode...
4448 if ( csrIsConnStateInfra(pMac, sessionId) )
4449 {
4450 //... then we need to issue a disassociation
4451 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4452 if(!HAL_STATUS_SUCCESS(status))
4453 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004454 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004455 //roam command is completed by caller in the failed case
4456 fComplete = eANI_BOOLEAN_TRUE;
4457 }
4458 }
4459 else if( csrIsConnStateIbss(pMac, sessionId) )
4460 {
4461 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4462 if(!HAL_STATUS_SUCCESS(status))
4463 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004464 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 //roam command is completed by caller in the failed case
4466 fComplete = eANI_BOOLEAN_TRUE;
4467 }
4468 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004469 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4470 {
4471 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4472 if(!HAL_STATUS_SUCCESS(status))
4473 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004474 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 //roam command is completed by caller in the failed case
4476 fComplete = eANI_BOOLEAN_TRUE;
4477 }
4478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 else
4480 {
4481 fComplete = eANI_BOOLEAN_TRUE;
4482 }
4483 if(fComplete)
4484 {
4485 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004486 if(eCsrStopRoamingDueToConcurrency == RoamState)
4487 {
4488 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4489 }
4490 else
4491 {
4492 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 }
4495 }
4496 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4497 {
4498 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4499 }
4500 else if ( eCsrStartIbssSameIbss == RoamState )
4501 {
4502 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4503 }
4504 }//hddIsRadioStateOn
4505
4506 return status;
4507}
Jeff Johnson295189b2012-06-20 16:38:30 -07004508eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4509{
4510 tANI_U32 sessionId;
4511 tCsrRoamSession *pSession;
4512 tCsrScanResult *pScanResult = NULL;
4513 tSirBssDescription *pBssDesc = NULL;
4514 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 sessionId = pCommand->sessionId;
4516 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004517
4518 if(!pSession)
4519 {
4520 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4521 return eHAL_STATUS_FAILURE;
4522 }
4523
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4525 {
4526 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004527 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4529 return eHAL_STATUS_FAILURE;
4530 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004531 if (pCommand->u.roamCmd.pRoamBssEntry)
4532 {
4533 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4534 pBssDesc = &pScanResult->Result.BssDescriptor;
4535 }
4536 else
4537 {
4538 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004539 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4541 return eHAL_STATUS_FAILURE;
4542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4544 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4545 return status;
4546}
4547
Jeff Johnson295189b2012-06-20 16:38:30 -07004548eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4549{
4550 eHalStatus status = eHAL_STATUS_SUCCESS;
4551 tCsrRoamInfo roamInfo;
4552 tANI_U32 sessionId = pCommand->sessionId;
4553 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004554
4555 if(!pSession)
4556 {
4557 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4558 return eHAL_STATUS_FAILURE;
4559 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004560
4561 switch ( pCommand->u.roamCmd.roamReason )
4562 {
4563 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004565 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004566 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 case eCsrSmeIssuedDisassocForHandoff:
4568 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4569#if 0 // TODO : Confirm this change
4570 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4571#else
4572 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4573#endif
4574
4575 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004578 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004582 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 case eCsrHddIssuedReassocToSameAP:
4585 case eCsrSmeIssuedReassocToSameAP:
4586 {
4587 tDot11fBeaconIEs *pIes = NULL;
4588
Jeff Johnson295189b2012-06-20 16:38:30 -07004589 if( pSession->pConnectBssDesc )
4590 {
4591 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4592 if(!HAL_STATUS_SUCCESS(status) )
4593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004594 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 }
4596 else
4597 {
4598 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4599 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4600 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004601 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4602 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4603 pSession->bRefAssocStartCnt++;
4604 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4605 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4606
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004607 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004608 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4609 &pCommand->u.roamCmd.roamProfile );
4610 if(!HAL_STATUS_SUCCESS(status))
4611 {
4612 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004613 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004614 }
4615
Kiet Lam64c1b492013-07-12 13:56:44 +05304616 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 pIes = NULL;
4618 }
4619 }
4620 break;
4621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004623 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004624 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4625 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4626 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004628 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4630 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004631
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 case eCsrStopBss:
4633 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4634 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4635 break;
4636
4637 case eCsrForcedDisassocSta:
4638 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4639 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4640 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4641 pCommand->u.roamCmd.reason);
4642 break;
4643
4644 case eCsrForcedDeauthSta:
4645 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4646 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4647 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4648 pCommand->u.roamCmd.reason);
4649 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004650
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004651 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004652 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004653 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4654 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004655 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004656
4657 default:
4658 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4659
4660 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4661 {
4662 //Remember the roaming profile
4663 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304664 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4665 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004666 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304667 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4669 }
4670 }
4671
4672 //At this point, original uapsd_mask is saved in pCurRoamProfile
4673 //uapsd_mask in the pCommand may change from this point on.
4674
4675 // Attempt to roam with the new scan results (if we need to..)
4676 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004677 if(!HAL_STATUS_SUCCESS(status))
4678 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004679 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004680 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 break;
4682 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 return (status);
4684}
4685
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004686void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4687{
4688 pCommand->u.roamCmd.pLastRoamBss = NULL;
4689 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4690 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304691 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004692}
4693
Jeff Johnson295189b2012-06-20 16:38:30 -07004694void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4695{
4696 if(pCommand->u.roamCmd.fReleaseBssList)
4697 {
4698 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4699 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4700 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4701 }
4702 if(pCommand->u.roamCmd.fReleaseProfile)
4703 {
4704 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4705 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4706 }
4707 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4708 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304709 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004710}
4711
Jeff Johnson295189b2012-06-20 16:38:30 -07004712void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4713{
Kiet Lam64c1b492013-07-12 13:56:44 +05304714 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004715}
Jeff Johnson295189b2012-06-20 16:38:30 -07004716void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4717{
4718 tListElem *pEntry;
4719 tSmeCmd *pCommand;
4720 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004721 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004722 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4723 if ( pEntry )
4724 {
4725 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 // If the head of the queue is Active and it is a ROAM command, remove
4727 // and put this on the Free queue.
4728 if ( eSmeCommandRoam == pCommand->command )
4729 {
4730 //we need to process the result first before removing it from active list because state changes
4731 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4732 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4733 if( fReleaseCommand )
4734 {
4735 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4736 {
4737 csrReleaseCommandRoam( pMac, pCommand );
4738 }
4739 else
4740 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004741 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004742 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004743 }
4744 }
4745 else
4746 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004747 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004748 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004749 }
4750 }
4751 else
4752 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004753 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 }
4755 }
4756 else
4757 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004758 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 if( fReleaseCommand )
4761 {
4762 smeProcessPendingQueue( pMac );
4763 }
4764}
4765
Jeff Johnson295189b2012-06-20 16:38:30 -07004766void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4767{
4768 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004769 if(!pSession)
4770 {
4771 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4772 return;
4773 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304774 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4775 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004776 pSession->NumPmkidCandidate = 0;
4777}
Jeff Johnson295189b2012-06-20 16:38:30 -07004778#ifdef FEATURE_WLAN_WAPI
4779void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4780{
4781 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004782 if(!pSession)
4783 {
4784 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4785 return;
4786 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304787 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4788 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 pSession->NumBkidCandidate = 0;
4790}
4791#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004792extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4793
Jeff Johnson295189b2012-06-20 16:38:30 -07004794static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4795 tSirBssDescription *pSirBssDesc,
4796 tDot11fBeaconIEs *pIes)
4797{
4798 eHalStatus status = eHAL_STATUS_SUCCESS;
4799 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4800 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004801
4802 if(!pSession)
4803 {
4804 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4805 return eHAL_STATUS_FAILURE;
4806 }
4807
Jeff Johnson295189b2012-06-20 16:38:30 -07004808 if((eCSR_AUTH_TYPE_WPA == authType) ||
4809 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4810 (eCSR_AUTH_TYPE_RSN == authType) ||
4811 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4812#if defined WLAN_FEATURE_VOWIFI_11R
4813 ||
4814 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4815 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4816#endif /* FEATURE_WLAN_WAPI */
4817#ifdef FEATURE_WLAN_WAPI
4818 ||
4819 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4820 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4821#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004822#ifdef WLAN_FEATURE_11W
4823 ||
4824 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4825#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004826 )
4827 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4829 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004830 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004831 }
4832 if( pIesLocal )
4833 {
4834 tANI_U32 nIeLen;
4835 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004836 if((eCSR_AUTH_TYPE_RSN == authType) ||
4837#if defined WLAN_FEATURE_VOWIFI_11R
4838 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4839 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4840#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004841#if defined WLAN_FEATURE_11W
4842 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4843#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004844 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4845 {
4846 if(pIesLocal->RSN.present)
4847 {
4848 //Calculate the actual length
4849 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4850 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4851 + 2 //akm_suite_count
4852 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4853 + 2; //reserved
4854 if( pIesLocal->RSN.pmkid_count )
4855 {
4856 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4857 }
4858 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304859 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4860 if (NULL == pSession->pWpaRsnRspIE)
4861 status = eHAL_STATUS_FAILURE;
4862 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004863 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304864 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004865 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4866 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4867 //copy upto akm_suites
4868 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304869 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4870 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004871 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304872 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4873 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004874 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304875 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4876 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004877 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004878 if( pIesLocal->RSN.pwise_cipher_suite_count )
4879 {
4880 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304881 vos_mem_copy(pIeBuf,
4882 pIesLocal->RSN.pwise_cipher_suites,
4883 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004884 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4885 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304886 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004887 pIeBuf += 2;
4888 if( pIesLocal->RSN.akm_suite_count )
4889 {
4890 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304891 vos_mem_copy(pIeBuf,
4892 pIesLocal->RSN.akm_suites,
4893 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004894 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4895 }
4896 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05304897 vos_mem_copy(pIeBuf,
4898 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
4899 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4901 }
4902 }
4903 }
4904 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4905 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4906 {
4907 if(pIesLocal->WPA.present)
4908 {
4909 //Calculate the actual length
4910 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4911 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4912 + 2 //auth_suite_count
4913 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4914 // The WPA capabilities follows the Auth Suite (two octects)--
4915 // this field is optional, and we always "send" zero, so just
4916 // remove it. This is consistent with our assumptions in the
4917 // frames compiler; c.f. bug 15234:
4918 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304919
4920 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4921 if ( NULL == pSession->pWpaRsnRspIE )
4922 status = eHAL_STATUS_FAILURE;
4923 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004924 {
4925 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4926 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4927 pIeBuf = pSession->pWpaRsnRspIE + 2;
4928 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05304929 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004930 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304931 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
4932 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004933 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304934 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
4935 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004936 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4937 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4938 }
4939 }
4940 }
4941#ifdef FEATURE_WLAN_WAPI
4942 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4943 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4944 {
4945 if(pIesLocal->WAPI.present)
4946 {
4947 //Calculate the actual length
4948 nIeLen = 4 //version + akm_suite_count
4949 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4950 + 2 //pwise_cipher_suite_count
4951 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4952 + 6; //gp_cipher_suite + preauth + reserved
4953 if( pIesLocal->WAPI.bkid_count )
4954 {
4955 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4956 }
4957
4958 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304959 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
4960 if ( NULL == pSession->pWapiRspIE )
4961 status = eHAL_STATUS_FAILURE;
4962 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 {
4964 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4965 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4966 pIeBuf = pSession->pWapiRspIE + 2;
4967 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05304968 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 pIeBuf += 4;
4970 if( pIesLocal->WAPI.akm_suite_count )
4971 {
4972 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304973 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
4974 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304976 }
4977 vos_mem_copy(pIeBuf,
4978 &pIesLocal->WAPI.unicast_cipher_suite_count,
4979 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4982 {
4983 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304984 vos_mem_copy( pIeBuf,
4985 pIesLocal->WAPI.unicast_cipher_suites,
4986 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004987 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4988 }
lukez3c809222013-05-03 10:23:02 -07004989 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05304990 vos_mem_copy(pIeBuf,
4991 pIesLocal->WAPI.multicast_cipher_suite,
4992 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07004993 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304994 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05304995 vos_mem_copy(pIeBuf,
4996 pIesLocal->WAPI.multicast_cipher_suite + 4,
4997 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07004998 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304999 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305000 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5001
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005002 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 if( pIesLocal->WAPI.bkid_count )
5004 {
5005 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305006 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5007 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005008 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5009 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305010 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005012 }
5013 }
5014#endif /* FEATURE_WLAN_WAPI */
5015 if( !pIes )
5016 {
5017 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305018 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005019 }
5020 }
5021 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 return (status);
5023}
5024
Jeff Johnson295189b2012-06-20 16:38:30 -07005025static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5026{
5027 v_U8_t bACWeights[WLANTL_MAX_AC];
5028 v_U8_t paramBk, paramBe, paramVi, paramVo;
5029 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005030 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5031 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5032 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5033 //This doesn't address the case where the lower AC needs a real higher weight
5034 if( pIEs->WMMParams.present )
5035 {
5036 //no change to the lowest ones
5037 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5038 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5039 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5040 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5041 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5042 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5043 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5044 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5045 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5046 {
5047 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5048 fWeightChange = VOS_TRUE;
5049 }
5050 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5051 {
5052 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5053 fWeightChange = VOS_TRUE;
5054 }
5055 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5056 {
5057 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5058 fWeightChange = VOS_TRUE;
5059 }
5060 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5061 {
5062 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5063 fWeightChange = VOS_TRUE;
5064 }
5065 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5066 {
5067 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5068 fWeightChange = VOS_TRUE;
5069 }
5070 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5071 {
5072 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5073 fWeightChange = VOS_TRUE;
5074 }
5075 if(fWeightChange)
5076 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005077 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005078 bACWeights[2], bACWeights[3]);
5079 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5080 }
5081 }
5082}
Jeff Johnson295189b2012-06-20 16:38:30 -07005083#ifdef WLAN_FEATURE_VOWIFI_11R
5084//Returns whether the current association is a 11r assoc or not
5085tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5086{
5087#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5088 return csrNeighborRoamIs11rAssoc(pMac);
5089#else
5090 return eANI_BOOLEAN_FALSE;
5091#endif
5092}
5093#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005094#ifdef FEATURE_WLAN_CCX
5095//Returns whether the current association is a CCX assoc or not
5096tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
5097{
5098#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5099 return csrNeighborRoamIsCCXAssoc(pMac);
5100#else
5101 return eANI_BOOLEAN_FALSE;
5102#endif
5103}
5104#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005105#ifdef FEATURE_WLAN_LFR
5106//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305107tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005108{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305109 tCsrRoamSession *pSession = NULL;
5110
5111 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5112 {
5113 pSession = CSR_GET_SESSION( pMac, sessionId );
5114 if (NULL != pSession->pCurRoamProfile)
5115 {
5116 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5117 {
5118 return eANI_BOOLEAN_FALSE;
5119 }
5120 }
5121 }
5122
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005123#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5124 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5125 {
5126 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5127 }
5128 else
5129#endif
5130 {
5131 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005132 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005133 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005134}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005135
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005136#ifdef FEATURE_WLAN_CCX
5137/* ---------------------------------------------------------------------------
5138
5139 \fn csrNeighborRoamIsCCXAssoc
5140
5141 \brief This function returns whether the current association is a CCX assoc or not
5142
5143 \param pMac - The handle returned by macOpen.
5144
5145 \return eANI_BOOLEAN_TRUE if current assoc is CCX, eANI_BOOLEAN_FALSE otherwise
5146
5147---------------------------------------------------------------------------*/
5148tANI_BOOLEAN csrNeighborRoamIsCCXAssoc(tpAniSirGlobal pMac)
5149{
5150 return pMac->roam.neighborRoamInfo.isCCXAssoc;
5151}
5152#endif /* FEATURE_WLAN_CCX */
5153
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005154#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5155//Returns whether "FW based BG scan" is currently enabled...or not
5156tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5157{
5158 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5159}
5160#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005161#endif
5162
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005163#if defined(FEATURE_WLAN_CCX)
5164tANI_BOOLEAN csrRoamIsCcxIniFeatureEnabled(tpAniSirGlobal pMac)
5165{
5166 return pMac->roam.configParam.isCcxIniFeatureEnabled;
5167}
5168#endif /*FEATURE_WLAN_CCX*/
5169
Jeff Johnson295189b2012-06-20 16:38:30 -07005170//Return true means the command can be release, else not
5171static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5172 eCsrRoamCompleteResult Result, void *Context )
5173{
5174 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5175 tSirBssDescription *pSirBssDesc = NULL;
5176 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5177 tCsrScanResult *pScanResult = NULL;
5178 tCsrRoamInfo roamInfo;
5179 sme_QosAssocInfo assocInfo;
5180 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5181 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5182 tDot11fBeaconIEs *pIes = NULL;
5183 tANI_U32 sessionId = pCommand->sessionId;
5184 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5185 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5186 eRoamCmdStatus roamStatus;
5187 eCsrRoamResult roamResult;
5188 eHalStatus status;
5189 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005191
Jeff Johnson32d95a32012-09-10 13:15:23 -07005192 if(!pSession)
5193 {
5194 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5195 return eANI_BOOLEAN_FALSE;
5196 }
5197
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005198 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005199 switch( Result )
5200 {
5201 case eCsrJoinSuccess:
5202 // reset the IDLE timer
5203 // !!
5204 // !! fall through to the next CASE statement here is intentional !!
5205 // !!
5206 case eCsrReassocSuccess:
5207 if(eCsrReassocSuccess == Result)
5208 {
5209 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5210 }
5211 else
5212 {
5213 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5214 }
5215 // Success Join Response from LIM. Tell NDIS we are connected and save the
5216 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005217 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305218 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005219 //always free the memory here
5220 if(pSession->pWpaRsnRspIE)
5221 {
5222 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305223 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005224 pSession->pWpaRsnRspIE = NULL;
5225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005226#ifdef FEATURE_WLAN_WAPI
5227 if(pSession->pWapiRspIE)
5228 {
5229 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305230 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005231 pSession->pWapiRspIE = NULL;
5232 }
5233#endif /* FEATURE_WLAN_WAPI */
5234#ifdef FEATURE_WLAN_BTAMP_UT_RF
5235 //Reset counter so no join retry is needed.
5236 pSession->maxRetryCount = 0;
5237 csrRoamStopJoinRetryTimer(pMac, sessionId);
5238#endif
5239 /* This creates problem since we have not saved the connected profile.
5240 So moving this after saving the profile
5241 */
5242 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
5243 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5244 {
5245 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5246 }
5247 else
5248 {
5249 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005251 //Use the last connected bssdesc for reassoc-ing to the same AP.
5252 //NOTE: What to do when reassoc to a different AP???
5253 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5254 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5255 {
5256 pSirBssDesc = pSession->pConnectBssDesc;
5257 if(pSirBssDesc)
5258 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305259 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5260 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005261 }
5262 }
5263 else
5264 {
5265
5266 if(pCommand->u.roamCmd.pRoamBssEntry)
5267 {
5268 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5269 if(pScanResult != NULL)
5270 {
5271 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5272 //this can be NULL
5273 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305274 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5275 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005276 }
5277 }
5278 }
5279 if( pSirBssDesc )
5280 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005281 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005282 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5283 //Save WPA/RSN IE
5284 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5285#ifdef FEATURE_WLAN_CCX
5286 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5287#endif
5288
5289 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5290 // substate change.
5291 // Moving even save profile above so that below mentioned conditon is also met.
5292 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5293 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005294 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5295 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5296 // will be dropped for the security context may not be set properly.
5297 //
5298 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5299 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5300 //
5301 // this reordering was done on titan_prod_usb branch and is being replicated here.
5302 //
5303
5304 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5305 !pProfile->bWPSAssociation)
5306 {
5307 // Issue the set Context request to LIM to establish the Unicast STA context
5308 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5309 pProfile->negotiatedUCEncryptionType,
5310 pSirBssDesc, &(pSirBssDesc->bssId),
5311 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5312 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005313 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005314 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5315 }
5316 // Issue the set Context request to LIM to establish the Broadcast STA context
5317 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5318 pSirBssDesc, &BroadcastMac,
5319 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5320 }
5321 else
5322 {
5323 //Need to wait for supplicant authtication
5324 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 //Set the subestate to WaitForKey in case authentiation is needed
5326 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5327
Jeff Johnson295189b2012-06-20 16:38:30 -07005328 if(pProfile->bWPSAssociation)
5329 {
5330 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5331 }
5332 else
5333 {
5334 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5335 }
5336
5337 //Save sessionId in case of timeout
5338 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5339 //This time should be long enough for the rest of the process plus setting key
5340 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5341 {
5342 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005343 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005344 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5345 }
5346 }
5347
5348 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5349 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005350 if(Context)
5351 {
5352 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5353 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005354 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5355 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5356#ifdef WLAN_FEATURE_VOWIFI_11R
5357 len += pJoinRsp->parsedRicRspLen;
5358#endif /* WLAN_FEATURE_VOWIFI_11R */
5359#ifdef FEATURE_WLAN_CCX
5360 len += pJoinRsp->tspecIeLen;
5361#endif
5362 if(len)
5363 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305364 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5365 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305367 vos_mem_copy(pSession->connectedInfo.pbFrames,
5368 pJoinRsp->frames, len);
5369 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5370 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5371 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005372#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305373 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005374#endif /* WLAN_FEATURE_VOWIFI_11R */
5375#ifdef FEATURE_WLAN_CCX
Kiet Lam64c1b492013-07-12 13:56:44 +05305376 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005377#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305378 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5379 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5380 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5381 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005382 }
5383 }
5384 if(pCommand->u.roamCmd.fReassoc)
5385 {
5386 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5387 }
5388 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5389 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5390 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5391 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5392 }
5393 else
5394 {
5395 if(pCommand->u.roamCmd.fReassoc)
5396 {
5397 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5398 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5399 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5400 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5401 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5402 }
5403 }
5404#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5405 // Indicate SME-QOS with reassoc success event, only after
5406 // copying the frames
5407 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5408#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005409 roamInfo.pBssDesc = pSirBssDesc;
5410 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5411 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5412#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5413 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5414#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5415 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005416 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5417 //It may be better to let QoS do this????
5418 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5419 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005420 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5422 pmcStartUapsd( pMac, NULL, NULL );
5423 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305424 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5426 if( pSession->bRefAssocStartCnt > 0 )
5427 {
5428 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005429 //Remove this code once SLM_Sessionization is supported
5430 //BMPS_WORKAROUND_NOT_NEEDED
5431 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005432 {
5433 pMac->roam.configParam.doBMPSWorkaround = 1;
5434 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005435 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5436 }
5437
5438 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 // reset the PMKID candidate list
5440 csrResetPMKIDCandidateList( pMac, sessionId );
5441 //Update TL's AC weight base on the current EDCA parameters
5442 //These parameters may change in the course of the connection, that sictuation
5443 //is not taken care here. This change is mainly to address a WIFI WMM test where
5444 //BE has a equal or higher TX priority than VI.
5445 //We only do this for infra link
5446 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5447 {
5448 csrCheckAndUpdateACWeight(pMac, pIes);
5449 }
5450#ifdef FEATURE_WLAN_WAPI
5451 // reset the BKID candidate list
5452 csrResetBKIDCandidateList( pMac, sessionId );
5453#endif /* FEATURE_WLAN_WAPI */
5454 }
5455 else
5456 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005457 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005458 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005459 csrScanCancelIdleScan(pMac);
5460 //Not to signal link up because keys are yet to be set.
5461 //The linkup function will overwrite the sub-state that we need to keep at this point.
5462 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5463 {
5464 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5465 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005466 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5467 //enough to let security and DHCP handshake succeed before entry into BMPS
5468 if (pmcShouldBmpsTimerRun(pMac))
5469 {
5470 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5471 != eHAL_STATUS_SUCCESS)
5472 {
5473 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5474 }
5475 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5476 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 break;
5478
Jeff Johnson295189b2012-06-20 16:38:30 -07005479 case eCsrStartBssSuccess:
5480 // on the StartBss Response, LIM is returning the Bss Description that we
5481 // are beaconing. Add this Bss Description to our scan results and
5482 // chain the Profile to this Bss Description. On a Start BSS, there was no
5483 // detected Bss description (no partner) so we issued the Start Bss to
5484 // start the Ibss without any Bss description. Lim was kind enough to return
5485 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005486 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305489 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005490 if( CSR_IS_IBSS( pProfile ) )
5491 {
5492 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005494 else if (CSR_IS_INFRA_AP(pProfile))
5495 {
5496 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5497 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005498 else
5499 {
5500 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5501 }
5502 if( !CSR_IS_WDS_STA( pProfile ) )
5503 {
5504 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005505 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005506 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5507 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305508 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 roamInfo.pBssDesc = pSirBssDesc;
5510 //We need to associate_complete it first, becasue Associate_start already indicated.
5511 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5512 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5513 break;
5514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005515 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005516 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005517 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 }
5519 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5520 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5521 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5522 if(pSirBssDesc)
5523 {
5524 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305525 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5526 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005527 }
5528 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305529 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005530#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5531 {
5532 vos_log_ibss_pkt_type *pIbssLog;
5533 tANI_U32 bi;
5534
5535 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5536 if(pIbssLog)
5537 {
5538 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5539 {
5540 //We start the IBSS (didn't find any matched IBSS out there)
5541 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5542 }
5543 else
5544 {
5545 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5546 }
5547 if(pSirBssDesc)
5548 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305549 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5551 }
5552 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5553 {
5554 //***U8 is not enough for beacon interval
5555 pIbssLog->beaconInterval = (v_U8_t)bi;
5556 }
5557 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5558 }
5559 }
5560#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5561 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5562 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5564 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005565 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5566 csrRoamIssueSetContextReq( pMac, sessionId,
5567 pProfile->negotiatedMCEncryptionType,
5568 pSirBssDesc, &BroadcastMac,
5569 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5570 }
5571 }
5572 else
5573 {
5574 //Keep the state to eCSR_ROAMING_STATE_JOINING
5575 //Need to send join_req.
5576 if(pCommand->u.roamCmd.pRoamBssEntry)
5577 {
5578 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5579 {
5580 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5581 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5582 // Set the roaming substate to 'join attempt'...
5583 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005584 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005585 }
5586 }
5587 else
5588 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005589 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 VOS_ASSERT( 0 );
5591 }
5592 }
5593 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5594 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5595 //trigger the connection start indication in Vista
5596 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5597 {
5598 roamStatus = eCSR_ROAM_IBSS_IND;
5599 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5600 if( CSR_IS_WDS( pProfile ) )
5601 {
5602 roamStatus = eCSR_ROAM_WDS_IND;
5603 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005605 if( CSR_IS_INFRA_AP( pProfile ) )
5606 {
5607 roamStatus = eCSR_ROAM_INFRA_IND;
5608 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5609 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005610
5611 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5612 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5613 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305614 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005615 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5616 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005617 //We start the IBSS (didn't find any matched IBSS out there)
5618 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005619 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305620 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5621 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005622 //Remove this code once SLM_Sessionization is supported
5623 //BMPS_WORKAROUND_NOT_NEEDED
5624 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005625 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005626 {
5627 pMac->roam.configParam.doBMPSWorkaround = 1;
5628 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005629
Jeff Johnson295189b2012-06-20 16:38:30 -07005630 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5631 }
5632
5633 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005634
5635 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005636 {
5637 //need to send stop BSS because we fail to send join_req
5638 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5639 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5640 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5641 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005642 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005643 case eCsrStartBssFailure:
5644#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5645 {
5646 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005647 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5648 if(pIbssLog)
5649 {
5650 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5651 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5652 }
5653 }
5654#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 roamStatus = eCSR_ROAM_IBSS_IND;
5656 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5657 if( CSR_IS_WDS( pProfile ) )
5658 {
5659 roamStatus = eCSR_ROAM_WDS_IND;
5660 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 if( CSR_IS_INFRA_AP( pProfile ) )
5663 {
5664 roamStatus = eCSR_ROAM_INFRA_IND;
5665 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 if(Context)
5668 {
5669 pSirBssDesc = (tSirBssDescription *)Context;
5670 }
5671 else
5672 {
5673 pSirBssDesc = NULL;
5674 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305675 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005676 roamInfo.pBssDesc = pSirBssDesc;
5677 //We need to associate_complete it first, becasue Associate_start already indicated.
5678 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5679 csrSetDefaultDot11Mode( pMac );
5680 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005681 case eCsrSilentlyStopRoaming:
5682 // We are here because we try to start the same IBSS
5683 //No message to PE
5684 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005685 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005686 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5687 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305688 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5690 if( roamInfo.pBssDesc )
5691 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305692 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5693 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 }
5695 //Since there is no change in the current state, simply pass back no result otherwise
5696 //HDD may be mistakenly mark to disconnected state.
5697 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5698 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005699 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005700 case eCsrSilentlyStopRoamingSaveState:
5701 //We are here because we try to connect to the same AP
5702 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005703 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305704 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005705
5706 //to aviod resetting the substate to NONE
5707 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5708 //No need to change substate to wai_for_key because there is no state change
5709 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5710 if( roamInfo.pBssDesc )
5711 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305712 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5713 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005715 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5716 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5717 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5718 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5719 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5720 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5721 roamInfo.staId = pSession->connectedInfo.staId;
5722 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 pSession->bRefAssocStartCnt--;
5725 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5726 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5727 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5728 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005729 case eCsrReassocFailure:
5730#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5731 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5732#endif
5733 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005734 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005735 csrFreeConnectBssDesc(pMac, sessionId);
5736 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5737 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305738 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5740 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5741 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5742 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5743 eCSR_ROAM_WDS_IND,
5744 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5745 //Need to issue stop_bss
5746 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005747 case eCsrJoinFailure:
5748 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005749 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005750 default:
5751 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005752 smsLog(pMac, LOGW, FL("receives no association indication"));
5753 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005754 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005755 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5756 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5757 {
5758 //do not free for the other profiles as we need to send down stop BSS later
5759 csrFreeConnectBssDesc(pMac, sessionId);
5760 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5761 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5762 csrSetDefaultDot11Mode( pMac );
5763 }
5764
5765 switch( pCommand->u.roamCmd.roamReason )
5766 {
5767 // If this transition is because of an 802.11 OID, then we transition
5768 // back to INIT state so we sit waiting for more OIDs to be issued and
5769 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005770 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 case eCsrSmeIssuedAssocToSimilarAP:
5772 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005773 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005774 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305775 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005776 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5777 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5778 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305779 vos_mem_copy(&roamInfo.bssid,
5780 &pSession->joinFailStatusCode.bssId,
5781 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005782
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 /* Defeaturize this later if needed */
5784#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5785 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5786 if (csrRoamIsHandoffInProgress(pMac))
5787 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 /* Should indicate neighbor roam algorithm about the connect failure here */
5789 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005791#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005792 if(pSession->bRefAssocStartCnt > 0)
5793 {
5794 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005795 if(eCsrJoinFailureDueToConcurrency == Result)
5796 {
5797 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5798 eCSR_ROAM_ASSOCIATION_COMPLETION,
5799 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5800 }
5801 else
5802 {
5803 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005804 eCSR_ROAM_ASSOCIATION_COMPLETION,
5805 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005808 else
5809 {
5810 /* bRefAssocStartCnt is not incremented when
5811 * eRoamState == eCsrStopRoamingDueToConcurrency
5812 * in csrRoamJoinNextBss API. so handle this in
5813 * else case by sending assoc failure
5814 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005815 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005816 pCommand->u.scanCmd.roamId,
5817 eCSR_ROAM_ASSOCIATION_FAILURE,
5818 eCSR_ROAM_RESULT_FAILURE);
5819 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005820 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005821#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05305822 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5824#endif
5825 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5826 csrScanStartIdleScan(pMac);
5827#ifdef FEATURE_WLAN_BTAMP_UT_RF
5828 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5829 //BT activity and not able to recevie WLAN traffic. Retry the join
5830 if( CSR_IS_WDS_STA(pProfile) )
5831 {
5832 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5833 }
5834#endif
5835 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 case eCsrHddIssuedReassocToSameAP:
5837 case eCsrSmeIssuedReassocToSameAP:
5838 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5839
5840 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5841#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5842 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5843#endif
5844 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5845 csrScanStartIdleScan(pMac);
5846 break;
5847 case eCsrForcedDisassoc:
5848 case eCsrForcedDeauth:
5849 case eCsrSmeIssuedIbssJoinFailure:
5850 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5851
5852 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5853 {
5854 // Notify HDD that IBSS join failed
5855 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5856 }
5857 else
5858 {
5859 csrRoamCallCallback(pMac, sessionId, NULL,
5860 pCommand->u.roamCmd.roamId,
5861 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5862 }
5863#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5864 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5865#endif
5866 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08005867 /*
5868 *DelSta not done FW still in conneced state so dont
5869 *issue IMPS req
5870 */
5871 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
5872 {
5873 smsLog(pMac, LOGW, FL("FW still in connected state "));
5874 break;
5875 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 csrScanStartIdleScan(pMac);
5877 break;
5878 case eCsrForcedIbssLeave:
5879 csrRoamCallCallback(pMac, sessionId, NULL,
5880 pCommand->u.roamCmd.roamId,
5881 eCSR_ROAM_IBSS_LEAVE,
5882 eCSR_ROAM_RESULT_IBSS_STOP);
5883 break;
5884 case eCsrForcedDisassocMICFailure:
5885 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5886
5887 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5888#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5889 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5890#endif
5891 csrScanStartIdleScan(pMac);
5892 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 case eCsrStopBss:
5894 csrRoamCallCallback(pMac, sessionId, NULL,
5895 pCommand->u.roamCmd.roamId,
5896 eCSR_ROAM_INFRA_IND,
5897 eCSR_ROAM_RESULT_INFRA_STOPPED);
5898 break;
5899 case eCsrForcedDisassocSta:
5900 case eCsrForcedDeauthSta:
5901 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5902 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5903 {
5904 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005905
5906 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5907 {
5908 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05305909 vos_mem_copy(roamInfo.peerMac,
5910 pCommand->u.roamCmd.peerMac,
5911 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5913 roamInfo.statusCode = eSIR_SME_SUCCESS;
5914 status = csrRoamCallCallback(pMac, sessionId,
5915 &roamInfo, pCommand->u.roamCmd.roamId,
5916 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5917 }
5918 }
5919 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 case eCsrLostLink1:
5921 // if lost link roam1 failed, then issue lost link Scan2 ...
5922 csrScanRequestLostLink2(pMac, sessionId);
5923 break;
5924 case eCsrLostLink2:
5925 // if lost link roam2 failed, then issue lost link scan3 ...
5926 csrScanRequestLostLink3(pMac, sessionId);
5927 break;
5928 case eCsrLostLink3:
5929 default:
5930 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5931
5932 //We are done with one round of lostlink roaming here
5933 csrScanHandleFailedLostlink3(pMac, sessionId);
5934 break;
5935 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005936 break;
5937 }
5938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 return ( fReleaseCommand );
5940}
5941
Jeff Johnson295189b2012-06-20 16:38:30 -07005942eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5943{
5944 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 return (status);
5946}
5947
Jeff Johnson295189b2012-06-20 16:38:30 -07005948eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5949{
5950 eHalStatus status = eHAL_STATUS_SUCCESS;
5951 tANI_U32 size = 0;
5952
5953 do
5954 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305955 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005956 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5957 {
5958 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305959 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
5960 if ( NULL == pDstProfile->BSSIDs.bssid )
5961 status = eHAL_STATUS_FAILURE;
5962 else
5963 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005964 if(!HAL_STATUS_SUCCESS(status))
5965 {
5966 break;
5967 }
5968 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305969 vos_mem_copy(pDstProfile->BSSIDs.bssid,
5970 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 }
5972 if(pSrcProfile->SSIDs.numOfSSIDs)
5973 {
5974 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305975 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
5976 if ( NULL == pDstProfile->SSIDs.SSIDList )
5977 status = eHAL_STATUS_FAILURE;
5978 else
5979 status = eHAL_STATUS_SUCCESS;
5980 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 {
5982 break;
5983 }
5984 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305985 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
5986 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005987 }
5988 if(pSrcProfile->nWPAReqIELength)
5989 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305990 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
5991 if ( NULL == pDstProfile->pWPAReqIE )
5992 status = eHAL_STATUS_FAILURE;
5993 else
5994 status = eHAL_STATUS_SUCCESS;
5995
5996 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005997 {
5998 break;
5999 }
6000 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306001 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6002 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006003 }
6004 if(pSrcProfile->nRSNReqIELength)
6005 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306006 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6007 if ( NULL == pDstProfile->pRSNReqIE )
6008 status = eHAL_STATUS_FAILURE;
6009 else
6010 status = eHAL_STATUS_SUCCESS;
6011
6012 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006013 {
6014 break;
6015 }
6016 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306017 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6018 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 }
6020#ifdef FEATURE_WLAN_WAPI
6021 if(pSrcProfile->nWAPIReqIELength)
6022 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306023 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6024 if ( NULL == pDstProfile->pWAPIReqIE )
6025 status = eHAL_STATUS_FAILURE;
6026 else
6027 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 if(!HAL_STATUS_SUCCESS(status))
6029 {
6030 break;
6031 }
6032 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306033 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6034 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006035 }
6036#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 if(pSrcProfile->nAddIEScanLength)
6038 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306039 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6040 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006041 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306042 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306043 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306044 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6045 }
6046 else
6047 {
6048 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6049 FL(" AddIEScanLength is not valid %u"),
6050 pSrcProfile->nAddIEScanLength);
6051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006053 if(pSrcProfile->nAddIEAssocLength)
6054 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306055 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6056 if ( NULL == pDstProfile->pAddIEAssoc )
6057 status = eHAL_STATUS_FAILURE;
6058 else
6059 status = eHAL_STATUS_SUCCESS;
6060
Jeff Johnson295189b2012-06-20 16:38:30 -07006061 if(!HAL_STATUS_SUCCESS(status))
6062 {
6063 break;
6064 }
6065 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306066 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6067 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 if(pSrcProfile->ChannelInfo.ChannelList)
6070 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306071 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6072 pSrcProfile->ChannelInfo.numOfChannels);
6073 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6074 status = eHAL_STATUS_FAILURE;
6075 else
6076 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 if(!HAL_STATUS_SUCCESS(status))
6078 {
6079 break;
6080 }
6081 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306082 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6083 pSrcProfile->ChannelInfo.ChannelList,
6084 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006085 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 pDstProfile->AuthType = pSrcProfile->AuthType;
6087 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6088 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6089 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6090 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6091 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006092#ifdef WLAN_FEATURE_11W
6093 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6094 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6095 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6096#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006097 pDstProfile->BSSType = pSrcProfile->BSSType;
6098 pDstProfile->phyMode = pSrcProfile->phyMode;
6099 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6100
6101#ifdef FEATURE_WLAN_WAPI
6102 if(csrIsProfileWapi(pSrcProfile))
6103 {
6104 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6105 {
6106 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6107 }
6108 }
6109#endif /* FEATURE_WLAN_WAPI */
6110 pDstProfile->CBMode = pSrcProfile->CBMode;
6111 /*Save the WPS info*/
6112 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
6113 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006114 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 pDstProfile->privacy = pSrcProfile->privacy;
6116 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6117 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6118 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6119 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6120 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6121 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6122 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6123 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6124 pDstProfile->wps_state = pSrcProfile->wps_state;
6125 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306126 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6127 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006128#ifdef WLAN_FEATURE_VOWIFI_11R
6129 if (pSrcProfile->MDID.mdiePresent)
6130 {
6131 pDstProfile->MDID.mdiePresent = 1;
6132 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6133 }
6134#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006135 }while(0);
6136
6137 if(!HAL_STATUS_SUCCESS(status))
6138 {
6139 csrReleaseProfile(pMac, pDstProfile);
6140 pDstProfile = NULL;
6141 }
6142
6143 return (status);
6144}
Jeff Johnson295189b2012-06-20 16:38:30 -07006145eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6146{
6147 eHalStatus status = eHAL_STATUS_SUCCESS;
6148 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6149 do
6150 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306151 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 if(pSrcProfile->bssid)
6153 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306154 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6155 if ( NULL == pDstProfile->BSSIDs.bssid )
6156 status = eHAL_STATUS_FAILURE;
6157 else
6158 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006159 if(!HAL_STATUS_SUCCESS(status))
6160 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306161 smsLog( pMac, LOGE,
6162 FL("failed to allocate memory for BSSID"
6163 "%02x:%02x:%02x:%02x:%02x:%02x"),
6164 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6165 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006166 break;
6167 }
6168 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306169 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6170 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006171 }
6172 if(pSrcProfile->SSID.ssId)
6173 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306174 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6175 if ( NULL == pDstProfile->SSIDs.SSIDList )
6176 status = eHAL_STATUS_FAILURE;
6177 else
6178 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 if(!HAL_STATUS_SUCCESS(status))
6180 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306181 smsLog( pMac, LOGE,
6182 FL("failed to allocate memory for SSIDList"
6183 "%02x:%02x:%02x:%02x:%02x:%02x"),
6184 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6185 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006186 break;
6187 }
6188 pDstProfile->SSIDs.numOfSSIDs = 1;
6189 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6190 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306191 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6192 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006193 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006194 if(pSrcProfile->nAddIEAssocLength)
6195 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306196 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6197 if ( NULL == pDstProfile->pAddIEAssoc)
6198 status = eHAL_STATUS_FAILURE;
6199 else
6200 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006201 if(!HAL_STATUS_SUCCESS(status))
6202 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006203 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006204 break;
6205 }
6206 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306207 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6208 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006209 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306210 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6211 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6212 status = eHAL_STATUS_FAILURE;
6213 else
6214 status = eHAL_STATUS_SUCCESS;
6215
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 if(!HAL_STATUS_SUCCESS(status))
6217 {
6218 break;
6219 }
6220 pDstProfile->ChannelInfo.numOfChannels = 1;
6221 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006222 pDstProfile->AuthType.numEntries = 1;
6223 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6224 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6225 pDstProfile->EncryptionType.numEntries = 1;
6226 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6227 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6228 pDstProfile->mcEncryptionType.numEntries = 1;
6229 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6230 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6231 pDstProfile->BSSType = pSrcProfile->BSSType;
6232 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306233 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6234 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006235#ifdef WLAN_FEATURE_VOWIFI_11R
6236 if (pSrcProfile->MDID.mdiePresent)
6237 {
6238 pDstProfile->MDID.mdiePresent = 1;
6239 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6240 }
6241#endif
6242
6243 }while(0);
6244
6245 if(!HAL_STATUS_SUCCESS(status))
6246 {
6247 csrReleaseProfile(pMac, pDstProfile);
6248 pDstProfile = NULL;
6249 }
6250
6251 return (status);
6252}
6253
Jeff Johnson295189b2012-06-20 16:38:30 -07006254eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6255 tScanResultHandle hBSSList,
6256 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6257 tANI_BOOLEAN fClearScan)
6258{
6259 eHalStatus status = eHAL_STATUS_SUCCESS;
6260 tSmeCmd *pCommand;
6261
6262 pCommand = csrGetCommandBuffer(pMac);
6263 if(NULL == pCommand)
6264 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006265 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 status = eHAL_STATUS_RESOURCES;
6267 }
6268 else
6269 {
6270 if( fClearScan )
6271 {
6272 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306273 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006274 }
6275 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6276 if(NULL == pProfile)
6277 {
6278 //We can roam now
6279 //Since pProfile is NULL, we need to build our own profile, set everything to default
6280 //We can only support open and no encryption
6281 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6282 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6283 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6284 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6285 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6286 }
6287 else
6288 {
6289 //make a copy of the profile
6290 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6291 if(HAL_STATUS_SUCCESS(status))
6292 {
6293 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6294 }
6295 }
6296 pCommand->command = eSmeCommandRoam;
6297 pCommand->sessionId = (tANI_U8)sessionId;
6298 pCommand->u.roamCmd.hBSSList = hBSSList;
6299 pCommand->u.roamCmd.roamId = roamId;
6300 pCommand->u.roamCmd.roamReason = reason;
6301 //We need to free the BssList when the command is done
6302 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6303 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006304 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6305 FL("CSR PERSONA=%d"),
6306 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006307 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6308 if( !HAL_STATUS_SUCCESS( status ) )
6309 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006310 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006311 csrReleaseCommandRoam( pMac, pCommand );
6312 }
6313 }
6314
6315 return (status);
6316}
Jeff Johnson295189b2012-06-20 16:38:30 -07006317eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6318 tCsrRoamModifyProfileFields *pMmodProfileFields,
6319 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6320{
6321 eHalStatus status = eHAL_STATUS_SUCCESS;
6322 tSmeCmd *pCommand;
6323
6324 pCommand = csrGetCommandBuffer(pMac);
6325 if(NULL == pCommand)
6326 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006327 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006328 status = eHAL_STATUS_RESOURCES;
6329 }
6330 else
6331 {
6332 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306333 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006334 if(pProfile)
6335 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006336 //This is likely trying to reassoc to different profile
6337 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6338 //make a copy of the profile
6339 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6340 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006341 }
6342 else
6343 {
6344 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6345 //how to update WPA/WPA2 info in roamProfile??
6346 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006347 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006348 if(HAL_STATUS_SUCCESS(status))
6349 {
6350 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6351 }
6352 pCommand->command = eSmeCommandRoam;
6353 pCommand->sessionId = (tANI_U8)sessionId;
6354 pCommand->u.roamCmd.roamId = roamId;
6355 pCommand->u.roamCmd.roamReason = reason;
6356 //We need to free the BssList when the command is done
6357 //For reassoc there is no BSS list, so the boolean set to false
6358 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6359 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6360 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006361 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6362 if( !HAL_STATUS_SUCCESS( status ) )
6363 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006364 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6366 csrReleaseCommandRoam( pMac, pCommand );
6367 }
6368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006369 return (status);
6370}
6371
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006372eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6373 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306374// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006375{
6376 eHalStatus status = eHAL_STATUS_SUCCESS;
6377 tSmeCmd *pCommand;
6378
6379 pCommand = csrGetCommandBuffer(pMac);
6380 if(NULL == pCommand)
6381 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006382 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006383 status = eHAL_STATUS_RESOURCES;
6384 }
6385 else
6386 {
6387 if(pBssDescription)
6388 {
6389 //copy over the parameters we need later
6390 pCommand->command = eSmeCommandRoam;
6391 pCommand->sessionId = (tANI_U8)sessionId;
6392 pCommand->u.roamCmd.roamReason = reason;
6393 //this is the important parameter
6394 //in this case we are using this field for the "next" BSS
6395 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6396 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6397 if( !HAL_STATUS_SUCCESS( status ) )
6398 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006399 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006400 csrReleaseCommandPreauth( pMac, pCommand );
6401 }
6402 }
6403 else
6404 {
6405 //Return failure
6406 status = eHAL_STATUS_RESOURCES;
6407 }
6408 }
6409 return (status);
6410}
6411
6412eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6413{
6414 tListElem *pEntry;
6415 tSmeCmd *pCommand;
6416 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6417 if ( pEntry )
6418 {
6419 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6420 if ( (eSmeCommandRoam == pCommand->command) &&
6421 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6422 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006423 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006424 pCommand->command, pCommand->u.roamCmd.roamReason);
6425 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6426 csrReleaseCommandPreauth( pMac, pCommand );
6427 }
6428 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006429 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006430 pCommand->command, pCommand->u.roamCmd.roamReason);
6431 }
6432 }
6433 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006434 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006435 }
6436 smeProcessPendingQueue( pMac );
6437 return eHAL_STATUS_SUCCESS;
6438}
6439
Jeff Johnson295189b2012-06-20 16:38:30 -07006440eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6441 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6442{
6443 eHalStatus status = eHAL_STATUS_FAILURE;
6444 tScanResultHandle hBSSList;
6445 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006446 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6447 if(HAL_STATUS_SUCCESS(status))
6448 {
6449 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6450 if(pRoamId)
6451 {
6452 *pRoamId = roamId;
6453 }
6454 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6455 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6456 if(!HAL_STATUS_SUCCESS(status))
6457 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006458 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006459 csrScanResultPurge(pMac, hBSSList);
6460 }
6461 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006462 return (status);
6463}
6464
Jeff Johnson295189b2012-06-20 16:38:30 -07006465eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6466 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6467{
6468 eHalStatus status = eHAL_STATUS_SUCCESS;
6469 tScanResultHandle hBSSList;
6470 tCsrScanResultFilter *pScanFilter;
6471 tANI_U32 roamId = 0;
6472 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6473 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006474 if (NULL == pProfile)
6475 {
6476 smsLog(pMac, LOGP, FL("No profile specified"));
6477 return eHAL_STATUS_FAILURE;
6478 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006479 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006480 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006481 if( CSR_IS_WDS( pProfile ) &&
6482 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6483 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006484 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006485 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 return status;
6487 }
6488 csrRoamCancelRoaming(pMac, sessionId);
6489 csrScanRemoveFreshScanCommand(pMac, sessionId);
6490 csrScanCancelIdleScan(pMac);
6491 //Only abort the scan if it is not used for other roam/connect purpose
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306492 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006493 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6494 {
6495 csrScanDisable(pMac);
6496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006497 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6498 //Check whether ssid changes
6499 if(csrIsConnStateConnected(pMac, sessionId))
6500 {
6501 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6502 {
6503 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6504 }
6505 }
6506#ifdef FEATURE_WLAN_BTAMP_UT_RF
6507 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6508#endif
6509 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6510 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006511 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006512 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6513 if(pRoamId)
6514 {
6515 roamId = *pRoamId;
6516 }
6517 if(!HAL_STATUS_SUCCESS(status))
6518 {
6519 fCallCallback = eANI_BOOLEAN_TRUE;
6520 }
6521 }
6522 else
6523 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306524 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6525 if ( NULL == pScanFilter )
6526 status = eHAL_STATUS_FAILURE;
6527 else
6528 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006529 if(HAL_STATUS_SUCCESS(status))
6530 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306531 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006532 //Try to connect to any BSS
6533 if(NULL == pProfile)
6534 {
6535 //No encryption
6536 pScanFilter->EncryptionType.numEntries = 1;
6537 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6538 }//we don't have a profile
6539 else
6540 {
6541 //Here is the profile we need to connect to
6542 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6543 }//We have a profile
6544 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6545 if(pRoamId)
6546 {
6547 *pRoamId = roamId;
6548 }
6549
6550 if(HAL_STATUS_SUCCESS(status))
6551 {
6552 /*Save the WPS info*/
6553 if(NULL != pProfile)
6554 {
6555 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6556 }
6557 else
6558 {
6559 pScanFilter->bWPSAssociation = 0;
6560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 do
6562 {
6563 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006564 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006565 )
6566 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006567 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006568 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6569 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6570 if(!HAL_STATUS_SUCCESS(status))
6571 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006572 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006573 fCallCallback = eANI_BOOLEAN_TRUE;
6574 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006575 else
6576 {
6577 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006579 break;
6580 }
6581 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006582 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006583 if(HAL_STATUS_SUCCESS(status))
6584 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006585 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6586 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6587 if(!HAL_STATUS_SUCCESS(status))
6588 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006589 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006590 csrScanResultPurge(pMac, hBSSList);
6591 fCallCallback = eANI_BOOLEAN_TRUE;
6592 }
6593 }//Have scan result
6594 else if(NULL != pProfile)
6595 {
6596 //Check whether it is for start ibss
6597 if(CSR_IS_START_IBSS(pProfile))
6598 {
6599 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6600 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6601 if(!HAL_STATUS_SUCCESS(status))
6602 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006603 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006604 fCallCallback = eANI_BOOLEAN_TRUE;
6605 }
6606 }
6607 else
6608 {
6609 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006610 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 if(!HAL_STATUS_SUCCESS(status))
6612 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006613 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006614 fCallCallback = eANI_BOOLEAN_TRUE;
6615 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006616 else
6617 {
6618 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 }
6621 }
6622 else
6623 {
6624 fCallCallback = eANI_BOOLEAN_TRUE;
6625 }
6626 } while (0);
6627 if(NULL != pProfile)
6628 {
6629 //we need to free memory for filter if profile exists
6630 csrFreeScanFilter(pMac, pScanFilter);
6631 }
6632 }//Got the scan filter from profile
6633
Kiet Lam64c1b492013-07-12 13:56:44 +05306634 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 }//allocated memory for pScanFilter
6636 }//No Bsslist coming in
6637 //tell the caller if we fail to trigger a join request
6638 if( fCallCallback )
6639 {
6640 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6641 }
6642
6643 return (status);
6644}
Jeff Johnson295189b2012-06-20 16:38:30 -07006645eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6646 tCsrRoamModifyProfileFields modProfileFields,
6647 tANI_U32 *pRoamId)
6648{
6649 eHalStatus status = eHAL_STATUS_SUCCESS;
6650 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6651 tANI_U32 roamId = 0;
6652 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 if (NULL == pProfile)
6654 {
6655 smsLog(pMac, LOGP, FL("No profile specified"));
6656 return eHAL_STATUS_FAILURE;
6657 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006658 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 -07006659 csrRoamCancelRoaming(pMac, sessionId);
6660 csrScanRemoveFreshScanCommand(pMac, sessionId);
6661 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306662 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006664 if(csrIsConnStateConnected(pMac, sessionId))
6665 {
6666 if(pProfile)
6667 {
6668 if(pProfile->SSIDs.numOfSSIDs &&
6669 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6670 {
6671 fCallCallback = eANI_BOOLEAN_FALSE;
6672 }
6673 else
6674 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006675 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 }
6677 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306678 else if (!vos_mem_compare(&modProfileFields,
6679 &pSession->connectedProfile.modifyProfileFields,
6680 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 {
6682 fCallCallback = eANI_BOOLEAN_FALSE;
6683 }
6684 else
6685 {
6686 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006687 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006688 }
6689 }
6690 else
6691 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006692 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006693 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006694 if(!fCallCallback)
6695 {
6696 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6697 if(pRoamId)
6698 {
6699 *pRoamId = roamId;
6700 }
6701
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6703 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 }
6705 else
6706 {
6707 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6708 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6709 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 return status;
6711}
Jeff Johnson295189b2012-06-20 16:38:30 -07006712eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6713{
6714 eHalStatus status = eHAL_STATUS_FAILURE;
6715 tScanResultHandle hBSSList = NULL;
6716 tCsrScanResultFilter *pScanFilter = NULL;
6717 tANI_U32 roamId;
6718 tCsrRoamProfile *pProfile = NULL;
6719 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006720
6721 if(!pSession)
6722 {
6723 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6724 return eHAL_STATUS_FAILURE;
6725 }
6726
Jeff Johnson295189b2012-06-20 16:38:30 -07006727 do
6728 {
6729 if(pSession->pCurRoamProfile)
6730 {
6731 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306732 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006733 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306734 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6735 if ( NULL == pProfile )
6736 status = eHAL_STATUS_FAILURE;
6737 else
6738 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 if(!HAL_STATUS_SUCCESS(status))
6740 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306741 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006742 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306743 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006744 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306745 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6746 if ( NULL == pScanFilter )
6747 status = eHAL_STATUS_FAILURE;
6748 else
6749 status = eHAL_STATUS_SUCCESS;
6750
Jeff Johnson295189b2012-06-20 16:38:30 -07006751 if(!HAL_STATUS_SUCCESS(status))
6752 {
6753 break;
6754 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306755 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6757 if(!HAL_STATUS_SUCCESS(status))
6758 {
6759 break;
6760 }
6761 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6762 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6763 if(HAL_STATUS_SUCCESS(status))
6764 {
6765 //we want to put the last connected BSS to the very beginning, if possible
6766 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6767 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6768 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6769 if(!HAL_STATUS_SUCCESS(status))
6770 {
6771 csrScanResultPurge(pMac, hBSSList);
6772 break;
6773 }
6774 }
6775 else
6776 {
6777 //Do a scan on this profile
6778 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006779 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006780 if(!HAL_STATUS_SUCCESS(status))
6781 {
6782 break;
6783 }
6784 }
6785 }//We have a profile
6786 else
6787 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006788 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006789 break;
6790 }
6791 }while(0);
6792 if(pScanFilter)
6793 {
6794 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306795 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006796 }
6797 if(NULL != pProfile)
6798 {
6799 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306800 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006801 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006802 return (status);
6803}
Jeff Johnson295189b2012-06-20 16:38:30 -07006804eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6805{
6806 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 if(csrIsConnStateConnected(pMac, sessionId))
6808 {
6809 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6810 if(HAL_STATUS_SUCCESS(status))
6811 {
6812 status = csrRoamJoinLastProfile(pMac, sessionId);
6813 }
6814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006815 return (status);
6816}
6817
Jeff Johnson295189b2012-06-20 16:38:30 -07006818eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6819{
6820 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006821 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 csrRoamCancelRoaming(pMac, sessionId);
6823 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6824 if(csrIsConnStateDisconnected(pMac, sessionId))
6825 {
6826 status = csrRoamJoinLastProfile(pMac, sessionId);
6827 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006828 return (status);
6829}
6830
Jeff Johnson295189b2012-06-20 16:38:30 -07006831eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6832{
6833 eHalStatus status = eHAL_STATUS_SUCCESS;
6834 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6835 eCsrRoamSubState NewSubstate;
6836 tANI_U32 sessionId = pCommand->sessionId;
6837
6838 // change state to 'Roaming'...
6839 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6840
6841 if ( csrIsConnStateIbss( pMac, sessionId ) )
6842 {
6843 // If we are in an IBSS, then stop the IBSS...
6844 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6845 fComplete = (!HAL_STATUS_SUCCESS(status));
6846 }
6847 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6848 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006849 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 -07006850 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6851 //Restore AC weight in case we change it
6852 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6853 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6854 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6855 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6856 {
6857 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6858 }
6859 if( fDisassoc )
6860 {
6861 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6862 }
6863 else
6864 {
6865 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6866 }
6867 fComplete = (!HAL_STATUS_SUCCESS(status));
6868 }
6869 else if ( csrIsConnStateWds( pMac, sessionId ) )
6870 {
6871 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6872 {
6873 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6874 fComplete = (!HAL_STATUS_SUCCESS(status));
6875 }
6876 //This has to be WDS station
6877 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6878 {
6879
6880 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6881 if( fDisassoc )
6882 {
6883 status = csrRoamIssueDisassociate( pMac, sessionId,
6884 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6885 fComplete = (!HAL_STATUS_SUCCESS(status));
6886 }
6887 }
6888 } else {
6889 // we got a dis-assoc request while not connected to any peer
6890 // just complete the command
6891 fComplete = eANI_BOOLEAN_TRUE;
6892 status = eHAL_STATUS_FAILURE;
6893 }
6894 if(fComplete)
6895 {
6896 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6897 }
6898
6899 if(HAL_STATUS_SUCCESS(status))
6900 {
6901 if ( csrIsConnStateInfra( pMac, sessionId ) )
6902 {
6903 //Set the state to disconnect here
6904 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6905 }
6906 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006907 else
6908 {
6909 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6910 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006911 return (status);
6912}
6913
Jeff Johnson295189b2012-06-20 16:38:30 -07006914/* This is been removed from latest code base */
6915/*
6916static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6917{
6918 eHalStatus status;
6919 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006920 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6921 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006922 return ( status );
6923}
6924*/
6925
Jeff Johnson295189b2012-06-20 16:38:30 -07006926eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6927{
6928 eHalStatus status = eHAL_STATUS_SUCCESS;
6929 tSmeCmd *pCommand;
6930 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006931 do
6932 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006933 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 pCommand = csrGetCommandBuffer( pMac );
6935 if ( !pCommand )
6936 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006937 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006938 status = eHAL_STATUS_RESOURCES;
6939 break;
6940 }
6941 //Change the substate in case it is wait-for-key
6942 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6943 {
6944 csrRoamStopWaitForKeyTimer( pMac );
6945 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6946 }
6947 pCommand->command = eSmeCommandRoam;
6948 pCommand->sessionId = (tANI_U8)sessionId;
6949 switch ( reason )
6950 {
6951 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6952 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6953 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006954 case eCSR_DISCONNECT_REASON_DEAUTH:
6955 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6956 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006957 case eCSR_DISCONNECT_REASON_HANDOFF:
6958 fHighPriority = eANI_BOOLEAN_TRUE;
6959 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6960 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006961 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6962 case eCSR_DISCONNECT_REASON_DISASSOC:
6963 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6964 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006965 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6966 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6967 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006968 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6969 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6970 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006971 default:
6972 break;
6973 }
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 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 return( status );
6982}
6983
Jeff Johnson295189b2012-06-20 16:38:30 -07006984eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6985{
6986 eHalStatus status = eHAL_STATUS_SUCCESS;
6987 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006988 pCommand = csrGetCommandBuffer( pMac );
6989 if ( NULL != pCommand )
6990 {
6991 //Change the substate in case it is wait-for-key
6992 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6993 {
6994 csrRoamStopWaitForKeyTimer( pMac );
6995 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6996 }
6997 pCommand->command = eSmeCommandRoam;
6998 pCommand->sessionId = (tANI_U8)sessionId;
6999 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7000 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7001 if( !HAL_STATUS_SUCCESS( status ) )
7002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007003 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007004 csrReleaseCommandRoam( pMac, pCommand );
7005 }
7006 }
7007 else
7008 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007009 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007010 status = eHAL_STATUS_RESOURCES;
7011 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007012 return ( status );
7013}
7014
Jeff Johnson295189b2012-06-20 16:38:30 -07007015eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7016{
7017 eHalStatus status = eHAL_STATUS_SUCCESS;
7018 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007019
7020 if(!pSession)
7021 {
7022 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7023 return eHAL_STATUS_FAILURE;
7024 }
7025
Jeff Johnson295189b2012-06-20 16:38:30 -07007026#ifdef FEATURE_WLAN_BTAMP_UT_RF
7027 //Stop te retry
7028 pSession->maxRetryCount = 0;
7029 csrRoamStopJoinRetryTimer(pMac, sessionId);
7030#endif
7031 //Not to call cancel roaming here
7032 //Only issue disconnect when necessary
7033 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7034 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7035 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7036
7037 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007038 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007039 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007041 return (status);
7042}
7043
Jeff Johnson295189b2012-06-20 16:38:30 -07007044eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7045{
7046 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007047
7048 if(!pSession)
7049 {
7050 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7051 return eHAL_STATUS_FAILURE;
7052 }
7053
Jeff Johnson295189b2012-06-20 16:38:30 -07007054 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007055 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7056
7057 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7058}
7059
Jeff Johnson295189b2012-06-20 16:38:30 -07007060eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7061 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7062{
7063 eHalStatus status = eHAL_STATUS_SUCCESS;
7064 tDot11fBeaconIEs *pIesTemp = pIes;
7065 tANI_U8 index;
7066 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7067 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007068
7069 if(!pSession)
7070 {
7071 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7072 return eHAL_STATUS_FAILURE;
7073 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007074 if(pConnectProfile->pAddIEAssoc)
7075 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307076 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007077 pConnectProfile->pAddIEAssoc = NULL;
7078 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307079 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007080 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7081 pConnectProfile->AuthInfo = pProfile->AuthType;
7082 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7083 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7084 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7085 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7086 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7087 pConnectProfile->BSSType = pProfile->BSSType;
7088 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7089 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007090 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
7091
Kiet Lam64c1b492013-07-12 13:56:44 +05307092 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007093 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7094 if(pProfile->nAddIEAssocLength)
7095 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307096 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7097 if ( NULL == pConnectProfile->pAddIEAssoc )
7098 status = eHAL_STATUS_FAILURE;
7099 else
7100 status = eHAL_STATUS_SUCCESS;
7101 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007102 {
7103 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7104 return eHAL_STATUS_FAILURE;
7105 }
7106 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307107 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7108 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007109 }
7110
Jeff Johnson295189b2012-06-20 16:38:30 -07007111 //Save bssid
7112 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7113#ifdef WLAN_FEATURE_VOWIFI_11R
7114 if (pSirBssDesc->mdiePresent)
7115 {
7116 pConnectProfile->MDID.mdiePresent = 1;
7117 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7118 }
7119#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007120 if( NULL == pIesTemp )
7121 {
7122 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007124#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007125 if ((csrIsProfileCCX(pProfile) ||
7126 ((pIesTemp->CCXVersion.present)
7127 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7128 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7129 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7130 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07007131#ifdef WLAN_FEATURE_11W
7132 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
7133#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05307134 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007135 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007136 {
7137 pConnectProfile->isCCXAssoc = 1;
7138 }
7139#endif
7140 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007141 if(HAL_STATUS_SUCCESS(status))
7142 {
7143 if(pIesTemp->SSID.present)
7144 {
7145 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307146 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7147 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007148 }
7149
7150 //Save the bss desc
7151 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307152
7153 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007154 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307155 //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 -07007156 pConnectProfile->qap = TRUE;
7157 }
7158 else
7159 {
7160 pConnectProfile->qap = FALSE;
7161 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 if ( NULL == pIes )
7163 {
7164 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307165 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007166 }
7167 }
7168 //Save Qos connection
7169 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7170
7171 if(!HAL_STATUS_SUCCESS(status))
7172 {
7173 csrFreeConnectBssDesc(pMac, sessionId);
7174 }
7175 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7176 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307177 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7178 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7179 pConnectProfile->SSID.ssId,
7180 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007181 {
7182 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7183 break;
7184 }
7185 pConnectProfile->handoffPermitted = FALSE;
7186 }
7187
7188 return (status);
7189}
7190
Jeff Johnson295189b2012-06-20 16:38:30 -07007191static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7192{
7193 tListElem *pEntry = NULL;
7194 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007195 //The head of the active list is the request we sent
7196 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7197 if(pEntry)
7198 {
7199 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7200 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7202 {
7203 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7204 {
7205#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7206 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7207#endif
7208 }
7209 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7210 }
7211 else
7212 {
7213 tANI_U32 roamId = 0;
7214 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007215 if(!pSession)
7216 {
7217 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7218 return;
7219 }
7220
Jeff Johnson295189b2012-06-20 16:38:30 -07007221
7222 //The head of the active list is the request we sent
7223 //Try to get back the same profile and roam again
7224 if(pCommand)
7225 {
7226 roamId = pCommand->u.roamCmd.roamId;
7227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007228 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7229 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007230 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007231#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7232 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7233 if (csrRoamIsHandoffInProgress(pMac))
7234 {
7235 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7236 /* Should indicate neighbor roam algorithm about the connect failure here */
7237 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7238 }
7239#endif
7240 if (pCommand)
7241 {
7242 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7243 {
7244 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7245 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7246 csrRoamReissueRoamCommand(pMac);
7247 }
7248 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7249 {
7250 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7251 }
7252 else
7253 {
7254 csrRoam(pMac, pCommand);
7255 }
7256 }
7257 else
7258 {
7259 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7260 }
7261 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7262}
7263
Jeff Johnson295189b2012-06-20 16:38:30 -07007264eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7265 tDot11fBeaconIEs *pIes,
7266 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7267{
7268 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007269 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7270 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007271
7272 // Set the roaming substate to 'join attempt'...
7273 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007274 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007275 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007276 return (status);
7277}
7278
Jeff Johnson295189b2012-06-20 16:38:30 -07007279static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7280 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7281{
7282 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007283 // Set the roaming substate to 'join attempt'...
7284 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7285
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307286 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7287 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007288
7289 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007290 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007291}
7292
Jeff Johnson295189b2012-06-20 16:38:30 -07007293void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7294{
7295 tListElem *pEntry;
7296 tSmeCmd *pCommand;
7297 tCsrRoamInfo roamInfo;
7298 tANI_U32 sessionId;
7299 tCsrRoamSession *pSession;
7300
7301 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7302 if(pEntry)
7303 {
7304 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7305 if ( eSmeCommandRoam == pCommand->command )
7306 {
7307 sessionId = pCommand->sessionId;
7308 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007309
7310 if(!pSession)
7311 {
7312 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7313 return;
7314 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307315 /* While switching between two AP, csr will reissue roam command again
7316 to the nextbss if it was interrupted by the dissconnect req for the
7317 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7318 so reset the bRefAssocStartCnt.
7319 */
7320 if(pSession->bRefAssocStartCnt > 0)
7321 {
7322 pSession->bRefAssocStartCnt--;
7323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007324 if( pCommand->u.roamCmd.fStopWds )
7325 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307326 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007327 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7328 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7329 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007330 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007331 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7332 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7333 eCSR_ROAM_WDS_IND,
7334 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007335 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7336 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7337 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7338 eCSR_ROAM_INFRA_IND,
7339 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7340 }
7341
Jeff Johnson295189b2012-06-20 16:38:30 -07007342
Jeff Johnson295189b2012-06-20 16:38:30 -07007343 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7344 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007345 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007346 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7347 }
7348 }
7349 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7350 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007351 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007352 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7353 }
7354 }
7355 else
7356 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007357 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007358 }
7359 }
7360 else
7361 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007362 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007363 }
7364}
7365
Jeff Johnson295189b2012-06-20 16:38:30 -07007366tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7367{
7368 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7369 tListElem *pEntry;
7370 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007371 //alwasy lock active list before locking pending list
7372 csrLLLock( &pMac->sme.smeCmdActiveList );
7373 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7374 if(pEntry)
7375 {
7376 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7377 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7378 {
7379 fRet = eANI_BOOLEAN_TRUE;
7380 }
7381 }
7382 if(eANI_BOOLEAN_FALSE == fRet)
7383 {
7384 csrLLLock(&pMac->sme.smeCmdPendingList);
7385 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7386 while(pEntry)
7387 {
7388 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7389 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7390 {
7391 fRet = eANI_BOOLEAN_TRUE;
7392 break;
7393 }
7394 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7395 }
7396 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7397 }
7398 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007399 return (fRet);
7400}
7401
Jeff Johnson295189b2012-06-20 16:38:30 -07007402tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7403{
7404 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7405 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007406 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7407 {
7408 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7409 {
7410 break;
7411 }
7412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007413 return ( fRet );
7414}
7415
Jeff Johnson295189b2012-06-20 16:38:30 -07007416tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7417{
7418 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007419 //alwasy lock active list before locking pending list
7420 csrLLLock( &pMac->sme.smeCmdActiveList );
7421 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7422 if(eANI_BOOLEAN_FALSE == fRet)
7423 {
7424 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7425 }
7426 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007427 return (fRet);
7428}
7429
Jeff Johnson295189b2012-06-20 16:38:30 -07007430tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7431{
7432 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7433 tListElem *pEntry;
7434 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007435 //alwasy lock active list before locking pending list
7436 csrLLLock( &pMac->sme.smeCmdActiveList );
7437 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7438 if( pEntry )
7439 {
7440 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7441 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7442 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7443 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7444 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7445 {
7446 fRet = eANI_BOOLEAN_TRUE;
7447 }
7448 }
7449 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007450 return (fRet);
7451}
Jeff Johnson295189b2012-06-20 16:38:30 -07007452eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7453{
7454 eHalStatus status = eHAL_STATUS_SUCCESS;
7455 tSmeCmd *pCommand = NULL;
7456 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7457 tANI_BOOLEAN fRemoveCmd = FALSE;
7458 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007459 // Delete the old assoc command. All is setup for reassoc to be serialized
7460 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7461 if ( pEntry )
7462 {
7463 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7464 if ( !pCommand )
7465 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007466 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007467 return eHAL_STATUS_RESOURCES;
7468 }
7469 if ( eSmeCommandRoam == pCommand->command )
7470 {
7471 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7472 {
7473 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7474 }
7475 else
7476 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007477 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 }
7479 if (fRemoveCmd == FALSE)
7480 {
7481 // Implies we did not get the serialized assoc command we
7482 // were expecting
7483 pCommand = NULL;
7484 }
7485 }
7486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007487 if(NULL == pCommand)
7488 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007489 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 return eHAL_STATUS_RESOURCES;
7491 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007492 do
7493 {
7494 //Change the substate in case it is wait-for-key
7495 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7496 {
7497 csrRoamStopWaitForKeyTimer( pMac );
7498 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7499 }
7500 pCommand->command = eSmeCommandRoam;
7501 pCommand->sessionId = (tANI_U8)sessionId;
7502 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007503 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7504 if( !HAL_STATUS_SUCCESS( status ) )
7505 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007506 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007507 csrReleaseCommandRoam( pMac, pCommand );
7508 }
7509 } while( 0 );
7510
Jeff Johnson295189b2012-06-20 16:38:30 -07007511 return( status );
7512}
7513static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7514{
7515 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7516 tCsrScanResult *pScanResult = NULL;
7517 tSirBssDescription *pBssDesc = NULL;
7518 tSmeCmd *pCommand = NULL;
7519 tANI_U32 sessionId;
7520 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007521 if(NULL == pEntry)
7522 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307523 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007524 return;
7525 }
7526 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7527 sessionId = pCommand->sessionId;
7528 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007529
7530 if(!pSession)
7531 {
7532 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7533 return;
7534 }
7535
Jeff Johnson295189b2012-06-20 16:38:30 -07007536 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7537 {
7538 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007539 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7541 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007542 /* If the roaming has stopped, not to continue the roaming command*/
7543 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7544 {
7545 //No need to complete roaming here as it already completes
7546 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7547 pCommand->u.roamCmd.roamReason);
7548 csrSetAbortRoamingCommand( pMac, pCommand );
7549 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7550 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007551 else
7552 {
7553 if ( CCM_IS_RESULT_SUCCESS(result) )
7554 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007555 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007556 // Successfully set the configuration parameters for the new Bss. Attempt to
7557 // join the roaming Bss.
7558 if(pCommand->u.roamCmd.pRoamBssEntry)
7559 {
7560 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7561 pBssDesc = &pScanResult->Result.BssDescriptor;
7562 }
7563 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7564 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007565 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007566 )
7567 {
7568 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7569 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7570 pBssDesc, pCommand->u.roamCmd.roamId )))
7571 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307572 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007573 //We need to complete the command
7574 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7575 }
7576 }
7577 else
7578 {
7579 if (!pCommand->u.roamCmd.pRoamBssEntry)
7580 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307581 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 //We need to complete the command
7583 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7584 return;
7585 }
7586 // If we are roaming TO an Infrastructure BSS...
7587 VOS_ASSERT(pScanResult != NULL);
7588 if ( csrIsInfraBssDesc( pBssDesc ) )
7589 {
7590 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007591 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7592 {
7593 // ..and currently in an Infrastructure connection....
7594 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7595 {
7596 // ...and the SSIDs are equal, then we Reassoc.
7597 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7598 pIesLocal ) )
7599 // ..and currently in an infrastructure connection
7600 {
7601 // then issue a Reassoc.
7602 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7603 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7604 &pCommand->u.roamCmd.roamProfile );
7605 }
7606 else
7607 {
7608
7609 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7610 // previously associated AP.
7611 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7612 pIesLocal,
7613 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7614 {
7615 //try something else
7616 csrRoam( pMac, pCommand );
7617 }
7618 }
7619 }
7620 else
7621 {
7622 eHalStatus status = eHAL_STATUS_SUCCESS;
7623
7624 /* We need to come with other way to figure out that this is because of HO in BMP
7625 The below API will be only available for Android as it uses a different HO algorithm */
7626 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7627 * use join request */
7628#ifdef WLAN_FEATURE_VOWIFI_11R
7629 if (csrRoamIsHandoffInProgress(pMac) &&
7630 csrRoamIs11rAssoc(pMac))
7631 {
7632 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7633 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7634 }
7635 else
7636#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007637#ifdef FEATURE_WLAN_CCX
7638 if (csrRoamIsHandoffInProgress(pMac) &&
7639 csrRoamIsCCXAssoc(pMac))
7640 {
7641 // Now serialize the reassoc command.
7642 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7643 }
7644 else
7645#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007646#ifdef FEATURE_WLAN_LFR
7647 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307648 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007649 {
7650 // Now serialize the reassoc command.
7651 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7652 }
7653 else
7654#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007655 // else we are not connected and attempting to Join. Issue the
7656 // Join request.
7657 {
7658 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7659 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7660 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7661 }
7662 if(!HAL_STATUS_SUCCESS(status))
7663 {
7664 //try something else
7665 csrRoam( pMac, pCommand );
7666 }
7667 }
7668 if( !pScanResult->Result.pvIes )
7669 {
7670 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307671 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007672 }
7673 }
7674 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7675 else
7676 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007677 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007678 }
7679 }//else
7680 }//if ( WNI_CFG_SUCCESS == result )
7681 else
7682 {
7683 // In the event the configuration failed, for infra let the roam processor
7684 //attempt to join something else...
7685 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7686 {
7687 csrRoam(pMac, pCommand);
7688 }
7689 else
7690 {
7691 //We need to complete the command
7692 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7693 {
7694 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7695 }
7696 else
7697 {
7698 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7699 }
7700 }
7701 }
7702 }//we have active entry
7703}
7704
Jeff Johnson295189b2012-06-20 16:38:30 -07007705static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7706{
7707 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007708 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7710 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007711 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007712 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7713 // join the new one...
7714 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007715 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7716 }
7717 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007718 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007719 /***profHandleLostLinkAfterReset(pAdapter);
7720 // In the event the authenticate fails, let the roam processor attempt to join something else...
7721 roamRoam( pAdapter );***/
7722 }
7723}
7724
Jeff Johnson295189b2012-06-20 16:38:30 -07007725static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7726{
7727 eCsrRoamCompleteResult result;
7728 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7729 tCsrRoamInfo roamInfo;
7730 tANI_U32 roamId = 0;
7731
7732 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7733 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007734 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007735 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007736 /* Defeaturize this part later if needed */
7737#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7738 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7739 * we need the response contents while processing the result in csrRoamProcessResults() */
7740 if (csrRoamIsHandoffInProgress(pMac))
7741 {
7742 /* Need to dig more on indicating events to SME QoS module */
7743 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7744 csrRoamComplete( pMac, result, pSmeJoinRsp);
7745 }
7746 else
7747#endif
7748 {
7749 csrRoamComplete( pMac, result, NULL );
7750 }
7751 }
7752 /* Should we handle this similar to handling the join failure? Is it ok
7753 * to call csrRoamComplete() with state as CsrJoinFailure */
7754 else
7755 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007756 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007757 result = eCsrReassocFailure;
7758#ifdef WLAN_FEATURE_VOWIFI_11R
7759 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7760 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7761 {
7762 // Inform HDD to turn off FT flag in HDD
7763 if (pNeighborRoamInfo)
7764 {
7765 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7766 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7767 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007768 /*
7769 * Since the above callback sends a disconnect
7770 * to HDD, we should clean-up our state
7771 * machine as well to be in sync with the upper
7772 * layers. There is no need to send a disassoc
7773 * since: 1) we will never reassoc to the current
7774 * AP in LFR, and 2) there is no need to issue a
7775 * disassoc to the AP with which we were trying
7776 * to reassoc.
7777 */
7778 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7779 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007780 }
7781 }
7782#endif
7783 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7784 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7785 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7786 //The disassoc rsp message will remove the command from active list
7787 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7788 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7789 {
7790 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7791 }
7792 }
7793}
7794
Jeff Johnson295189b2012-06-20 16:38:30 -07007795static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7796{
Jeff Johnson295189b2012-06-20 16:38:30 -07007797#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7798 {
7799 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007800 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7801 if(pIbssLog)
7802 {
7803 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7804 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7805 {
7806 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7807 }
7808 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7809 }
7810 }
7811#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007812 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7813 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7814 {
7815 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7816 }
7817 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7818 {
7819 csrRoamReissueRoamCommand(pMac);
7820 }
7821}
7822
Jeff Johnson295189b2012-06-20 16:38:30 -07007823void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7824{
7825 tSirResultCodes statusCode;
7826#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7827 tScanResultHandle hBSSList;
7828 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7829 eHalStatus status;
7830 tCsrRoamInfo roamInfo;
7831 tCsrScanResultFilter *pScanFilter = NULL;
7832 tANI_U32 roamId = 0;
7833 tCsrRoamProfile *pCurRoamProfile = NULL;
7834 tListElem *pEntry = NULL;
7835 tSmeCmd *pCommand = NULL;
7836#endif
7837 tANI_U32 sessionId;
7838 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007839
Jeff Johnson295189b2012-06-20 16:38:30 -07007840 tSirSmeDisassocRsp SmeDisassocRsp;
7841
7842 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7843 sessionId = SmeDisassocRsp.sessionId;
7844 statusCode = SmeDisassocRsp.statusCode;
7845
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007846 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007847
7848 if ( csrIsConnStateInfra( pMac, sessionId ) )
7849 {
7850 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007852 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007853
7854 if(!pSession)
7855 {
7856 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7857 return;
7858 }
7859
Jeff Johnson295189b2012-06-20 16:38:30 -07007860 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7861 {
7862 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7863 }
7864 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7865 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7866 {
7867 if ( eSIR_SME_SUCCESS == statusCode )
7868 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007869 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007870 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7871 }
7872 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7873 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007874 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7875 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307876 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
7877 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007878#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007879 /*
7880 * First ensure if the roam profile is in the scan cache.
7881 * If not, post a reassoc failure and disconnect.
7882 */
Kiet Lam64c1b492013-07-12 13:56:44 +05307883 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7884 if ( NULL == pScanFilter )
7885 status = eHAL_STATUS_FAILURE;
7886 else
7887 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007888 if(HAL_STATUS_SUCCESS(status))
7889 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307890 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007891 status = csrRoamPrepareFilterFromProfile(pMac,
7892 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7893 if(!HAL_STATUS_SUCCESS(status))
7894 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007895 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007896 __func__, status);
7897 goto POST_ROAM_FAILURE;
7898 }
7899 else
7900 {
7901 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7902 if (!HAL_STATUS_SUCCESS(status))
7903 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007904 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007905 __func__, status);
7906 goto POST_ROAM_FAILURE;
7907 }
7908 }
7909 }
7910 else
7911 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007912 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007913 __func__, status);
7914 goto POST_ROAM_FAILURE;
7915 }
7916
7917 /*
7918 * After ensuring that the roam profile is in the scan result list,
7919 * dequeue the command from the active list.
7920 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007921 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7922 if ( pEntry )
7923 {
7924 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007925 /* If the head of the queue is Active and it is a ROAM command, remove
7926 * and put this on the Free queue.
7927 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007928 if ( eSmeCommandRoam == pCommand->command )
7929 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007930
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007931 /*
7932 * we need to process the result first before removing it from active list
7933 * because state changes still happening insides roamQProcessRoamResults so
7934 * no other roam command should be issued.
7935 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007936 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7937 if(pCommand->u.roamCmd.fReleaseProfile)
7938 {
7939 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7940 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7941 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007942 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007943 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007944 else
7945 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007946 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007947 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007948 }
7949 }
7950 else
7951 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007952 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007953 }
7954 }
7955 else
7956 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007957 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007958 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007959
7960 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007961 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7962
Kiet Lam64c1b492013-07-12 13:56:44 +05307963 vos_mem_copy(roamInfo.bssid,
7964 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7965 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007966
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007967 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7968 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007969
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007970 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05307971 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7972 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07007973 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307974 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007975 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7976 //make sure to put it at the head of the cmd queue
7977 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7978 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7979 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7980
Jeff Johnson295189b2012-06-20 16:38:30 -07007981 if(!HAL_STATUS_SUCCESS(status))
7982 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007983 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007984 __func__, status);
7985 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007986 }
7987
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007988 /* Notify sub-modules like QoS etc. that handoff happening */
7989 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007990 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307991 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007992 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307993 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007994 return;
7995 }
7996
7997POST_ROAM_FAILURE:
7998 if (pScanFilter)
7999 {
8000 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308001 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008002 }
8003 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308004 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008005
8006 /* Inform the upper layers that the reassoc failed */
8007 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8008 csrRoamCallCallback(pMac, sessionId,
8009 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8010
8011 /*
8012 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8013 * Upon success, we would re-enter this routine after receiving the disassoc
8014 * response and will fall into the reassoc fail sub-state. And, eventually
8015 * call csrRoamComplete which would remove the roam command from SME active
8016 * queue.
8017 */
8018 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8019 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8020 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008021 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008022 __func__, status);
8023 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008024 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008025#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008026
Jeff Johnson295189b2012-06-20 16:38:30 -07008027 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8028 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8029 {
8030 // Disassoc due to Reassoc failure falls into this codepath....
8031 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8032 }
8033 else
8034 {
8035 if ( eSIR_SME_SUCCESS == statusCode )
8036 {
8037 // Successfully disassociated from the 'old' Bss...
8038 //
8039 // We get Disassociate response in three conditions.
8040 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8041 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8042 // Infrastructure network.
8043 // - Third is where we are doing an Infra to Infra roam between networks with different
8044 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8045
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008046 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008047 }
8048 else
8049 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008050 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008051 }
8052 //We are not done yet. Get the data and continue roaming
8053 csrRoamReissueRoamCommand(pMac);
8054 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008055}
8056
Jeff Johnson295189b2012-06-20 16:38:30 -07008057static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8058{
8059 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008060 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008061 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008062 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008063 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8065 {
8066 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8067 }
8068 else
8069 {
8070 if ( eSIR_SME_SUCCESS == statusCode )
8071 {
8072 // Successfully deauth from the 'old' Bss...
8073 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008074 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008075 }
8076 else
8077 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008078 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008079 }
8080 //We are not done yet. Get the data and continue roaming
8081 csrRoamReissueRoamCommand(pMac);
8082 }
8083}
8084
Jeff Johnson295189b2012-06-20 16:38:30 -07008085static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8086{
8087 eCsrRoamCompleteResult result;
8088
8089 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8090 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008091 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008092 result = eCsrStartBssSuccess;
8093 }
8094 else
8095 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008096 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008097 //Let csrRoamComplete decide what to do
8098 result = eCsrStartBssFailure;
8099 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008100 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008101}
8102
Jeff Johnson295189b2012-06-20 16:38:30 -07008103/*
8104 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8105 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8106 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8107 For the messages where sender allocates memory for specific structures, then it can be
8108 cast accordingly.
8109*/
8110void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8111{
8112 tSirSmeRsp *pSmeRsp;
8113 tSmeIbssPeerInd *pIbssPeerInd;
8114 tCsrRoamInfo roamInfo;
8115 // TODO Session Id need to be acquired in this function
8116 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008117 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008118 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008119 pSmeRsp->messageType, pSmeRsp->messageType,
8120 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07008121 pSmeRsp->messageType = (pSmeRsp->messageType);
8122 pSmeRsp->length = (pSmeRsp->length);
8123 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008124 switch (pSmeRsp->messageType)
8125 {
8126
8127 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8128 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8129 {
8130 //We sent a JOIN_REQ
8131 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8132 }
8133 break;
8134
8135 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8136 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8137 {
8138 //We sent a AUTH_REQ
8139 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8140 }
8141 break;
8142
8143 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8144 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8145 {
8146 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8147 }
8148 break;
8149
8150 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8151 {
8152 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8153 }
8154 break;
8155
8156 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8157 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8158 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8159 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8160 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8161 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8162//HO
8163 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8164 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008165 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008166 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
8167 }
8168 break;
8169
8170 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8171 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8172 {
8173 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8174 }
8175 break;
8176
8177 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8178 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8179 {
8180 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8181 }
8182 break;
8183
8184 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8185 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8186 {
8187 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8188 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008189 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008190 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8191 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8192 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008193 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308194 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8195 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008196 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8197 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308198 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8199 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008200 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8201 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8202 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8203 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008204 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008205 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008206 pSmeRsp->messageType, pSmeRsp->messageType,
8207 pMac->roam.curSubState[pSmeRsp->sessionId] );
8208
8209 //If we are connected, check the link status change
8210 if(!csrIsConnStateDisconnected(pMac, sessionId))
8211 {
8212 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8213 }
8214 break;
8215 }
8216}
8217
Jeff Johnson295189b2012-06-20 16:38:30 -07008218void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8219{
8220 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008221 switch (pSirMsg->messageType)
8222 {
8223 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008224 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008225 csrRoamStatsRspProcessor( pMac, pSirMsg );
8226 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008227 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8228 {
8229 tCsrRoamSession *pSession;
8230 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8231 tCsrRoamInfo roamInfo;
8232 tCsrRoamInfo *pRoamInfo = NULL;
8233 tANI_U32 sessionId;
8234 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008235 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308236 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008237 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008238 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8239 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8240 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008241
8242 if(!pSession)
8243 {
8244 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8245 return;
8246 }
8247
Jeff Johnson295189b2012-06-20 16:38:30 -07008248 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8249 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008250 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8251 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8252 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008253 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8254 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308255 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8256 sizeof(tSirMacAddr));
8257 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8258 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008259 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008260 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8261 {
8262 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8263 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8264 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8265 }
8266 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8267 {
8268 vos_sleep( 100 );
8269 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8270 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8271 }
8272
Jeff Johnson295189b2012-06-20 16:38:30 -07008273 }
8274 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008275 default:
8276 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8277 break;
8278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008279}
8280
Jeff Johnson295189b2012-06-20 16:38:30 -07008281eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8282 tSirBssDescription *pBssDescription,
8283 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8284 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8285 tANI_U8 keyId, tANI_U16 keyLength,
8286 tANI_U8 *pKey, tANI_U8 paeRole )
8287{
8288 eHalStatus status = eHAL_STATUS_SUCCESS;
8289 tAniEdType edType;
8290
8291 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8292 {
8293 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8294 }
8295
8296 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8297
8298 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8299 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8300 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8301 addKey )
8302 {
8303 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008304 setKey.encType = EncryptType;
8305 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308306 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008307 setKey.paeRole = paeRole; //0 for supplicant
8308 setKey.keyId = keyId; // Kye index
8309 setKey.keyLength = keyLength;
8310 if( keyLength )
8311 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308312 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008313 }
8314 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8315 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008316 return (status);
8317}
8318
Jeff Johnson295189b2012-06-20 16:38:30 -07008319static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8320 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8321{
8322 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8323 tSmeCmd *pCommand = NULL;
8324#ifdef FEATURE_WLAN_CCX
8325 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8326#endif /* FEATURE_WLAN_CCX */
8327
8328 do
8329 {
8330 pCommand = csrGetCommandBuffer(pMac);
8331 if(NULL == pCommand)
8332 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008333 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008334 status = eHAL_STATUS_RESOURCES;
8335 break;
8336 }
8337 pCommand->command = eSmeCommandSetKey;
8338 pCommand->sessionId = (tANI_U8)sessionId;
8339 // validate the key length, Adjust if too long...
8340 // for static WEP the keys are not set thru' SetContextReq
8341 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8342 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8343 {
8344 //KeyLength maybe 0 for static WEP
8345 if( pSetKey->keyLength )
8346 {
8347 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8348 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008349 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008350 break;
8351 }
8352
8353 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308354 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8355 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008356 }
8357 }
8358 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8359 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8360 {
8361 //KeyLength maybe 0 for static WEP
8362 if( pSetKey->keyLength )
8363 {
8364 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8365 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008366 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008367 break;
8368 }
8369
8370 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308371 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8372 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008373 }
8374 }
8375 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8376 {
8377 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8378 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008379 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008380 break;
8381 }
8382 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308383 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8384 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008385 }
8386 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8387 {
8388 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8389 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008390 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008391 break;
8392 }
8393 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308394 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8395 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008396 }
8397#ifdef FEATURE_WLAN_WAPI
8398 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8399 {
8400 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008402 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008403 break;
8404 }
8405 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308406 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8407 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008408 }
8409#endif /* FEATURE_WLAN_WAPI */
8410#ifdef FEATURE_WLAN_CCX
8411 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8412 {
8413 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8414 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008415 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008416 break;
8417 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308418 vos_mem_copy(pSession->ccxCckmInfo.krk, pSetKey->Key,
8419 CSR_KRK_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008420 pSession->ccxCckmInfo.reassoc_req_num=1;
8421 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8422 status = eHAL_STATUS_SUCCESS;
8423 break;
8424 }
8425#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008426
Jeff Johnson295189b2012-06-20 16:38:30 -07008427#ifdef WLAN_FEATURE_11W
8428 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008429 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008430 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008431 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008432 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008433 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008434 break;
8435 }
8436 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308437 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008438 }
8439#endif
8440 status = eHAL_STATUS_SUCCESS;
8441 pCommand->u.setKeyCmd.roamId = roamId;
8442 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8443 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308444 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8445 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008446 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8447 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308448 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008449 //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
8450
8451 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8452 if( !HAL_STATUS_SUCCESS( status ) )
8453 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008454 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008455 }
8456 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008457 // Free the command if there has been a failure, or it is a
8458 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008459 if ( ( NULL != pCommand ) &&
8460 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008461#ifdef FEATURE_WLAN_CCX
8462 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8463#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008464 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008465 {
8466 csrReleaseCommandSetKey( pMac, pCommand );
8467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008468 return( status );
8469}
8470
Jeff Johnson295189b2012-06-20 16:38:30 -07008471eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8472 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8473{
8474 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8475 tSmeCmd *pCommand = NULL;
8476 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008477 do
8478 {
8479 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8480 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008481 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008482 status = eHAL_STATUS_CSR_WRONG_STATE;
8483 break;
8484 }
8485 pCommand = csrGetCommandBuffer(pMac);
8486 if(NULL == pCommand)
8487 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008488 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008489 status = eHAL_STATUS_RESOURCES;
8490 break;
8491 }
8492 pCommand->command = eSmeCommandRemoveKey;
8493 pCommand->sessionId = (tANI_U8)sessionId;
8494 pCommand->u.removeKeyCmd.roamId = roamId;
8495 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308496 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8497 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008498 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8499 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8500 {
8501 //in this case, put it to the end of the Q incase there is a set key pending.
8502 fImediate = eANI_BOOLEAN_FALSE;
8503 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008504 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008506 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008507 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8508 if( !HAL_STATUS_SUCCESS( status ) )
8509 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008510 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008511 break;
8512 }
8513 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008514 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8515 {
8516 csrReleaseCommandRemoveKey( pMac, pCommand );
8517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008518 return (status );
8519}
8520
Jeff Johnson295189b2012-06-20 16:38:30 -07008521eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8522{
8523 eHalStatus status;
8524 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8525 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8526 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8527 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008528#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8529 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8530 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008531 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008532 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308533 vos_mem_set(&setKeyEvent,
8534 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008535 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8536 {
8537 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8538 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8539 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8540 }
8541 else
8542 {
8543 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8544 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8545 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8546 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308547 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008548 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008549 {
8550 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008551 //It has to be static WEP here
8552 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8553 {
8554 setKeyEvent.keyId = (v_U8_t)defKeyId;
8555 }
8556 }
8557 else
8558 {
8559 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8560 }
8561 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8562 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8563 }
8564#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008565 if( csrIsSetKeyAllowed(pMac, sessionId) )
8566 {
8567 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8568 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8569 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8570 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8571 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8572 pCommand->u.setKeyCmd.keyRsc);
8573 }
8574 else
8575 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008576 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008577 //Set this status so the error handling take care of the case.
8578 status = eHAL_STATUS_CSR_WRONG_STATE;
8579 }
8580 if( !HAL_STATUS_SUCCESS(status) )
8581 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008582 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008583 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008584#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008585 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008586 {
8587 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8588 {
8589 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8590 }
8591 else
8592 {
8593 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8594 }
8595 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8596 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8597 }
8598#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008600 return ( status );
8601}
8602
Jeff Johnson295189b2012-06-20 16:38:30 -07008603eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8604{
8605 eHalStatus status;
8606 tpSirSmeRemoveKeyReq pMsg = NULL;
8607 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8608 tANI_U8 *p;
8609 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008610#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8611 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8612 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05308613 vos_mem_set(&removeKeyEvent,
8614 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008615 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8616 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8617 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308618 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008619 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8620 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8621 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8622#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008623 if( csrIsSetKeyAllowed(pMac, sessionId) )
8624 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308625 pMsg = vos_mem_malloc(wMsgLen);
8626 if ( NULL == pMsg )
8627 status = eHAL_STATUS_FAILURE;
8628 else
8629 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008630 }
8631 else
8632 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008633 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008634 //Set the error status so error handling kicks in below
8635 status = eHAL_STATUS_CSR_WRONG_STATE;
8636 }
8637 if( HAL_STATUS_SUCCESS( status ) )
8638 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308639 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008640 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8641 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008642 pMsg->sessionId = (tANI_U8)sessionId;
8643 pMsg->transactionId = 0;
8644 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8645 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8646 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308647 vos_mem_copy(p,
8648 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8649 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008650 p += sizeof(tSirMacAddr);
8651 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308652 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008653 p += sizeof(tSirMacAddr);
8654 // edType
8655 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8656 p++;
8657 // weptype
8658 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8659 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8660 {
8661 *p = (tANI_U8)eSIR_WEP_STATIC;
8662 }
8663 else
8664 {
8665 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8666 }
8667 p++;
8668 //keyid
8669 *p = pCommand->u.removeKeyCmd.keyId;
8670 p++;
8671 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008672 status = palSendMBMessage(pMac->hHdd, pMsg);
8673 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008674 if( !HAL_STATUS_SUCCESS( status ) )
8675 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008676 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008677#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8678 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008679 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008680 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8681#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008682 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008684 return ( status );
8685}
8686
Jeff Johnson295189b2012-06-20 16:38:30 -07008687eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8688{
8689 eHalStatus status;
8690
8691 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8692 {
8693 status = eHAL_STATUS_CSR_WRONG_STATE;
8694 }
8695 else
8696 {
8697 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8698 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008699 return ( status );
8700}
8701
Jeff Johnson295189b2012-06-20 16:38:30 -07008702/*
8703 Prepare a filter base on a profile for parsing the scan results.
8704 Upon successful return, caller MUST call csrFreeScanFilter on
8705 pScanFilter when it is done with the filter.
8706*/
8707eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8708 tCsrScanResultFilter *pScanFilter)
8709{
8710 eHalStatus status = eHAL_STATUS_SUCCESS;
8711 tANI_U32 size = 0;
8712 tANI_U8 index = 0;
8713
8714 do
8715 {
8716 if(pProfile->BSSIDs.numOfBSSIDs)
8717 {
8718 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308719 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8720 if ( NULL == pScanFilter->BSSIDs.bssid )
8721 status = eHAL_STATUS_FAILURE;
8722 else
8723 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008724 if(!HAL_STATUS_SUCCESS(status))
8725 {
8726 break;
8727 }
8728 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308729 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008730 }
8731 if(pProfile->SSIDs.numOfSSIDs)
8732 {
8733 if( !CSR_IS_WDS_STA( pProfile ) )
8734 {
8735 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8736 }
8737 else
8738 {
8739 //For WDS station
8740 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8741 pScanFilter->SSIDs.numOfSSIDs = 1;
8742 }
8743 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308744 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8745 if ( NULL == pScanFilter->SSIDs.SSIDList )
8746 status = eHAL_STATUS_FAILURE;
8747 else
8748 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008749 if(!HAL_STATUS_SUCCESS(status))
8750 {
8751 break;
8752 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308753 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8754 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008755 }
8756 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8757 {
8758 pScanFilter->ChannelInfo.numOfChannels = 0;
8759 pScanFilter->ChannelInfo.ChannelList = NULL;
8760 }
8761 else if(pProfile->ChannelInfo.numOfChannels)
8762 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308763 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8764 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8765 pProfile->ChannelInfo.numOfChannels);
8766 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8767 status = eHAL_STATUS_FAILURE;
8768 else
8769 status = eHAL_STATUS_SUCCESS;
8770
Jeff Johnson295189b2012-06-20 16:38:30 -07008771 pScanFilter->ChannelInfo.numOfChannels = 0;
8772 if(HAL_STATUS_SUCCESS(status))
8773 {
8774 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8775 {
8776 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8777 {
8778 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8779 = pProfile->ChannelInfo.ChannelList[index];
8780 pScanFilter->ChannelInfo.numOfChannels++;
8781 }
8782 else
8783 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008784 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008785 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 }
8787 }
8788 else
8789 {
8790 break;
8791 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008792 }
8793 else
8794 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308795 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008796 status = eHAL_STATUS_FAILURE;
8797 break;
8798 }
8799 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8800 pScanFilter->authType = pProfile->AuthType;
8801 pScanFilter->EncryptionType = pProfile->EncryptionType;
8802 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8803 pScanFilter->BSSType = pProfile->BSSType;
8804 pScanFilter->phyMode = pProfile->phyMode;
8805#ifdef FEATURE_WLAN_WAPI
8806 //check if user asked for WAPI with 11n or auto mode, in that case modify
8807 //the phymode to 11g
8808 if(csrIsProfileWapi(pProfile))
8809 {
8810 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8811 {
8812 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8813 }
8814 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8815 {
8816 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8817 }
8818 if(!pScanFilter->phyMode)
8819 {
8820 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8821 }
8822 }
8823#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008824 /*Save the WPS info*/
8825 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008826 if( pProfile->countryCode[0] )
8827 {
8828 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05308829 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
8830 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 }
8832#ifdef WLAN_FEATURE_VOWIFI_11R
8833 if (pProfile->MDID.mdiePresent)
8834 {
8835 pScanFilter->MDID.mdiePresent = 1;
8836 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8837 }
8838#endif
8839
8840 }while(0);
8841
8842 if(!HAL_STATUS_SUCCESS(status))
8843 {
8844 csrFreeScanFilter(pMac, pScanFilter);
8845 }
8846
8847 return(status);
8848}
8849
Jeff Johnson295189b2012-06-20 16:38:30 -07008850tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8851 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8852{
8853 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8854 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008855 do
8856 {
8857 // Validate the type is ok...
8858 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8859 pCommand = csrGetCommandBuffer( pMac );
8860 if ( !pCommand )
8861 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008862 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008863 break;
8864 }
8865 //Change the substate in case it is waiting for key
8866 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8867 {
8868 csrRoamStopWaitForKeyTimer( pMac );
8869 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8870 }
8871 pCommand->command = eSmeCommandWmStatusChange;
8872 pCommand->sessionId = (tANI_U8)sessionId;
8873 pCommand->u.wmStatusChangeCmd.Type = Type;
8874 if ( eCsrDisassociated == Type )
8875 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308876 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
8877 pSmeRsp,
8878 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 }
8880 else
8881 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308882 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
8883 pSmeRsp,
8884 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008885 }
8886 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8887 {
8888 fCommandQueued = eANI_BOOLEAN_TRUE;
8889 }
8890 else
8891 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008892 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008893 csrReleaseCommandWmStatusChange( pMac, pCommand );
8894 }
8895
Jeff Johnson295189b2012-06-20 16:38:30 -07008896 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8897 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008898 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008899 return( fCommandQueued );
8900}
8901
Jeff Johnson295189b2012-06-20 16:38:30 -07008902static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8903{
8904 v_S7_t rssi = 0;
8905 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8906 if(pGetRssiReq)
8907 {
8908 if(NULL != pGetRssiReq->pVosContext)
8909 {
8910 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8911 }
8912 else
8913 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008914 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008915 return;
8916 }
8917
8918 if(NULL != pGetRssiReq->rssiCallback)
8919 {
8920 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8921 }
8922 else
8923 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008924 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008925 return;
8926 }
8927 }
8928 else
8929 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008930 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008931 }
8932 return;
8933}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308934
8935static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
8936{
8937 tANI_S8 snr = 0;
8938 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
8939
8940 if (pGetSnrReq)
8941 {
8942 if (VOS_STATUS_SUCCESS !=
8943 WDA_GetSnr(pGetSnrReq->staId, &snr))
8944 {
8945 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
8946 return;
8947 }
8948
8949 if (pGetSnrReq->snrCallback)
8950 {
8951 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
8952 pGetSnrReq->pDevContext);
8953 }
8954 else
8955 {
8956 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
8957 return;
8958 }
8959 }
8960 else
8961 {
8962 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
8963 }
8964 return;
8965}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008966#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8967void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8968{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008969 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8970
Jeff Johnson36d483b2013-04-08 11:08:53 -07008971 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008972 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008973 /* Get roam Rssi request is backed up and passed back to the response,
8974 Extract the request message to fetch callback */
8975 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8976 v_S7_t rssi = pRoamRssiRsp->rssi;
8977
8978 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008979 {
8980 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8981 reqBkp->rssiCallback = NULL;
8982 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08008983 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008984 }
8985 else
8986 {
8987 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8988 if (NULL != reqBkp)
8989 {
8990 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08008991 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008992 }
8993 }
8994 }
8995 else
8996 {
8997 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8998 }
8999 return;
9000}
9001#endif
9002
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009003
9004#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
9005void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9006{
9007 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9008
9009 if (NULL != pTsmStatsRsp)
9010 {
9011 /* Get roam Rssi request is backed up and passed back to the response,
9012 Extract the request message to fetch callback */
9013 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9014
9015 if (NULL != reqBkp)
9016 {
9017 if (NULL != reqBkp->tsmStatsCallback)
9018 {
9019 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9020 pTsmStatsRsp->staId, reqBkp->pDevContext);
9021 reqBkp->tsmStatsCallback = NULL;
9022 }
9023 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009024 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009025 }
9026 else
9027 {
9028 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9029 if (NULL != reqBkp)
9030 {
9031 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009032 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009033 }
9034 }
9035 }
9036 else
9037 {
9038 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9039 }
9040 return;
9041}
9042
9043void csrSendCcxAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
9044{
9045 tANI_U32 roamTS2 = 0;
9046 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009047 tpPESession pSessionEntry = NULL;
9048 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009049
9050 if (NULL == pSession)
9051 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009052 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009053 return;
9054 }
9055
9056 roamTS2 = vos_timer_get_system_time();
9057 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009058 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9059 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009060 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009061
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009062 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9063 if (NULL == pSessionEntry)
9064 {
9065 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9066 return;
9067 }
9068 pSessionEntry->ccxContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009069 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
9070 0, eCSR_ROAM_CCX_ADJ_AP_REPORT_IND, 0);
9071}
9072#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
9073
Jeff Johnsone7245742012-09-05 17:12:55 -07009074static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9075{
9076 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9077 if(pTlRssiInd)
9078 {
9079 if(NULL != pTlRssiInd->tlCallback)
9080 {
9081 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009082 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009083 }
9084 else
9085 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009086 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009087 }
9088 }
9089 else
9090 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009091 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009092 }
9093 return;
9094}
Jeff Johnson295189b2012-06-20 16:38:30 -07009095
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309096eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9097{
9098 tpSirResetAPCapsChange pMsg;
9099 tANI_U16 len;
9100 eHalStatus status = eHAL_STATUS_SUCCESS;
9101
9102 /* Create the message and send to lim */
9103 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309104 pMsg = vos_mem_malloc(len);
9105 if ( NULL == pMsg )
9106 status = eHAL_STATUS_FAILURE;
9107 else
9108 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309109 if (HAL_STATUS_SUCCESS(status))
9110 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309111 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309112 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9113 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309114 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009115 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9116 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309117 status = palSendMBMessage(pMac->hHdd, pMsg);
9118 }
9119 else
9120 {
9121 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9122 }
9123 return status;
9124}
9125
Jeff Johnson295189b2012-06-20 16:38:30 -07009126void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9127{
9128 tSirSmeAssocInd *pAssocInd;
9129 tSirSmeDisassocInd *pDisassocInd;
9130 tSirSmeDeauthInd *pDeauthInd;
9131 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9132 tSirSmeNewBssInfo *pNewBss;
9133 tSmeIbssPeerInd *pIbssPeerInd;
9134 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9135 tSirSmeApNewCaps *pApNewCaps;
9136 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9137 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9138 tCsrRoamInfo *pRoamInfo = NULL;
9139 tCsrRoamInfo roamInfo;
9140 eHalStatus status;
9141 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9142 tCsrRoamSession *pSession = NULL;
9143 tpSirSmeSwitchChannelInd pSwitchChnInd;
9144 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309145 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009146
9147
9148 if (NULL == pSirMsg)
9149 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9150 return;
9151 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009152 switch( pSirMsg->messageType )
9153 {
9154 case eWNI_SME_ASSOC_IND:
9155 {
9156 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009157 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009158 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9159 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9160 if( HAL_STATUS_SUCCESS( status ) )
9161 {
9162 pSession = CSR_GET_SESSION(pMac, sessionId);
9163
Jeff Johnson32d95a32012-09-10 13:15:23 -07009164 if(!pSession)
9165 {
9166 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9167 return;
9168 }
9169
Jeff Johnson295189b2012-06-20 16:38:30 -07009170 pRoamInfo = &roamInfo;
9171
9172 // Required for indicating the frames to upper layer
9173 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9174 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9175
9176 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9177 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9178 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9179 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9180
9181 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9182 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9183 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9184
9185 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9186 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309187 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9188 sizeof(tSirMacAddr));
9189 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9190 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009191 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9192 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009193 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009194 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9195 {
9196 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9197 {
9198 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9199 pSession->pConnectBssDesc,
9200 &(pRoamInfo->peerMac),
9201 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9202 pRoamInfo->fAuthRequired = FALSE;
9203 }
9204 else
9205 {
9206 pRoamInfo->fAuthRequired = TRUE;
9207 }
9208 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9209 if (!HAL_STATUS_SUCCESS(status))
9210 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009212 /* Send Association completion message to PE */
9213 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9214
9215 /* send a message to CSR itself just to avoid the EAPOL frames going
9216 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009217 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9218 {
9219 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009221 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9222 {
9223 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9224 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9225 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009227 }
9228 }
9229 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009230 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009231 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309232 // Check if AP dis-associated us because of MIC failure. If so,
9233 // then we need to take action immediately and not wait till the
9234 // the WmStatusChange requests is pushed and processed
9235 tSmeCmd *pCommand;
9236
9237 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9238 status = csrRoamGetSessionIdFromBSSID( pMac,
9239 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9240 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009241 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309242 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9243 " for session %d "), sessionId);
9244 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9245 MAC_ADDRESS_STR " "
9246 " reason = %d status = %d "),
9247 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9248 pDisassocInd->reasonCode,
9249 pDisassocInd->statusCode);
9250 // If we are in neighbor preauth done state then on receiving
9251 // disassoc or deauth we dont roam instead we just disassoc
9252 // from current ap and then go to disconnected state
9253 // This happens for CCX and 11r FT connections ONLY.
9254#ifdef WLAN_FEATURE_VOWIFI_11R
9255 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9256 {
9257 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009259#endif
9260#ifdef FEATURE_WLAN_CCX
Agarwal Ashish4f616132013-12-30 23:32:50 +05309261 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9262 {
9263 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009265#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009266#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309267 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9268 {
9269 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9270 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009271#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309272 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009273
Agarwal Ashish4f616132013-12-30 23:32:50 +05309274 if (!pSession)
9275 {
9276 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9277 return;
9278 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009279
Agarwal Ashish4f616132013-12-30 23:32:50 +05309280 if ( csrIsConnStateInfra( pMac, sessionId ) )
9281 {
9282 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9283 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009284#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309285 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009286#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309287 csrRoamLinkDown(pMac, sessionId);
9288 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9289 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9290 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009291
Agarwal Ashish4f616132013-12-30 23:32:50 +05309292 pCommand = csrGetCommandBuffer(pMac);
9293 if (NULL == pCommand)
9294 {
9295 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9296 status = eHAL_STATUS_RESOURCES;
9297 }
9298 pRoamInfo = &roamInfo;
9299 pRoamInfo->statusCode = pDisassocInd->statusCode;
9300 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9301 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009302
Agarwal Ashish4f616132013-12-30 23:32:50 +05309303 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9304 sizeof(tSirMacAddr));
9305 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9306 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009307
Agarwal Ashish4f616132013-12-30 23:32:50 +05309308 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9309 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009310
Agarwal Ashish4f616132013-12-30 23:32:50 +05309311 /*
9312 * STA/P2P client got disassociated so remove any pending deauth
9313 * commands in sme pending list
9314 */
9315 pCommand->command = eSmeCommandRoam;
9316 pCommand->sessionId = (tANI_U8)sessionId;
9317 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9318 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9319 pDisassocInd->peerMacAddr,
9320 sizeof(tSirMacAddr));
9321 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9322 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009323
Agarwal Ashish4f616132013-12-30 23:32:50 +05309324 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009325 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309326 else
9327 {
9328 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9329 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9330 }
Kiet Lam82004c62013-11-11 13:24:28 +05309331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009332 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009333 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009334 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009335 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9336 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9337 if( HAL_STATUS_SUCCESS( status ) )
9338 {
9339 // If we are in neighbor preauth done state then on receiving
9340 // disassoc or deauth we dont roam instead we just disassoc
9341 // from current ap and then go to disconnected state
9342 // This happens for CCX and 11r FT connections ONLY.
9343#ifdef WLAN_FEATURE_VOWIFI_11R
9344 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9345 {
9346 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9347 }
9348#endif
9349#ifdef FEATURE_WLAN_CCX
9350 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9351 {
9352 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9353 }
9354#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009355#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309356 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009357 {
9358 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9359 }
9360#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009361 pSession = CSR_GET_SESSION( pMac, sessionId );
9362
Jeff Johnson32d95a32012-09-10 13:15:23 -07009363 if(!pSession)
9364 {
9365 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9366 return;
9367 }
9368
Jeff Johnson295189b2012-06-20 16:38:30 -07009369 if ( csrIsConnStateInfra( pMac, sessionId ) )
9370 {
9371 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9372 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009373#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9374 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9375#endif
9376 csrRoamLinkDown(pMac, sessionId);
9377 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009378 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9379 {
9380
9381 pRoamInfo = &roamInfo;
9382
9383 pRoamInfo->statusCode = pDeauthInd->statusCode;
9384 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9385
9386 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9387
Kiet Lam64c1b492013-07-12 13:56:44 +05309388 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9389 sizeof(tSirMacAddr));
9390 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9391 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009392
9393 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9394 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009395 }
9396 break;
9397
9398 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 -08009399 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009400 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9401 //Update with the new channel id.
9402 //The channel id is hidden in the statusCode.
9403 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9404 if( HAL_STATUS_SUCCESS( status ) )
9405 {
9406 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009407 if(!pSession)
9408 {
9409 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9410 return;
9411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009412 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9413 if(pSession->pConnectBssDesc)
9414 {
9415 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9416 }
9417 }
9418 break;
9419
9420 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009421 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009422 {
9423 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9424 sessionId = pDeauthRsp->sessionId;
9425 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9426 {
9427 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009428 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9429 {
9430 pRoamInfo = &roamInfo;
9431 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309432 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9433 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009434 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9435 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9436 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9437 }
9438 }
9439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009440 break;
9441
9442 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009443 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009444 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009445 {
9446 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9447 sessionId = pDisassocRsp->sessionId;
9448 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9449 {
9450 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009451 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9452 {
9453 pRoamInfo = &roamInfo;
9454 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309455 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9456 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009457 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9458 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9459 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9460 }
9461 }
9462 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009463 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009464 case eWNI_SME_MIC_FAILURE_IND:
9465 {
9466 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9467 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9468 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009469
9470 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9471 if( HAL_STATUS_SUCCESS( status ) )
9472 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309473 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009474 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9475 pRoamInfo = &roamInfo;
9476 if(pMicInd->info.multicast)
9477 {
9478 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9479 }
9480 else
9481 {
9482 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9483 }
9484 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9485 }
9486
Jeff Johnson295189b2012-06-20 16:38:30 -07009487#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9488 {
lukez3c809222013-05-03 10:23:02 -07009489 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009490 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009491 if(!pSession)
9492 {
9493 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9494 return;
9495 }
lukez3c809222013-05-03 10:23:02 -07009496
Kiet Lam64c1b492013-07-12 13:56:44 +05309497 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009498 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9499 secEvent.encryptionModeMulticast =
9500 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9501 secEvent.encryptionModeUnicast =
9502 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9503 secEvent.authMode =
9504 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309505 vos_mem_copy(secEvent.bssid,
9506 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009507 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9508 }
9509#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009510 }
9511 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009512 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9513 {
9514 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9515 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009516 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009517
9518 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9519 if( HAL_STATUS_SUCCESS( status ) )
9520 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309521 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009522 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9523 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9524 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9525 }
9526 }
9527 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009528
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9530 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9531 switch( pStatusChangeMsg->statusChangeCode )
9532 {
9533 case eSIR_SME_IBSS_ACTIVE:
9534 sessionId = csrFindIbssSession( pMac );
9535 if( CSR_SESSION_ID_INVALID != sessionId )
9536 {
9537 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009538 if(!pSession)
9539 {
9540 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9541 return;
9542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9544 if(pSession->pConnectBssDesc)
9545 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309546 vos_mem_copy(&roamInfo.bssid,
9547 pSession->pConnectBssDesc->bssId,
9548 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009549 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9550 pRoamInfo = &roamInfo;
9551 }
9552 else
9553 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009554 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009555 }
9556 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9557 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9558 }
9559 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009560 case eSIR_SME_IBSS_INACTIVE:
9561 sessionId = csrFindIbssSession( pMac );
9562 if( CSR_SESSION_ID_INVALID != sessionId )
9563 {
9564 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009565 if(!pSession)
9566 {
9567 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9568 return;
9569 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009570 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9571 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9572 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9573 }
9574 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009575 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9576 sessionId = csrFindIbssSession( pMac );
9577 if( CSR_SESSION_ID_INVALID != sessionId )
9578 {
9579 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009580 if(!pSession)
9581 {
9582 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9583 return;
9584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009585 // update the connection state information
9586 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009587#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9588 {
9589 vos_log_ibss_pkt_type *pIbssLog;
9590 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009591 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9592 if(pIbssLog)
9593 {
9594 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9595 if(pNewBss)
9596 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309597 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009598 if(pNewBss->ssId.length)
9599 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309600 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9601 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009602 }
9603 pIbssLog->operatingChannel = pNewBss->channelNumber;
9604 }
9605 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9606 {
9607 //***U8 is not enough for beacon interval
9608 pIbssLog->beaconInterval = (v_U8_t)bi;
9609 }
9610 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9611 }
9612 }
9613#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009614 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009615
9616 if ((eCSR_ENCRYPT_TYPE_NONE ==
9617 pSession->connectedProfile.EncryptionType ))
9618 {
9619 csrRoamIssueSetContextReq( pMac, sessionId,
9620 pSession->connectedProfile.EncryptionType,
9621 pSession->pConnectBssDesc,
9622 &Broadcastaddr,
9623 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9624 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009625 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9626 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309627 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9628 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009629 pRoamInfo = &roamInfo;
9630 //This BSSID is th ereal BSSID, let's save it
9631 if(pSession->pConnectBssDesc)
9632 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309633 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9634 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009637 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009638 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009639 // detection by LIM that the capabilities of the associated AP have changed.
9640 case eSIR_SME_AP_CAPS_CHANGED:
9641 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009642 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9644 if( HAL_STATUS_SUCCESS( status ) )
9645 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009646 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9647 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309648 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009649 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9650 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9651 )
9652 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309653 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9654 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009655 }
9656 else
9657 {
9658 smsLog(pMac, LOGW,
9659 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009660 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009661 pMac->roam.curState[sessionId],
9662 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309663 /* We ignore the caps change event if CSR is not in full connected state.
9664 * Send one event to PE to reset limSentCapsChangeNtf
9665 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9666 * otherwise lim cannot send any CAPS change events to SME */
9667 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009668 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009669 }
9670 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309671
Jeff Johnson295189b2012-06-20 16:38:30 -07009672 default:
9673 roamStatus = eCSR_ROAM_FAILED;
9674 result = eCSR_ROAM_RESULT_NONE;
9675 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009676 } // end switch on statusChangeCode
9677 if(eCSR_ROAM_RESULT_NONE != result)
9678 {
9679 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9680 }
9681 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009682 case eWNI_SME_IBSS_NEW_PEER_IND:
9683 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009684#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9685 {
9686 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9688 if(pIbssLog)
9689 {
9690 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309691 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009692 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9693 }
9694 }
9695#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009696 sessionId = csrFindIbssSession( pMac );
9697 if( CSR_SESSION_ID_INVALID != sessionId )
9698 {
9699 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009700
9701 if(!pSession)
9702 {
9703 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9704 return;
9705 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009706 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9707 if(pSession->pConnectBssDesc)
9708 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309709 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9710 sizeof(tCsrBssid));
9711 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9712 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009713 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9714 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309715 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9716 - sizeof(tSmeIbssPeerInd)));
9717 if ( NULL == roamInfo.pbFrames )
9718 status = eHAL_STATUS_FAILURE;
9719 else
9720 status = eHAL_STATUS_SUCCESS;
9721 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009722 {
9723 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309724 vos_mem_copy(roamInfo.pbFrames,
9725 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9726 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009727 }
9728 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9729 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9730 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309731 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9732 if ( NULL == roamInfo.pBssDesc )
9733 status = eHAL_STATUS_FAILURE;
9734 else
9735 status = eHAL_STATUS_SUCCESS;
9736 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009737 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309738 vos_mem_copy(roamInfo.pBssDesc,
9739 pSession->pConnectBssDesc,
9740 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009741 }
9742 if(HAL_STATUS_SUCCESS(status))
9743 {
9744 pRoamInfo = &roamInfo;
9745 }
9746 else
9747 {
9748 if(roamInfo.pbFrames)
9749 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309750 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009751 }
9752 if(roamInfo.pBssDesc)
9753 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309754 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009755 }
9756 }
9757 }
9758 else
9759 {
9760 pRoamInfo = &roamInfo;
9761 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009762 if ((eCSR_ENCRYPT_TYPE_NONE ==
9763 pSession->connectedProfile.EncryptionType ))
9764 {
9765 csrRoamIssueSetContextReq( pMac, sessionId,
9766 pSession->connectedProfile.EncryptionType,
9767 pSession->pConnectBssDesc,
9768 &(pIbssPeerInd->peerAddr),
9769 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009771 }
9772 else
9773 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009774 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009775 }
9776 //send up the sec type for the new peer
9777 if (pRoamInfo)
9778 {
9779 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9780 }
9781 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9782 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9783 if(pRoamInfo)
9784 {
9785 if(roamInfo.pbFrames)
9786 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309787 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009788 }
9789 if(roamInfo.pBssDesc)
9790 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309791 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009792 }
9793 }
9794 }
9795 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009796 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9797 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9798 sessionId = csrFindIbssSession( pMac );
9799 if( CSR_SESSION_ID_INVALID != sessionId )
9800 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009801#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9802 {
9803 vos_log_ibss_pkt_type *pIbssLog;
9804
9805 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9806 if(pIbssLog)
9807 {
9808 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9809 if(pIbssPeerInd)
9810 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309811 vos_mem_copy(pIbssLog->peerMacAddr,
9812 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009813 }
9814 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9815 }
9816 }
9817#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009818 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009819 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9820 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9821 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309822 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9823 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009824 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9825 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9826 }
9827 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009828 case eWNI_SME_SETCONTEXT_RSP:
9829 {
9830 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9831 tListElem *pEntry;
9832 tSmeCmd *pCommand;
9833
9834 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9835 if ( pEntry )
9836 {
9837 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9838 if ( eSmeCommandSetKey == pCommand->command )
9839 {
9840 sessionId = pCommand->sessionId;
9841 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009842
9843 if(!pSession)
9844 {
9845 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9846 return;
9847 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009848
9849#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9850 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9851 {
9852 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309853 vos_mem_set(&setKeyEvent,
9854 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009855 if( pRsp->peerMacAddr[0] & 0x01 )
9856 {
9857 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9858 }
9859 else
9860 {
9861 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9862 }
9863 setKeyEvent.encryptionModeMulticast =
9864 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9865 setKeyEvent.encryptionModeUnicast =
9866 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309867 vos_mem_copy(setKeyEvent.bssid,
9868 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009869 setKeyEvent.authMode =
9870 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009871 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009872 {
9873 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9874 }
9875 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9876 }
9877#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9878 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9879 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009880 csrRoamStopWaitForKeyTimer( pMac );
9881
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 //We are done with authentication, whethere succeed or not
9883 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009884 //We do it here because this linkup function is not called after association
9885 //when a key needs to be set.
9886 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9887 {
9888 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9889 }
9890 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009891 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009892 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309893 vos_mem_copy(&roamInfo.peerMac,
9894 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07009895 //Make sure we install the GTK before indicating to HDD as authenticated
9896 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +05309897 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
9898 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009899 {
Yathish9f22e662012-12-10 14:21:35 -08009900#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9901 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9902 {
9903 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +05309904 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -08009905 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9906 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9907 pMsg->seesionId = sessionId;
9908 status = palSendMBMessage(pMac->hHdd, pMsg );
9909 }
9910#endif
9911 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009912 }
9913 else
9914 {
9915 result = eCSR_ROAM_RESULT_NONE;
9916 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009917 pRoamInfo = &roamInfo;
9918 }
9919 else
9920 {
9921 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009922 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
9923 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
9924 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009925 }
9926 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9927 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009928 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9929 // can go ahead and initiate the TSPEC if any are pending
9930 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009931#ifdef FEATURE_WLAN_CCX
9932 //Send Adjacent AP repot to new AP.
9933 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9934 pSession->isPrevApInfoValid &&
9935 pSession->connectedProfile.isCCXAssoc)
9936 {
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009937#ifdef FEATURE_WLAN_CCX_UPLOAD
9938 csrSendCcxAdjacentApRepInd(pMac, pSession);
9939#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009940 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9941#endif
9942 pSession->isPrevApInfoValid = FALSE;
9943 }
9944#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009945 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9946 {
9947 csrReleaseCommandSetKey( pMac, pCommand );
9948 }
9949 }
9950 else
9951 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009952 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009953 }
9954 }
9955 else
9956 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009957 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009958 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 smeProcessPendingQueue( pMac );
9960 }
9961 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009962 case eWNI_SME_REMOVEKEY_RSP:
9963 {
9964 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9965 tListElem *pEntry;
9966 tSmeCmd *pCommand;
9967
9968 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9969 if ( pEntry )
9970 {
9971 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9972 if ( eSmeCommandRemoveKey == pCommand->command )
9973 {
9974 sessionId = pCommand->sessionId;
9975 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009976
9977 if(!pSession)
9978 {
9979 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9980 return;
9981 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009982#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9983 {
9984 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309985 vos_mem_set(&removeKeyEvent,
9986 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009987 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9988 removeKeyEvent.encryptionModeMulticast =
9989 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9990 removeKeyEvent.encryptionModeUnicast =
9991 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309992 vos_mem_copy( removeKeyEvent.bssid,
9993 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009994 removeKeyEvent.authMode =
9995 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009996 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009997 {
9998 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9999 }
10000 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10001 }
10002#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010003 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010004 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010005 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10006 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010007 result = eCSR_ROAM_RESULT_NONE;
10008 pRoamInfo = &roamInfo;
10009 }
10010 else
10011 {
10012 result = eCSR_ROAM_RESULT_FAILURE;
10013 }
10014 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10015 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10016 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10017 {
10018 csrReleaseCommandRemoveKey( pMac, pCommand );
10019 }
10020 }
10021 else
10022 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010023 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010024 }
10025 }
10026 else
10027 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010028 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010029 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010030 smeProcessPendingQueue( pMac );
10031 }
10032 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010033 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010034 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010035 csrRoamStatsRspProcessor( pMac, pSirMsg );
10036 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010037#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
10038 case eWNI_SME_GET_ROAM_RSSI_RSP:
10039 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10040 csrRoamRssiRspProcessor( pMac, pSirMsg );
10041 break;
10042#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010043#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
10044 case eWNI_SME_GET_TSM_STATS_RSP:
10045 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10046 csrTsmStatsRspProcessor( pMac, pSirMsg );
10047 break;
10048#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010049 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010050 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010051 csrUpdateRssi( pMac, pSirMsg );
10052 break;
10053
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010054 case eWNI_SME_GET_SNR_REQ:
10055 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10056 csrUpdateSnr(pMac, pSirMsg);
10057 break;
10058
Jeff Johnson295189b2012-06-20 16:38:30 -070010059#ifdef WLAN_FEATURE_VOWIFI_11R
10060 case eWNI_SME_FT_PRE_AUTH_RSP:
10061 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10062 break;
10063#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010064 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10065 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010066 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 -070010067 sessionId = pSmeMaxAssocInd->sessionId;
10068 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010069 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10070 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010071 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10072 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10073 break;
10074
10075 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010076 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010077 btampEstablishLogLinkHdlr( pSirMsg );
10078 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010079 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010080 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010081 csrRoamRssiIndHdlr( pMac, pSirMsg );
10082 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010083#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10084 case eWNI_SME_CANDIDATE_FOUND_IND:
10085 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10086 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10087 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010088 case eWNI_SME_HANDOFF_REQ:
10089 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10090 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10091 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010092#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010093
10094 default:
10095 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010096 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010097}
10098
Jeff Johnson295189b2012-06-20 16:38:30 -070010099void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10100 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10101{
10102 if(pSession)
10103 {
10104 if(pSession->bRefAssocStartCnt)
10105 {
10106 pSession->bRefAssocStartCnt--;
10107 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10108 //Need to call association_completion because there is an assoc_start pending.
10109 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10110 eCSR_ROAM_ASSOCIATION_COMPLETION,
10111 eCSR_ROAM_RESULT_FAILURE);
10112 }
10113 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10114 }
10115 else
10116 {
10117 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10118 }
10119}
10120
10121
10122eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10123{
10124 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010125 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10126 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10127 {
10128 status = csrScanRequestLostLink1( pMac, sessionId );
10129 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010130 return(status);
10131}
10132
Jeff Johnson295189b2012-06-20 16:38:30 -070010133//return a boolean to indicate whether roaming completed or continue.
10134tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10135 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10136{
10137 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10138 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10139 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10140 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010141 if(!pSession)
10142 {
10143 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10144 return eANI_BOOLEAN_FALSE;
10145 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010146 //Check whether time is up
10147 if(pSession->fCancelRoaming || fForce ||
10148 ((curTime - pSession->roamingStartTime) > roamTime) ||
10149 eCsrReassocRoaming == pSession->roamingReason ||
10150 eCsrDynamicRoaming == pSession->roamingReason)
10151 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010152 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010153 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10154 {
10155 //roaming is cancelled, tell HDD to indicate disconnect
10156 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10157 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10158 //to be eSIR_BEACON_MISSED
10159 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10160 {
10161 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10162 }
10163 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10164 {
10165 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10166 }
10167 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10168 {
10169 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10170 }
10171 else
10172 {
10173 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10174 }
10175 }
10176 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10177 pSession->roamingReason = eCsrNotRoaming;
10178 }
10179 else
10180 {
10181 pSession->roamResult = roamResult;
10182 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10183 {
10184 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10185 pSession->roamingReason = eCsrNotRoaming;
10186 }
10187 else
10188 {
10189 fCompleted = eANI_BOOLEAN_FALSE;
10190 }
10191 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010192 return(fCompleted);
10193}
10194
Jeff Johnson295189b2012-06-20 16:38:30 -070010195void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10196{
10197 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010198
10199 if(!pSession)
10200 {
10201 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10202 return;
10203 }
10204
Jeff Johnson295189b2012-06-20 16:38:30 -070010205 if(CSR_IS_ROAMING(pSession))
10206 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010207 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010208 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10209 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10210 {
10211 //No need to do anything in here because the handler takes care of it
10212 }
10213 else
10214 {
10215 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10216 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10217 //Roaming is stopped after here
10218 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10219 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +053010220 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010221 csrRoamStopRoamingTimer(pMac, sessionId);
10222 }
10223 }
10224}
10225
Jeff Johnson295189b2012-06-20 16:38:30 -070010226void csrRoamRoamingTimerHandler(void *pv)
10227{
10228 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10229 tpAniSirGlobal pMac = pInfo->pMac;
10230 tANI_U32 sessionId = pInfo->sessionId;
10231 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010232
10233 if(!pSession)
10234 {
10235 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10236 return;
10237 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010238
10239 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10240 {
10241 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10242 {
10243 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10244 pSession->roamingReason = eCsrNotRoaming;
10245 }
10246 }
10247}
10248
Jeff Johnson295189b2012-06-20 16:38:30 -070010249eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10250{
10251 eHalStatus status;
10252 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010253
10254 if(!pSession)
10255 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010256 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010257 return eHAL_STATUS_FAILURE;
10258 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010259
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010260 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010262 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010263
10264 return (status);
10265}
10266
Jeff Johnson295189b2012-06-20 16:38:30 -070010267eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10268{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010269 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010270}
10271
Jeff Johnson295189b2012-06-20 16:38:30 -070010272void csrRoamWaitForKeyTimeOutHandler(void *pv)
10273{
10274 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10275 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010276 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010277 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010278
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010279 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010280 pMac->roam.neighborRoamInfo.neighborRoamState,
10281 pMac->roam.curSubState[pInfo->sessionId]);
10282
Jeff Johnson295189b2012-06-20 16:38:30 -070010283 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10284 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010285#ifdef FEATURE_WLAN_LFR
10286 if (csrNeighborRoamIsHandoffInProgress(pMac))
10287 {
10288 /*
10289 * Enable heartbeat timer when hand-off is in progress
10290 * and Key Wait timer expired.
10291 */
10292 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010293 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010294 pMac->roam.configParam.HeartbeatThresh24);
10295 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10296 pMac->roam.configParam.HeartbeatThresh24,
10297 NULL, eANI_BOOLEAN_FALSE);
10298 }
10299#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010300 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010301
Jeff Johnson295189b2012-06-20 16:38:30 -070010302 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010303 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10304 {
10305 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10306 pInfo->sessionId);
10307 }
10308
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010309 if (pSession)
10310 {
10311 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10312 {
10313 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10314 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010315 if( (pSession->connectedProfile.AuthType ==
10316 eCSR_AUTH_TYPE_SHARED_KEY) &&
10317 ( (pSession->connectedProfile.EncryptionType ==
10318 eCSR_ENCRYPT_TYPE_WEP40) ||
10319 (pSession->connectedProfile.EncryptionType ==
10320 eCSR_ENCRYPT_TYPE_WEP104) ))
10321 {
10322 status = sme_AcquireGlobalLock( &pMac->sme );
10323 if ( HAL_STATUS_SUCCESS( status ) )
10324 {
10325 csrRoamDisconnect( pMac, pInfo->sessionId,
10326 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10327 sme_ReleaseGlobalLock( &pMac->sme );
10328 }
10329 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010330 }
10331 else
10332 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010333 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010334 __func__);
10335 }
10336 }
10337 else
10338 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010339 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010340 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010341 }
10342
10343}
10344
Jeff Johnson295189b2012-06-20 16:38:30 -070010345eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10346{
10347 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010348#ifdef FEATURE_WLAN_LFR
10349 if (csrNeighborRoamIsHandoffInProgress(pMac))
10350 {
10351 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010352 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010353 __func__,
10354 pMac->roam.neighborRoamInfo.neighborRoamState,
10355 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10356 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10357 }
10358#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010359 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010360 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010361
10362 return (status);
10363}
10364
Jeff Johnson295189b2012-06-20 16:38:30 -070010365eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10366{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010367 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010368 pMac->roam.neighborRoamInfo.neighborRoamState,
10369 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10370#ifdef FEATURE_WLAN_LFR
10371 if (csrNeighborRoamIsHandoffInProgress(pMac))
10372 {
10373 /*
10374 * Enable heartbeat timer when hand-off is in progress
10375 * and Key Wait timer got stopped for some reason
10376 */
10377 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010378 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010379 pMac->roam.configParam.HeartbeatThresh24);
10380 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10381 pMac->roam.configParam.HeartbeatThresh24,
10382 NULL, eANI_BOOLEAN_FALSE);
10383 }
10384#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010385 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010386}
10387
Jeff Johnson295189b2012-06-20 16:38:30 -070010388void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10389 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10390{
10391 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10392 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010393 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10394 /* To silence the KW tool Null chaeck is added */
10395 if(!pSession)
10396 {
10397 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10398 return;
10399 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010400
10401 if(pCommand)
10402 {
10403 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010404 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010405 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010406 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10407 {
10408 //if success, force roaming completion
10409 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10410 }
10411 else
10412 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010413 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010414 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010415 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10416 }
10417}
10418
Jeff Johnson295189b2012-06-20 16:38:30 -070010419eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10420{
10421 eHalStatus status = eHAL_STATUS_SUCCESS;
10422 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10423 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10424 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10425 tCsrRoamInfo *pRoamInfo = NULL;
10426 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010427 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010428 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010429 /* To silence the KW tool Null chaeck is added */
10430 if(!pSession)
10431 {
10432 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10433 return eHAL_STATUS_FAILURE;
10434 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010435 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010436 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010437 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10438 if ( eWNI_SME_DISASSOC_IND == type )
10439 {
10440 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10441 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10442 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010443 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010444 }
10445 else if ( eWNI_SME_DEAUTH_IND == type )
10446 {
10447 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10448 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10449 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010450 /* Convert into proper reason code */
10451 pSession->joinFailStatusCode.reasonCode =
10452 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010453 0 : pDeauthIndMsg->reasonCode;
10454 /* cfg layer expects 0 as reason code if
10455 the driver dosent know the reason code
10456 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010457 }
10458 else
10459 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010460 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010461 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010462 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010463 }
10464
10465 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010466 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010467 {
10468 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10469 }
10470
10471 if ( eWNI_SME_DISASSOC_IND == type )
10472 {
10473 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10474 }
10475 else if ( eWNI_SME_DEAUTH_IND == type )
10476 {
10477 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10478 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010479 if(!HAL_STATUS_SUCCESS(status))
10480 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010481 //If fail to send confirmation to PE, not to trigger roaming
10482 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010483 }
10484
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010485 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010486 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010487 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10488 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010489 if( eWNI_SME_DISASSOC_IND == type)
10490 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010491 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010492 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10493 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010494 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10495 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010496 else if( eWNI_SME_DEAUTH_IND == type )
10497 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010498 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010499 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10500 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010501 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10502 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010503 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010504
10505 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10506 that we are roaming. But if we cannot possibly roam, or if we are unable to
10507 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010508 if(fToRoam)
10509 {
10510 //Only remove the connected BSS in infrastructure mode
10511 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10512 //Not to do anying for lostlink with WDS
10513 if( pMac->roam.configParam.nRoamingTime )
10514 {
10515 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10516 ( eWNI_SME_DEAUTH_IND == type ) ?
10517 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10518 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010519 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010520 //For IBSS, we need to give some more info to HDD
10521 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10522 {
10523 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10524 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10525 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10526 }
10527 else
10528 {
10529 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10530 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010531 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010532 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10533 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10534 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10535 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10536 }
10537 else
10538 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010539 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010540 fToRoam = eANI_BOOLEAN_FALSE;
10541 }
10542 }
10543 else
10544 {
10545 //We are told not to roam, indicate lostlink
10546 fToRoam = eANI_BOOLEAN_FALSE;
10547 }
10548 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010549 if(!fToRoam)
10550 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010551 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010552 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010553 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010554 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10555 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10556 * csrRoamCheckForLinkStatusChange API.
10557 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010558 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10559 }
10560
10561 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010562 Still enable idle scan for polling in case concurrent sessions are running */
10563 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10564 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010565 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010566 }
10567 }
10568
10569 return (status);
10570}
10571
Jeff Johnson295189b2012-06-20 16:38:30 -070010572eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10573{
10574 eHalStatus status = eHAL_STATUS_SUCCESS;
10575 tListElem *pEntry = NULL;
10576 tSmeCmd *pCommand = NULL;
10577 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010578
10579 if(!pSession)
10580 {
10581 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10582 return eHAL_STATUS_FAILURE;
10583 }
10584
Jeff Johnson295189b2012-06-20 16:38:30 -070010585 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010586 //Only remove the connected BSS in infrastructure mode
10587 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10588 if(pMac->roam.configParam.nRoamingTime)
10589 {
10590 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10591 {
10592 //before starting the lost link logic release the roam command for handoff
10593 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10594 if(pEntry)
10595 {
10596 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10597 }
10598 if(pCommand)
10599 {
10600 if (( eSmeCommandRoam == pCommand->command ) &&
10601 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10602 {
10603 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10604 {
10605 csrReleaseCommandRoam( pMac, pCommand );
10606 }
10607 }
10608 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010609 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010610 }
10611 }
10612 else
10613 {
10614 //We are told not to roam, indicate lostlink
10615 status = eHAL_STATUS_FAILURE;
10616 }
10617
10618 return (status);
10619}
Jeff Johnson295189b2012-06-20 16:38:30 -070010620void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10621{
10622 tListElem *pEntry;
10623 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010624 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10625 if ( pEntry )
10626 {
10627 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10628 if ( eSmeCommandWmStatusChange == pCommand->command )
10629 {
10630 // Nothing to process in a Lost Link completion.... It just kicks off a
10631 // roaming sequence.
10632 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10633 {
10634 csrReleaseCommandWmStatusChange( pMac, pCommand );
10635 }
10636 else
10637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010638 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010639 }
10640
10641 }
10642 else
10643 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010644 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010645 }
10646 }
10647 else
10648 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010649 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010650 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010651 smeProcessPendingQueue( pMac );
10652}
10653
Jeff Johnson295189b2012-06-20 16:38:30 -070010654void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10655{
10656 eHalStatus status = eHAL_STATUS_FAILURE;
10657 tSirSmeRsp *pSirSmeMsg;
10658 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010659
10660 if(!pSession)
10661 {
10662 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10663 return;
10664 }
10665
Jeff Johnson295189b2012-06-20 16:38:30 -070010666 switch ( pCommand->u.wmStatusChangeCmd.Type )
10667 {
10668 case eCsrDisassociated:
10669 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10670 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10671 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010672 case eCsrDeauthenticated:
10673 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10674 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10675 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010676 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010677 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010678 break;
10679 }
10680 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10681 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10682 {
10683 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10684 {
10685 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010686 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010687 }
10688 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010689 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10690 // command here since there is nothing else to do.
10691 csrRoamWmStatusChangeComplete( pMac );
10692}
10693
Jeff Johnson295189b2012-06-20 16:38:30 -070010694//This function returns band and mode information.
10695//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10696//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010697static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10698 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010699{
Jeff Johnson295189b2012-06-20 16:38:30 -070010700 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10701 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10702 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010703 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010704
Jeff Johnson295189b2012-06-20 16:38:30 -070010705 //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 -070010706 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10707 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10708 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10709 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010710 {
10711 switch( pMac->roam.configParam.uCfgDot11Mode )
10712 {
10713 case eCSR_CFG_DOT11_MODE_11A:
10714 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10715 eBand = eCSR_BAND_5G;
10716 break;
10717 case eCSR_CFG_DOT11_MODE_11B:
10718 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10719 eBand = eCSR_BAND_24;
10720 break;
10721 case eCSR_CFG_DOT11_MODE_11G:
10722 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10723 eBand = eCSR_BAND_24;
10724 break;
10725 case eCSR_CFG_DOT11_MODE_11N:
10726 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010727 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10728 break;
10729#ifdef WLAN_FEATURE_11AC
10730 case eCSR_CFG_DOT11_MODE_11AC:
10731 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10732 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010733 /* If the operating channel is in 2.4 GHz band, check for
10734 * INI item to disable VHT operation in 2.4 GHz band
10735 */
10736 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10737 !pMac->roam.configParam.enableVhtFor24GHz)
10738 {
10739 /* Disable 11AC operation */
10740 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10741 }
10742 else
10743 {
10744 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10745 }
10746 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010747 }
10748 else
10749 {
10750 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10751 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10752 }
10753 break;
10754 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10755 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10756 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010757 /* If the operating channel is in 2.4 GHz band, check for
10758 * INI item to disable VHT operation in 2.4 GHz band
10759 */
10760 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10761 !pMac->roam.configParam.enableVhtFor24GHz)
10762 {
10763 /* Disable 11AC operation */
10764 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10765 }
10766 else
10767 {
10768 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10769 }
10770 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010771 }
10772 else
10773 {
10774 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10775 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10776 }
10777 break;
10778#endif
10779 case eCSR_CFG_DOT11_MODE_AUTO:
10780 eBand = pMac->roam.configParam.eBand;
10781 if (eCSR_BAND_24 == eBand)
10782 {
10783 // WiFi tests require IBSS networks to start in 11b mode
10784 // without any change to the default parameter settings
10785 // on the adapter. We use ACU to start an IBSS through
10786 // creation of a startIBSS profile. This startIBSS profile
10787 // has Auto MACProtocol and the adapter property setting
10788 // for dot11Mode is also AUTO. So in this case, let's
10789 // start the IBSS network in 11b mode instead of 11g mode.
10790 // So this is for Auto=profile->MacProtocol && Auto=Global.
10791 // dot11Mode && profile->channel is < 14, then start the IBSS
10792 // in b mode.
10793 //
10794 // Note: we used to have this start as an 11g IBSS for best
10795 // performance... now to specify that the user will have to
10796 // set the do11Mode in the property page to 11g to force it.
10797 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10798 }
10799 else
10800 {
10801#ifdef WLAN_FEATURE_11AC
10802 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10803 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010804 /* If the operating channel is in 2.4 GHz band, check for
10805 * INI item to disable VHT operation in 2.4 GHz band
10806 */
10807 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10808 !pMac->roam.configParam.enableVhtFor24GHz)
10809 {
10810 /* Disable 11AC operation */
10811 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10812 }
10813 else
10814 {
10815 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10816 }
10817 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010818 }
10819 else
10820 {
10821 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10822 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10823 }
10824#else
10825 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10826 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10827#endif
10828 }
10829 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010830 default:
10831 // Global dot11 Mode setting is 11a/b/g.
10832 // use the channel number to determine the Mode setting.
10833 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10834 {
10835 eBand = pMac->roam.configParam.eBand;
10836 if(eCSR_BAND_24 == eBand)
10837 {
10838 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10839 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10840 }
10841 else
10842 {
10843 //prefer 5GHz
10844 eBand = eCSR_BAND_5G;
10845 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10846 }
10847 }
10848 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10849 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010850 // WiFi tests require IBSS networks to start in 11b mode
10851 // without any change to the default parameter settings
10852 // on the adapter. We use ACU to start an IBSS through
10853 // creation of a startIBSS profile. This startIBSS profile
10854 // has Auto MACProtocol and the adapter property setting
10855 // for dot11Mode is also AUTO. So in this case, let's
10856 // start the IBSS network in 11b mode instead of 11g mode.
10857 // So this is for Auto=profile->MacProtocol && Auto=Global.
10858 // dot11Mode && profile->channel is < 14, then start the IBSS
10859 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010860 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010861 // Note: we used to have this start as an 11g IBSS for best
10862 // performance... now to specify that the user will have to
10863 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010864 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10865 eBand = eCSR_BAND_24;
10866 }
10867 else
10868 {
10869 // else, it's a 5.0GHz channel. Set mode to 11a.
10870 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10871 eBand = eCSR_BAND_5G;
10872 }
10873 break;
10874 }//switch
10875 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10876 else
10877 {
10878 //dot11 mode is set, lets pick the band
10879 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10880 {
10881 // channel is Auto also.
10882 eBand = pMac->roam.configParam.eBand;
10883 if(eCSR_BAND_ALL == eBand)
10884 {
10885 //prefer 5GHz
10886 eBand = eCSR_BAND_5G;
10887 }
10888 }
10889 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10890 {
10891 eBand = eCSR_BAND_24;
10892 }
10893 else
10894 {
10895 eBand = eCSR_BAND_5G;
10896 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010897 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010898 if(pBand)
10899 {
10900 *pBand = eBand;
10901 }
10902
10903 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010904 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010905 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10906 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010907
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010908 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10909 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 -070010910 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010911#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010912 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010913#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010914 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10915 {
10916 //We cannot do 11n here
10917 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10918 {
10919 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10920 }
10921 else
10922 {
10923 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10924 }
10925 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010926 return( cfgDot11Mode );
10927}
10928
Jeff Johnson295189b2012-06-20 16:38:30 -070010929eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10930{
10931 eHalStatus status;
10932 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010933
10934 if(!pSession)
10935 {
10936 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10937 return eHAL_STATUS_FAILURE;
10938 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010939
10940#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10941 {
10942 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010943 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10944 if(pIbssLog)
10945 {
10946 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10947 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10948 }
10949 }
10950#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010951 // Set the roaming substate to 'stop Bss request'...
10952 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10953
10954 // attempt to stop the Bss (reason code is ignored...)
10955 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010956 if(!HAL_STATUS_SUCCESS(status))
10957 {
10958 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10959 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010960 return (status);
10961}
10962
Jeff Johnson295189b2012-06-20 16:38:30 -070010963//pNumChan is a caller allocated space with the sizeof pChannels
10964eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10965{
10966
10967 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10968 (tANI_U8 *)pChannels,
10969 pNumChan));
10970}
10971
Kiran4a17ebe2013-01-31 10:43:43 -080010972tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10973{
10974 tANI_U32 cfgLength = 0;
10975 tANI_U16 cfgId = 0;
10976 tPowerdBm maxTxPwr = 0;
10977 tANI_U8 *pCountryInfo = NULL;
10978 eHalStatus status;
10979 tANI_U8 count = 0;
10980 tANI_U8 firstChannel;
10981 tANI_U8 maxChannels;
10982
10983 if (CSR_IS_CHANNEL_5GHZ(channel))
10984 {
10985 cfgId = WNI_CFG_MAX_TX_POWER_5;
10986 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10987 }
10988 else if (CSR_IS_CHANNEL_24GHZ(channel))
10989 {
10990 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10991 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10992 }
10993 else
10994 return maxTxPwr;
10995
Kiet Lam64c1b492013-07-12 13:56:44 +053010996 pCountryInfo = vos_mem_malloc(cfgLength);
10997 if ( NULL == pCountryInfo )
10998 status = eHAL_STATUS_FAILURE;
10999 else
11000 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011001 if (status != eHAL_STATUS_SUCCESS)
11002 {
11003 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011004 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011005 __FUNCTION__, status);
11006 goto error;
11007 }
11008 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11009 if (status != eHAL_STATUS_SUCCESS)
11010 {
11011 goto error;
11012 }
11013 /* Identify the channel and maxtxpower */
11014 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11015 {
11016 firstChannel = pCountryInfo[count++];
11017 maxChannels = pCountryInfo[count++];
11018 maxTxPwr = pCountryInfo[count++];
11019
11020 if ((channel >= firstChannel) &&
11021 (channel < (firstChannel + maxChannels)))
11022 {
11023 break;
11024 }
11025 }
11026
11027error:
11028 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011029 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011030
11031 return maxTxPwr;
11032}
11033
11034
Jeff Johnson295189b2012-06-20 16:38:30 -070011035tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11036{
11037 tANI_BOOLEAN fValid = FALSE;
11038 tANI_U32 idxValidChannels;
11039 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11040
11041 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11042 {
11043 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11044 {
11045 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11046 {
11047 fValid = TRUE;
11048 break;
11049 }
11050 }
11051 }
11052 pMac->roam.numValidChannels = len;
11053 return fValid;
11054}
11055
Jeff Johnson295189b2012-06-20 16:38:30 -070011056tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11057{
11058 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11059 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011060 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11061 {
11062 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11063 {
11064 fValid = eANI_BOOLEAN_TRUE;
11065 break;
11066 }
11067 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011068 return (fValid);
11069}
11070
Jeff Johnson295189b2012-06-20 16:38:30 -070011071//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011072 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011073{
Jeff Johnsone7245742012-09-05 17:12:55 -070011074 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011075 tANI_U8 centerChn;
11076 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011077 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11078 {
11079 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11080 }
11081 else
11082 {
11083 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11084 }
11085 //Figure what the other side's CB mode
11086 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11087 {
11088 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11089 {
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011090 // Check set as TKIP or not.
Praveen Kumar Sirisilla548cf372014-01-16 18:28:59 -080011091 if ((NULL != &(pIes->RSN.pwise_cipher_suites[0][0]) &&
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011092 !memcmp( &(pIes->RSN.pwise_cipher_suites[0][0]),
11093 "\x00\x0f\xac\x02" ,4))
Praveen Kumar Sirisilla548cf372014-01-16 18:28:59 -080011094 || (((NULL != &(pIes->WPA)) &&
11095 (pIes->WPA.unicast_cipher_count == 1))
11096 && ((NULL != &(pIes->WPA.unicast_ciphers[0]))
11097 && memcmp(&(pIes->WPA.unicast_ciphers[0]),
11098 "\x00\x0f\xac\x02", 4))))
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011099 {
11100 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11101 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11102 }
11103
11104 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011105 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011106 /* This is called during INFRA STA/CLIENT and should use the merged value of
11107 * supported channel width and recommended tx width as per standard
11108 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011109 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011110 pIes->HTCaps.supportedChannelWidthSet,
11111 pIes->HTInfo.recommendedTxWidthSet,
11112 pIes->HTInfo.secondaryChannelOffset);
11113
11114 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11115 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011116 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011117 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11118 switch (eRet) {
11119 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11120 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11121 break;
11122 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11123 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11124 break;
11125 case PHY_SINGLE_CHANNEL_CENTERED:
11126 default:
11127 centerChn = primaryChn;
11128 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011129 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011130 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011131 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011132 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070011133 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011134 }
11135 }
11136 }
11137 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011138 return eRet;
11139}
Jeff Johnson295189b2012-06-20 16:38:30 -070011140tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11141{
11142 tANI_BOOLEAN fFound = FALSE;
11143 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011144 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11145 {
11146 if( pCipherList->encryptionType[idx] == encryptionType )
11147 {
11148 fFound = TRUE;
11149 break;
11150 }
11151 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011152 return fFound;
11153}
Jeff Johnson295189b2012-06-20 16:38:30 -070011154tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11155{
11156 tANI_BOOLEAN fFound = FALSE;
11157 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011158 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11159 {
11160 if( pAuthList->authType[idx] == authType )
11161 {
11162 fFound = TRUE;
11163 break;
11164 }
11165 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011166 return fFound;
11167}
Jeff Johnson295189b2012-06-20 16:38:30 -070011168tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11169{
11170 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11171 tCsrScanResultFilter *pScanFilter = NULL;
11172 eHalStatus status = eHAL_STATUS_SUCCESS;
11173
11174 if(pProfile1 && pProfile2)
11175 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011176 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11177 if ( NULL == pScanFilter )
11178 status = eHAL_STATUS_FAILURE;
11179 else
11180 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011181 if(HAL_STATUS_SUCCESS(status))
11182 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011183 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011184 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11185 if(HAL_STATUS_SUCCESS(status))
11186 {
11187 fCheck = eANI_BOOLEAN_FALSE;
11188 do
11189 {
11190 tANI_U32 i;
11191 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11192 {
11193 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11194 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11195 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11196 if ( fCheck ) break;
11197 }
11198 if(!fCheck)
11199 {
11200 break;
11201 }
11202 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11203 || pProfile2->BSSType != pProfile1->BSSType
11204 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11205 )
11206 {
11207 fCheck = eANI_BOOLEAN_FALSE;
11208 break;
11209 }
11210#ifdef WLAN_FEATURE_VOWIFI_11R
11211 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11212 {
11213 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11214 {
11215 fCheck = eANI_BOOLEAN_FALSE;
11216 break;
11217 }
11218 }
11219#endif
11220 //Match found
11221 fCheck = eANI_BOOLEAN_TRUE;
11222 }while(0);
11223 csrFreeScanFilter(pMac, pScanFilter);
11224 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011225 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011226 }
11227 }
11228
11229 return (fCheck);
11230}
11231
Jeff Johnson295189b2012-06-20 16:38:30 -070011232tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11233{
11234 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11235 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011236 do
11237 {
11238 //Only check for static WEP
11239 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11240 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11241 {
11242 fCheck = eANI_BOOLEAN_TRUE;
11243 break;
11244 }
11245 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11246 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11247 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11248 {
11249 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011250 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11251 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011252 {
11253 break;
11254 }
11255 }
11256 if( i == CSR_MAX_NUM_KEY)
11257 {
11258 fCheck = eANI_BOOLEAN_TRUE;
11259 }
11260 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011261 return (fCheck);
11262}
11263
Jeff Johnson295189b2012-06-20 16:38:30 -070011264//IBSS
11265
Jeff Johnson295189b2012-06-20 16:38:30 -070011266tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11267{
11268 tANI_U8 channel = 0;
11269 tANI_U32 idx;
11270 tANI_U32 idxValidChannels;
11271 tANI_BOOLEAN fFound = FALSE;
11272 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11273
11274 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11275 {
11276 channel = pMac->roam.configParam.AdHocChannel5G;
11277 if(!csrRoamIsChannelValid(pMac, channel))
11278 {
11279 channel = 0;
11280 }
11281 }
11282 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11283 {
11284 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11285 {
11286 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11287 {
11288 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11289 {
11290 fFound = TRUE;
11291 channel = csrStartIbssChannels50[ idx ];
11292 }
11293 }
11294 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011295 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11296 if (!fFound)
11297 {
11298 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11299 {
11300 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11301 {
11302 channel = csrStartIbssChannels50[ idx ];
11303 break;
11304 }
11305 }
11306 }
11307 }//if
11308
11309 return( channel );
11310}
11311
Jeff Johnson295189b2012-06-20 16:38:30 -070011312tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11313{
11314 tANI_U8 channel = 1;
11315 tANI_U32 idx;
11316 tANI_U32 idxValidChannels;
11317 tANI_BOOLEAN fFound = FALSE;
11318 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11319
11320 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11321 {
11322 channel = pMac->roam.configParam.AdHocChannel24;
11323 if(!csrRoamIsChannelValid(pMac, channel))
11324 {
11325 channel = 0;
11326 }
11327 }
11328
11329 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11330 {
11331 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11332 {
11333 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11334 {
11335 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11336 {
11337 fFound = TRUE;
11338 channel = csrStartIbssChannels24[ idx ];
11339 }
11340 }
11341 }
11342 }
11343
11344 return( channel );
11345}
11346
Jeff Johnson295189b2012-06-20 16:38:30 -070011347static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11348 tCsrRoamStartBssParams *pParam )
11349{
11350 eCsrCfgDot11Mode cfgDot11Mode;
11351 eCsrBand eBand;
11352 tANI_U8 channel = 0;
11353 tSirNwType nwType;
11354 tANI_U8 operationChannel = 0;
11355
11356 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11357 {
11358 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11359 }
11360
Jeff Johnson295189b2012-06-20 16:38:30 -070011361 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011362
Jeff Johnson295189b2012-06-20 16:38:30 -070011363 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11364 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11365 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11366 )
11367 {
11368 /* This should never happen */
11369 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011370 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011371 pProfile->csrPersona);
11372 VOS_ASSERT(0);
11373 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011374 switch( cfgDot11Mode )
11375 {
11376 case eCSR_CFG_DOT11_MODE_11G:
11377 nwType = eSIR_11G_NW_TYPE;
11378 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011379 case eCSR_CFG_DOT11_MODE_11B:
11380 nwType = eSIR_11B_NW_TYPE;
11381 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011382 case eCSR_CFG_DOT11_MODE_11A:
11383 nwType = eSIR_11A_NW_TYPE;
11384 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011385 default:
11386 case eCSR_CFG_DOT11_MODE_11N:
11387 case eCSR_CFG_DOT11_MODE_TAURUS:
11388 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11389 if(eCSR_BAND_24 == eBand)
11390 {
11391 nwType = eSIR_11G_NW_TYPE;
11392 }
11393 else
11394 {
11395 nwType = eSIR_11A_NW_TYPE;
11396 }
11397 break;
11398 }
11399
11400 pParam->extendedRateSet.numRates = 0;
11401
11402 switch ( nwType )
11403 {
11404 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011405 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011406 case eSIR_11A_NW_TYPE:
11407
11408 pParam->operationalRateSet.numRates = 8;
11409
11410 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11411 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11412 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11413 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11414 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11415 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11416 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11417 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11418
11419 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11420 {
11421 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11422 if( 0 == channel &&
11423 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11424 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11425 )
11426 {
11427 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11428 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11429 nwType = eSIR_11B_NW_TYPE;
11430 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11431 pParam->operationalRateSet.numRates = 4;
11432 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11433 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11434 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11435 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11436 }
11437 }
11438 else
11439 {
11440 channel = operationChannel;
11441 }
11442 break;
11443
11444 case eSIR_11B_NW_TYPE:
11445 pParam->operationalRateSet.numRates = 4;
11446 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11447 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11448 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11449 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011450 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11451 {
11452 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11453 }
11454 else
11455 {
11456 channel = operationChannel;
11457 }
11458
11459 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011460 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011461 /* For P2P Client and P2P GO, disable 11b rates */
11462 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11463 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11464 )
11465 {
11466 pParam->operationalRateSet.numRates = 8;
11467
11468 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11469 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11470 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11471 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11472 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11473 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11474 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11475 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11476 }
11477 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011478 {
11479 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011480 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11481 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11482 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11483 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11484
11485 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011486 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11487 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11488 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11489 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11490 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11491 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11492 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11493 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11494 }
11495
11496 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11497 {
11498 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11499 }
11500 else
11501 {
11502 channel = operationChannel;
11503 }
11504
11505 break;
11506 }
11507 pParam->operationChn = channel;
11508 pParam->sirNwType = nwType;
11509}
11510
Jeff Johnson295189b2012-06-20 16:38:30 -070011511static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11512 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11513{
11514
11515 if( pParam )
11516 {
11517 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011518 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011519 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011520 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011521
11522 if( pIes )
11523 {
11524 if(pIes->SuppRates.present)
11525 {
11526 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11527 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11528 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011529 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 -070011530 pIes->SuppRates.num_rates);
11531 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11532 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011533 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11534 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011535 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011536 if (pIes->ExtSuppRates.present)
11537 {
11538 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
11539 if(pIes->ExtSuppRates.num_rates > SIR_MAC_EXTENDED_RATE_EID_MAX)
11540 {
11541 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11542 SIR_MAC_RATESET_EID_MAX, resetting to \
11543 SIR_MAC_RATESET_EID_MAX"),
11544 pIes->ExtSuppRates.num_rates);
11545 pIes->ExtSuppRates.num_rates = SIR_MAC_EXTENDED_RATE_EID_MAX;
11546 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011547 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011548 pIes->ExtSuppRates.rates,
11549 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11550 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011551 if( pIes->SSID.present )
11552 {
11553 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011554 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11555 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011556 }
11557 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011558 }
11559 else
11560 {
11561 pParam->ssId.length = 0;
11562 pParam->operationalRateSet.numRates = 0;
11563 }
11564 }
11565}
11566
Jeff Johnson295189b2012-06-20 16:38:30 -070011567static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11568{
11569 tANI_U8 MaxRate = 0;
11570 tANI_U32 i;
11571 tANI_U8 *pRate;
11572
11573 pRate = pSirRateSet->rate;
11574 for ( i = 0; i < pSirRateSet->numRates; i++ )
11575 {
11576 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11577 }
11578
11579 // Save the max rate in the connected state information...
11580
11581 // modify LastRates variable as well
11582
11583 return;
11584}
11585
Jeff Johnson295189b2012-06-20 16:38:30 -070011586eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11587 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11588{
11589 eHalStatus status = eHAL_STATUS_SUCCESS;
11590 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011591 // Set the roaming substate to 'Start BSS attempt'...
11592 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011593#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11594 //Need to figure out whether we need to log WDS???
11595 if( CSR_IS_IBSS( pProfile ) )
11596 {
11597 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011598 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11599 if(pIbssLog)
11600 {
11601 if(pBssDesc)
11602 {
11603 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011604 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011605 }
11606 else
11607 {
11608 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11609 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011610 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011611 if(pProfile->ChannelInfo.numOfChannels == 0)
11612 {
11613 pIbssLog->channelSetting = AUTO_PICK;
11614 }
11615 else
11616 {
11617 pIbssLog->channelSetting = SPECIFIED;
11618 }
11619 pIbssLog->operatingChannel = pParam->operationChn;
11620 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11621 }
11622 }
11623#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11624 //Put RSN information in for Starting BSS
11625 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11626 pParam->pRSNIE = pProfile->pRSNReqIE;
11627
Jeff Johnson295189b2012-06-20 16:38:30 -070011628 pParam->privacy = pProfile->privacy;
11629 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11630 pParam->authType = pProfile->csr80211AuthType;
11631 pParam->beaconInterval = pProfile->beaconInterval;
11632 pParam->dtimPeriod = pProfile->dtimPeriod;
11633 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11634 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11635 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11636 {
11637 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11638 {
11639 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11640 }
11641 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011642 pParam->protEnabled = pProfile->protEnabled;
11643 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11644 pParam->ht_protection = pProfile->cfg_protection;
11645 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011646
Jeff Johnson295189b2012-06-20 16:38:30 -070011647 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11648 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011649 pParam->bssPersona = pProfile->csrPersona;
11650 // When starting an IBSS, start on the channel from the Profile.
11651 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 return (status);
11653}
11654
Jeff Johnson295189b2012-06-20 16:38:30 -070011655static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011656 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011657{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011658 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011659 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011660 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011661
11662 if(!pSession)
11663 {
11664 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11665 return;
11666 }
11667
Jeff Johnson295189b2012-06-20 16:38:30 -070011668 if( pBssDesc )
11669 {
11670 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11671 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11672 //The following code has to be do after that.
11673 //For WDS station, use selfMac as the self BSSID
11674 if( CSR_IS_WDS_STA( pProfile ) )
11675 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011676 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11677 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011678 }
11679 }
11680 else
11681 {
11682 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011683 //Use the first SSID
11684 if(pProfile->SSIDs.numOfSSIDs)
11685 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011686 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11687 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011688 }
11689 //For WDS station, use selfMac as the self BSSID
11690 if( CSR_IS_WDS_STA( pProfile ) )
11691 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011692 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11693 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011694 }
11695 //Use the first BSSID
11696 else if( pProfile->BSSIDs.numOfBSSIDs )
11697 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011698 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11699 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011700 }
11701 else
11702 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011703 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011704 }
11705 }
11706 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011707 //Set operating channel in pProfile which will be used
11708 //in csrRoamSetBssConfigCfg() to determine channel bonding
11709 //mode and will be configured in CFG later
11710 pProfile->operationChannel = Channel;
11711
11712 if(Channel == 0)
11713 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053011714 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011715 }
11716 else
11717 {
11718
11719 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011720 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011721 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011722 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011723 {
11724 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11725 }
11726 else
11727 {
11728 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11729 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011730 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011731 pBssConfig->cbMode = cbMode;
11732 pSession->bssParams.cbMode = cbMode;
11733 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011734 }
11735}
11736
Jeff Johnson295189b2012-06-20 16:38:30 -070011737static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11738 tANI_BOOLEAN *pfSameIbss )
11739{
11740 eHalStatus status = eHAL_STATUS_SUCCESS;
11741 tANI_BOOLEAN fSameIbss = FALSE;
11742
11743 if ( csrIsConnStateIbss( pMac, sessionId ) )
11744 {
11745 // Check if any profile parameter has changed ? If any profile parameter
11746 // has changed then stop old BSS and start a new one with new parameters
11747 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11748 {
11749 fSameIbss = TRUE;
11750 }
11751 else
11752 {
11753 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11754 }
11755 }
11756 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11757 {
11758 // Disassociate from the connected Infrastructure network...
11759 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11760 }
11761 else
11762 {
11763 tBssConfigParam *pBssConfig;
11764
Kiet Lam64c1b492013-07-12 13:56:44 +053011765 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11766 if ( NULL == pBssConfig )
11767 status = eHAL_STATUS_FAILURE;
11768 else
11769 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011770 if(HAL_STATUS_SUCCESS(status))
11771 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011772 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011773 // there is no Bss description before we start an IBSS so we need to adopt
11774 // all Bss configuration parameters from the Profile.
11775 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11776 if(HAL_STATUS_SUCCESS(status))
11777 {
11778 //save dotMode
11779 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11780 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011781 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011782 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11783 NULL, pBssConfig,
11784 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011785 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011786
11787 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011788 }//Allocate memory
11789 }
11790
11791 if(pfSameIbss)
11792 {
11793 *pfSameIbss = fSameIbss;
11794 }
11795 return( status );
11796}
11797
Jeff Johnson295189b2012-06-20 16:38:30 -070011798static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11799 tSirSmeNewBssInfo *pNewBss )
11800{
11801 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011802
11803 if(!pSession)
11804 {
11805 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11806 return;
11807 }
11808
Jeff Johnson295189b2012-06-20 16:38:30 -070011809 if( pNewBss )
11810 {
11811 // Set the operating channel.
11812 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11813 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011814 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11815 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011816 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011817 return;
11818}
11819
Jeff Johnson295189b2012-06-20 16:38:30 -070011820#ifdef FEATURE_WLAN_WAPI
11821eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11822 tANI_U32 numItems )
11823{
11824 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11825 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011826 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11827 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011828 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011829 return status;
11830 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011831 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011832 pSession = CSR_GET_SESSION( pMac, sessionId );
11833 if(numItems <= CSR_MAX_BKID_ALLOWED)
11834 {
11835 status = eHAL_STATUS_SUCCESS;
11836 //numItems may be 0 to clear the cache
11837 pSession->NumBkidCache = (tANI_U16)numItems;
11838 if(numItems && pBKIDCache)
11839 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011840 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
11841 sizeof(tBkidCacheInfo) * numItems);
11842 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011843 }
11844 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011845 return (status);
11846}
Jeff Johnson295189b2012-06-20 16:38:30 -070011847eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11848 tBkidCacheInfo *pBkidCache)
11849{
11850 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11851 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011852 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11853 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011854 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011855 return status;
11856 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011857 pSession = CSR_GET_SESSION( pMac, sessionId );
11858 if(pNum && pBkidCache)
11859 {
11860 if(pSession->NumBkidCache == 0)
11861 {
11862 *pNum = 0;
11863 status = eHAL_STATUS_SUCCESS;
11864 }
11865 else if(*pNum >= pSession->NumBkidCache)
11866 {
11867 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11868 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011869 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 -070011870 pSession->NumBkidCache);
11871 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11872 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011873 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
11874 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011875 *pNum = pSession->NumBkidCache;
11876 status = eHAL_STATUS_SUCCESS;
11877 }
11878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011879 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011880}
Jeff Johnson295189b2012-06-20 16:38:30 -070011881tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11882{
11883 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011884}
11885#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011886eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11887 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11888{
11889 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11890 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011891
11892 if(!pSession)
11893 {
11894 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11895 return eHAL_STATUS_FAILURE;
11896 }
11897
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011898 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011899 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11900 {
11901#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11902 {
11903 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053011904 vos_mem_set(&secEvent,
11905 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011906 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11907 secEvent.encryptionModeMulticast =
11908 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11909 secEvent.encryptionModeUnicast =
11910 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053011911 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011912 secEvent.authMode =
11913 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11914 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11915 }
11916#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011917 status = eHAL_STATUS_SUCCESS;
11918 //numItems may be 0 to clear the cache
11919 pSession->NumPmkidCache = (tANI_U16)numItems;
11920 if(numItems && pPMKIDCache)
11921 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011922 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
11923 sizeof(tPmkidCacheInfo) * numItems);
11924 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011925 }
11926 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011927 return (status);
11928}
11929
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011930eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11931 tANI_U8 *pBSSId )
11932{
11933 eHalStatus status = eHAL_STATUS_FAILURE;
11934 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11935 tANI_BOOLEAN fMatchFound = FALSE;
11936 tANI_U32 Index;
11937 if(!pSession)
11938 {
11939 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11940 return eHAL_STATUS_FAILURE;
11941 }
11942 do
11943 {
11944 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
11945 {
Arif Hussaina7c8e412013-11-20 11:06:42 -080011946 smsLog(pMac, LOGW, "Delete PMKID for "
11947 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Kiet Lamf2f201e2013-11-16 21:24:16 +053011948 if( vos_mem_compare( pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011949 {
11950 fMatchFound = TRUE;
11951 break;
11952 }
11953 }
11954 if( !fMatchFound ) break;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053011955 vos_mem_set(pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid), 0);
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011956 status = eHAL_STATUS_SUCCESS;
11957 }
11958 while( 0 );
11959 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
11960 fMatchFound, status);
11961 return status;
11962}
Jeff Johnson295189b2012-06-20 16:38:30 -070011963tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11964{
11965 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11966}
11967
Jeff Johnson295189b2012-06-20 16:38:30 -070011968eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11969{
11970 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11971 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011972
11973 if(!pSession)
11974 {
11975 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11976 return eHAL_STATUS_FAILURE;
11977 }
11978
Jeff Johnson295189b2012-06-20 16:38:30 -070011979 if(pNum && pPmkidCache)
11980 {
11981 if(pSession->NumPmkidCache == 0)
11982 {
11983 *pNum = 0;
11984 status = eHAL_STATUS_SUCCESS;
11985 }
11986 else if(*pNum >= pSession->NumPmkidCache)
11987 {
11988 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11989 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011990 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 -070011991 pSession->NumPmkidCache);
11992 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11993 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011994 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
11995 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011996 *pNum = pSession->NumPmkidCache;
11997 status = eHAL_STATUS_SUCCESS;
11998 }
11999 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012000 return (status);
12001}
12002
Jeff Johnson295189b2012-06-20 16:38:30 -070012003eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12004{
12005 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12006 tANI_U32 len;
12007 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012008
12009 if(!pSession)
12010 {
12011 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12012 return eHAL_STATUS_FAILURE;
12013 }
12014
Jeff Johnson295189b2012-06-20 16:38:30 -070012015 if(pLen)
12016 {
12017 len = *pLen;
12018 *pLen = pSession->nWpaRsnReqIeLength;
12019 if(pBuf)
12020 {
12021 if(len >= pSession->nWpaRsnReqIeLength)
12022 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012023 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12024 pSession->nWpaRsnReqIeLength);
12025 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012026 }
12027 }
12028 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012029 return (status);
12030}
12031
Jeff Johnson295189b2012-06-20 16:38:30 -070012032eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12033{
12034 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12035 tANI_U32 len;
12036 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012037
12038 if(!pSession)
12039 {
12040 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12041 return eHAL_STATUS_FAILURE;
12042 }
12043
Jeff Johnson295189b2012-06-20 16:38:30 -070012044 if(pLen)
12045 {
12046 len = *pLen;
12047 *pLen = pSession->nWpaRsnRspIeLength;
12048 if(pBuf)
12049 {
12050 if(len >= pSession->nWpaRsnRspIeLength)
12051 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012052 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12053 pSession->nWpaRsnRspIeLength);
12054 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012055 }
12056 }
12057 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012058 return (status);
12059}
Jeff Johnson295189b2012-06-20 16:38:30 -070012060#ifdef FEATURE_WLAN_WAPI
12061eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12062{
12063 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12064 tANI_U32 len;
12065 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012066
12067 if(!pSession)
12068 {
12069 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12070 return eHAL_STATUS_FAILURE;
12071 }
12072
Jeff Johnson295189b2012-06-20 16:38:30 -070012073 if(pLen)
12074 {
12075 len = *pLen;
12076 *pLen = pSession->nWapiReqIeLength;
12077 if(pBuf)
12078 {
12079 if(len >= pSession->nWapiReqIeLength)
12080 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012081 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12082 pSession->nWapiReqIeLength);
12083 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012084 }
12085 }
12086 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012087 return (status);
12088}
Jeff Johnson295189b2012-06-20 16:38:30 -070012089eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12090{
12091 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12092 tANI_U32 len;
12093 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012094
12095 if(!pSession)
12096 {
12097 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12098 return eHAL_STATUS_FAILURE;
12099 }
12100
Jeff Johnson295189b2012-06-20 16:38:30 -070012101 if(pLen)
12102 {
12103 len = *pLen;
12104 *pLen = pSession->nWapiRspIeLength;
12105 if(pBuf)
12106 {
12107 if(len >= pSession->nWapiRspIeLength)
12108 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012109 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12110 pSession->nWapiRspIeLength);
12111 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012112 }
12113 }
12114 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012115 return (status);
12116}
12117#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012118eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12119{
12120 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12121 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012122
12123 if(!pSession)
12124 {
12125 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12126 return (retStatus);
12127 }
12128
Jeff Johnson295189b2012-06-20 16:38:30 -070012129 if(CSR_IS_ROAMING(pSession))
12130 {
12131 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12132 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12133 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012134 return (retStatus);
12135}
12136
Jeff Johnson295189b2012-06-20 16:38:30 -070012137//This function remove the connected BSS from te cached scan result
12138eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12139 tCsrRoamConnectedProfile *pConnProfile)
12140{
12141 eHalStatus status = eHAL_STATUS_FAILURE;
12142 tCsrScanResultFilter *pScanFilter = NULL;
12143 tListElem *pEntry;
12144 tCsrScanResult *pResult;
12145 tDot11fBeaconIEs *pIes;
12146 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012147 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12148 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12149 {
12150 do
12151 {
12152 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012153 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12154 if ( NULL == pScanFilter )
12155 status = eHAL_STATUS_FAILURE;
12156 else
12157 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012158 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012159 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12160 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12161 if ( NULL == pScanFilter->BSSIDs.bssid )
12162 status = eHAL_STATUS_FAILURE;
12163 else
12164 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012165 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012166 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12167 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012168 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12169 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12170 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012171 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12172 if ( NULL == pScanFilter->SSIDs.SSIDList )
12173 status = eHAL_STATUS_FAILURE;
12174 else
12175 status = eHAL_STATUS_SUCCESS;
12176 if (!HAL_STATUS_SUCCESS(status)) break;
12177 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12178 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012179 }
12180 pScanFilter->authType.numEntries = 1;
12181 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12182 pScanFilter->BSSType = pConnProfile->BSSType;
12183 pScanFilter->EncryptionType.numEntries = 1;
12184 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12185 pScanFilter->mcEncryptionType.numEntries = 1;
12186 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12187 //We ignore the channel for now, BSSID should be enough
12188 pScanFilter->ChannelInfo.numOfChannels = 0;
12189 //Also ignore the following fields
12190 pScanFilter->uapsd_mask = 0;
12191 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
12192 pScanFilter->countryCode[0] = 0;
12193 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012194 csrLLLock(&pMac->scan.scanResultList);
12195 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12196 while( pEntry )
12197 {
12198 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12199 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12200 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12201 pScanFilter, NULL, NULL, NULL, &pIes);
12202 //Release the IEs allocated by csrMatchBSS is needed
12203 if( !pResult->Result.pvIes )
12204 {
12205 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012206 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012207 }
12208 if(fMatch)
12209 {
12210 //We found the one
12211 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12212 {
12213 //Free the memory
12214 csrFreeScanResultEntry( pMac, pResult );
12215 }
12216 break;
12217 }
12218 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12219 }//while
12220 csrLLUnlock(&pMac->scan.scanResultList);
12221 }while(0);
12222 if(pScanFilter)
12223 {
12224 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012225 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012226 }
12227 }
12228 return (status);
12229}
12230
Jeff Johnson295189b2012-06-20 16:38:30 -070012231//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012232eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12233{
12234 eHalStatus status = eHAL_STATUS_SUCCESS;
12235 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012236 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12237 {
12238 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12239 {
12240 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12241 {
12242 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012243 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012244 status = eHAL_STATUS_CSR_WRONG_STATE;
12245 break;
12246 }
12247 if( csrIsConnStateInfra( pMac, sessionId ) )
12248 {
12249 if( chnId &&
12250 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12251 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012252 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012253 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12254 status = eHAL_STATUS_CSR_WRONG_STATE;
12255 break;
12256 }
12257 }
12258 }
12259 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012260 return ( status );
12261}
12262
Jeff Johnson295189b2012-06-20 16:38:30 -070012263static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12264{
12265 eHalStatus status = eHAL_STATUS_SUCCESS;
12266 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12267 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012268
12269 if(!pSession)
12270 {
12271 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12272 return eHAL_STATUS_FAILURE;
12273 }
12274
Jeff Johnson295189b2012-06-20 16:38:30 -070012275 if ( csrIsConnStateIbss( pMac, sessionId ) )
12276 {
12277 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12278 }
12279 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12280 {
12281 // Disassociate from the connected Infrastructure network...
12282 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12283 }
12284 else
12285 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012286 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12287 //Otherwise we need to add code to handle the
12288 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12289 //send stop_bss to PE, before we can continue.
12290 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012291 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012292 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012293 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12294 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012295 // there is no Bss description before we start an WDS so we need
12296 // to adopt all Bss configuration parameters from the Profile.
12297 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12298 if(HAL_STATUS_SUCCESS(status))
12299 {
12300 //Save profile for late use
12301 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012302 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12303 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012304 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012305 vos_mem_set(pSession->pCurRoamProfile,
12306 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012307 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12308 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012309 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012310 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012311 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12312 NULL, &bssConfig,
12313 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012314 }
12315 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012316
Jeff Johnson295189b2012-06-20 16:38:30 -070012317 return( status );
12318}
12319
Jeff Johnson295189b2012-06-20 16:38:30 -070012320////////////////////Mail box
12321
Jeff Johnson295189b2012-06-20 16:38:30 -070012322//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12323//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012324static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12325 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012326 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12327{
12328 tCsrChannelSet channelGroup;
12329 tSirMacCapabilityInfo *pAP_capabilityInfo;
12330 tAniBool fTmp;
12331 tANI_BOOLEAN found = FALSE;
12332 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012333 tANI_S8 pwrLimit = 0;
12334 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012335 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12336 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12337 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12338 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012339 // 802.11h
12340 //We can do this because it is in HOST CPU order for now.
12341 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012342 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12343 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12344 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012345 fTmp = (tAniBool)pal_cpu_to_be32(1);
12346 }
12347 else
12348 fTmp = (tAniBool)0;
12349
12350 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012351 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012352 pBuf += sizeof(tAniBool);
12353 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012354 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012355 // This is required for 11k test VoWiFi Ent: Test 2.
12356 // We need the power capabilities for Assoc Req.
12357 // This macro is provided by the halPhyCfg.h. We pick our
12358 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012359 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12360 if (0 != pwrLimit)
12361 {
12362 *pBuf++ = pwrLimit;
12363 }
12364 else
12365 {
12366 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12367 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012368 size = sizeof(pMac->roam.validChannelList);
12369 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12370 {
12371 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12372 for ( i = 0; i < size; i++)
12373 {
12374 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12375
12376 }
12377 }
12378 else
12379 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012380 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012381 *pBuf++ = 0; //tSirSupChnl->numChnl
12382 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012383 //Check whether it is ok to enter UAPSD
12384#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12385 if( btcIsReadyForUapsd(pMac) )
12386#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12387 {
12388 *pBuf++ = uapsdMask;
12389 }
12390#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12391 else
12392 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012393 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 *pBuf++ = 0;
12395 }
12396#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12397
Jeff Johnson295189b2012-06-20 16:38:30 -070012398 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012399 vos_mem_copy(pBuf, pBssDescription,
12400 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012401 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12402}
12403
Jeff Johnson295189b2012-06-20 16:38:30 -070012404/*
12405 * The communication between HDD and LIM is thru mailbox (MB).
12406 * Both sides will access the data structure "tSirSmeJoinReq".
12407 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12408 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12409 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12410 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12411 */
12412eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012413 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012414{
12415 eHalStatus status = eHAL_STATUS_SUCCESS;
12416 tSirSmeJoinReq *pMsg;
12417 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012418 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012419 tANI_U16 msgLen, wTmp, ieLen;
12420 tSirMacRateSet OpRateSet;
12421 tSirMacRateSet ExRateSet;
12422 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12423 tANI_U32 dwTmp;
12424 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012425 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012426
12427 if(!pSession)
12428 {
12429 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12430 return eHAL_STATUS_FAILURE;
12431 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012432 /* To satisfy klockworks */
12433 if (NULL == pBssDescription)
12434 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012435 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012436 return eHAL_STATUS_FAILURE;
12437 }
12438
Jeff Johnson295189b2012-06-20 16:38:30 -070012439 do {
12440 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12441 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012442 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012443 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12444 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12445 // IE fields, but the length field in the bssDescription needs to be interpreted to
12446 // determine length of the IE fields.
12447 //
12448 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12449 // add in the length from the bssDescription (then add the size of the 'length' field
12450 // itself because that is NOT included in the length field).
12451 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12452 pBssDescription->length + sizeof( pBssDescription->length ) +
12453 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 +053012454 pMsg = vos_mem_malloc(msgLen);
12455 if (NULL == pMsg)
12456 status = eHAL_STATUS_FAILURE;
12457 else
12458 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012459 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012460 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012461 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012462 pMsg->length = pal_cpu_to_be16(msgLen);
12463 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012464 // sessionId
12465 *pBuf = (tANI_U8)sessionId;
12466 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012467 // transactionId
12468 *pBuf = 0;
12469 *( pBuf + 1 ) = 0;
12470 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012471 // ssId
12472 if( pIes->SSID.present && pIes->SSID.num_ssid )
12473 {
12474 // ssId len
12475 *pBuf = pIes->SSID.num_ssid;
12476 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012477 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012478 pBuf += pIes->SSID.num_ssid;
12479 }
12480 else
12481 {
12482 *pBuf = 0;
12483 pBuf++;
12484 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012485 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012486 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12487 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012488 pBuf += sizeof(tSirMacAddr);
12489 // bsstype
12490 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12491 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012492 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012493 pBuf += sizeof(tSirBssType);
12494 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012495 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12496 if (pBssDescription->channelId <= 14 &&
12497 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12498 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12499 {
12500 //Need to disable VHT operation in 2.4 GHz band
12501 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12502 }
12503 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012504 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012505 //Persona
12506 *pBuf = (tANI_U8)pProfile->csrPersona;
12507 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012508 //CBMode
12509 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12510 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012511
12512 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012513 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12514
Jeff Johnson295189b2012-06-20 16:38:30 -070012515 // uapsdPerAcBitmask
12516 *pBuf = pProfile->uapsd_mask;
12517 pBuf++;
12518
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012519
12520
Jeff Johnson295189b2012-06-20 16:38:30 -070012521 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012522 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012523 {
12524 // OperationalRateSet
12525 if (OpRateSet.numRates) {
12526 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012527 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012528 pBuf += OpRateSet.numRates;
12529 } else *pBuf++ = 0;
12530 // ExtendedRateSet
12531 if (ExRateSet.numRates) {
12532 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012533 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012534 pBuf += ExRateSet.numRates;
12535 } else *pBuf++ = 0;
12536 }
12537 else
12538 {
12539 *pBuf++ = 0;
12540 *pBuf++ = 0;
12541 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012542 // rsnIE
12543 if ( csrIsProfileWpa( pProfile ) )
12544 {
12545 // Insert the Wpa IE into the join request
12546 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12547 (tCsrWpaIe *)( wpaRsnIE ) );
12548 }
12549 else if( csrIsProfileRSN( pProfile ) )
12550 {
12551 // Insert the RSN IE into the join request
12552 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12553 (tCsrRSNIe *)( wpaRsnIE ) );
12554 }
12555#ifdef FEATURE_WLAN_WAPI
12556 else if( csrIsProfileWapi( pProfile ) )
12557 {
12558 // Insert the WAPI IE into the join request
12559 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12560 (tCsrWapiIe *)( wpaRsnIE ) );
12561 }
12562#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012563 else
12564 {
12565 ieLen = 0;
12566 }
12567 //remember the IE for future use
12568 if( ieLen )
12569 {
12570 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12571 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012572 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 -070012573 ieLen = DOT11F_IE_RSN_MAX_LEN;
12574 }
12575#ifdef FEATURE_WLAN_WAPI
12576 if( csrIsProfileWapi( pProfile ) )
12577 {
12578 //Check whether we need to allocate more memory
12579 if(ieLen > pSession->nWapiReqIeLength)
12580 {
12581 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12582 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012583 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012584 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012585 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12586 if (NULL == pSession->pWapiReqIE)
12587 status = eHAL_STATUS_FAILURE;
12588 else
12589 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012590 if(!HAL_STATUS_SUCCESS(status)) break;
12591 }
12592 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012593 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012594 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012595 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012596 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012597 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012598 pBuf += ieLen;
12599 }
12600 else//should be WPA/WPA2 otherwise
12601#endif /* FEATURE_WLAN_WAPI */
12602 {
12603 //Check whether we need to allocate more memory
12604 if(ieLen > pSession->nWpaRsnReqIeLength)
12605 {
12606 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12607 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012608 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012609 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012610 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12611 if (NULL == pSession->pWpaRsnReqIE)
12612 status = eHAL_STATUS_FAILURE;
12613 else
12614 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012615 if(!HAL_STATUS_SUCCESS(status)) break;
12616 }
12617 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012618 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012619 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012620 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012621 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012622 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012623 pBuf += ieLen;
12624 }
12625 }
12626 else
12627 {
12628 //free whatever old info
12629 pSession->nWpaRsnReqIeLength = 0;
12630 if(pSession->pWpaRsnReqIE)
12631 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012632 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012633 pSession->pWpaRsnReqIE = NULL;
12634 }
12635#ifdef FEATURE_WLAN_WAPI
12636 pSession->nWapiReqIeLength = 0;
12637 if(pSession->pWapiReqIE)
12638 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012639 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012640 pSession->pWapiReqIE = NULL;
12641 }
12642#endif /* FEATURE_WLAN_WAPI */
12643 //length is two bytes
12644 *pBuf = 0;
12645 *(pBuf + 1) = 0;
12646 pBuf += 2;
12647 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012648#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012649 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012650 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012651 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012652 //length is two bytes
12653 *pBuf = 0;
12654 *(pBuf + 1) = 0;
12655 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012656 }
12657 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012658 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012659 // cckmIE
12660 if( csrIsProfileCCX( pProfile ) )
12661 {
12662 // Insert the CCKM IE into the join request
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012663#ifdef FEATURE_WLAN_CCX_UPLOAD
12664 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080012665 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012666 pSession->suppCckmIeInfo.cckmIe, ieLen);
12667#else
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012668 ieLen = csrConstructCcxCckmIe( pMac,
12669 pSession,
12670 pProfile,
12671 pBssDescription,
12672 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012673 pSession->nWpaRsnReqIeLength,
12674 (void *)( wpaRsnIE ) );
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012675#endif /* FEATURE_WLAN_CCX_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012676 }
12677 else
12678 {
12679 ieLen = 0;
12680 }
12681 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12682 if( ieLen )
12683 {
12684 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12685 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012686 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012687 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012688 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012689 pBuf += ieLen;
12690 }
12691 else
12692 {
12693 //Indicate you have no CCKM IE
12694 //length is two bytes
12695 *pBuf = 0;
12696 *(pBuf + 1) = 0;
12697 pBuf += 2;
12698 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012699 }
12700#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012701 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053012702 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070012703 {
12704 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012705 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012706 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012707 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012708 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012709 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012710 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053012711 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012712 pBuf += ieLen;
12713 }
12714 else
12715 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053012716 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012717 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012718 *pBuf = 0;
12719 *(pBuf + 1) = 0;
12720 pBuf += 2;
12721 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012722 // addIEAssoc
12723 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12724 {
12725 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012726 if(ieLen > pSession->nAddIEAssocLength)
12727 {
12728 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012729 {
12730 vos_mem_free(pSession->pAddIEAssoc);
12731 }
12732 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12733 if (NULL == pSession->pAddIEAssoc)
12734 status = eHAL_STATUS_FAILURE;
12735 else
12736 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012737 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012738 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012739 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012740 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012741 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012742 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012743 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012744 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012745 pBuf += ieLen;
12746 }
12747 else
12748 {
12749 pSession->nAddIEAssocLength = 0;
12750 if(pSession->pAddIEAssoc)
12751 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012752 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012753 pSession->pAddIEAssoc = NULL;
12754 }
12755 *pBuf = 0;
12756 *(pBuf + 1) = 0;
12757 pBuf += 2;
12758 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012759
12760 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012761 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012762 //Unmask any AC in reassoc that is ACM-set
12763 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12764 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012765 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012766 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12767 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012768#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012769 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012770#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012771 uapsd_mask &= ~(acm_mask);
12772 }
12773 else
12774 {
12775 uapsd_mask = 0;
12776 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 }
12778 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012779
Jeff Johnson295189b2012-06-20 16:38:30 -070012780 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012781 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012782 pBuf += sizeof(tANI_U32);
12783
Jeff Johnson295189b2012-06-20 16:38:30 -070012784 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012785 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012786 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012787#ifdef WLAN_FEATURE_11W
12788 //MgmtEncryption
12789 if (pProfile->MFPEnabled)
12790 {
12791 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12792 }
12793 else
12794 {
12795 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12796 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012797 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012798 pBuf += sizeof(tANI_U32);
12799#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012800#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012801 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012802 if (csrIsProfile11r( pProfile )
12803#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012804 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12805 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012806#endif
12807 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012808 {
12809 // is11Rconnection;
12810 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012811 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012812 pBuf += sizeof(tAniBool);
12813 }
12814 else
12815 {
12816 // is11Rconnection;
12817 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012818 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012819 pBuf += sizeof(tAniBool);
12820 }
12821#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012822#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012823
12824 // isCCXFeatureIniEnabled
12825 if (TRUE == pMac->roam.configParam.isCcxIniFeatureEnabled)
12826 {
12827 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012828 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012829 pBuf += sizeof(tAniBool);
12830 }
12831 else
12832 {
12833 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080012834 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012835 pBuf += sizeof(tAniBool);
12836 }
12837
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012838 /* A profile can not be both CCX and 11R. But an 802.11R AP
12839 * may be advertising support for CCX as well. So if we are
12840 * associating Open or explicitly CCX then we will get CCX.
12841 * If we are associating explictly 11R only then we will get
12842 * 11R.
12843 */
12844 if ((csrIsProfileCCX(pProfile) ||
12845 ((pIes->CCXVersion.present)
12846 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012847 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12848 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12849 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012850#ifdef WLAN_FEATURE_11W
12851 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12852#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012853 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012854 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12855 {
12856 // isCCXconnection;
12857 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012858 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012859 pBuf += sizeof(tAniBool);
12860 }
12861 else
12862 {
12863 //isCCXconnection;
12864 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012865 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012866 pBuf += sizeof(tAniBool);
12867 }
12868
12869 if (eWNI_SME_JOIN_REQ == messageType)
12870 {
12871 tCCXTspecInfo ccxTspec;
12872 // CCX-Tspec IEs in the ASSOC request is presently not supported
12873 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012874 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12875 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012876 pBuf += sizeof(tCCXTspecInfo);
12877 }
12878 else if (eWNI_SME_REASSOC_REQ == messageType)
12879 {
12880 if ((csrIsProfileCCX(pProfile) ||
12881 ((pIes->CCXVersion.present)
12882 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012883 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12884 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12885 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012886#ifdef WLAN_FEATURE_11W
12887 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12888#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012889 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012890 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012891 {
12892 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012893 // CCX Tspec information
Kiet Lam64c1b492013-07-12 13:56:44 +053012894 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012895 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12896 *pBuf = ccxTspec.numTspecs;
12897 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012898 // Copy the TSPEC information only if present
12899 if (ccxTspec.numTspecs) {
Kiet Lam64c1b492013-07-12 13:56:44 +053012900 vos_mem_copy(pBuf, (void*)&ccxTspec.tspec[0],
12901 (ccxTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070012902 }
12903 pBuf += sizeof(ccxTspec.tspec);
12904 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012905 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012906 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012907 tCCXTspecInfo ccxTspec;
12908 // CCX-Tspec IEs in the ASSOC request is presently not supported
12909 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012910 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12911 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070012912 pBuf += sizeof(tCCXTspecInfo);
12913 }
12914 }
12915#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012916#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012917 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012918 if (pMac->roam.configParam.isFastTransitionEnabled
12919#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012920 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012921#endif
12922 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012923 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012924 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012925 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012926 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012927 }
12928 else
12929 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012930 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012931 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012932 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012933 }
12934#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012935#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012936 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012937 {
12938 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012939 dwTmp = pal_cpu_to_be32(TRUE);
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 Johnson43971f52012-07-17 12:26:56 -070012942 }
12943 else
12944 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012945 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012946 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012947 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012948 }
12949#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012950
12951 // txLdpcIniFeatureEnabled
12952 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12953 pBuf++;
12954
Kiran4a17ebe2013-01-31 10:43:43 -080012955 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12956 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12957 {
12958 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12959 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12960 csrApplyPower2Current(pMac);
12961 }
12962
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012963#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012964 // txBFIniFeatureEnabled
12965 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12966 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012967
12968 // txBFCsnValue
12969 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12970 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012971#endif
krunal soni5afa96c2013-09-06 22:19:02 -070012972 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
12973 pBuf++;
12974
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053012975 // WME
12976 if(pMac->roam.roamSession[sessionId].fWMMConnection)
12977 {
12978 //WME enabled
12979 dwTmp = pal_cpu_to_be32(TRUE);
12980 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
12981 pBuf += sizeof(tAniBool);
12982 }
12983 else
12984 {
12985 dwTmp = pal_cpu_to_be32(FALSE);
12986 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
12987 pBuf += sizeof(tAniBool);
12988 }
12989
12990 // QOS
12991 if(pMac->roam.roamSession[sessionId].fQOSConnection)
12992 {
12993 //QOS enabled
12994 dwTmp = pal_cpu_to_be32(TRUE);
12995 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
12996 pBuf += sizeof(tAniBool);
12997 }
12998 else
12999 {
13000 dwTmp = pal_cpu_to_be32(FALSE);
13001 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13002 pBuf += sizeof(tAniBool);
13003 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013004 //BssDesc
13005 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13006 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013007
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013008 status = palSendMBMessage(pMac->hHdd, pMsg );
13009 if(!HAL_STATUS_SUCCESS(status))
13010 {
13011 break;
13012 }
13013 else
13014 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013015#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013016 if (eWNI_SME_JOIN_REQ == messageType)
13017 {
13018 //Tush-QoS: notify QoS module that join happening
13019 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13020 }
13021 else if (eWNI_SME_REASSOC_REQ == messageType)
13022 {
13023 //Tush-QoS: notify QoS module that reassoc happening
13024 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13025 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013026#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013027 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013028 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013029 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013030}
13031
Jeff Johnson295189b2012-06-20 16:38:30 -070013032//
13033eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13034{
13035 eHalStatus status = eHAL_STATUS_SUCCESS;
13036 tSirSmeDisassocReq *pMsg;
13037 tANI_U8 *pBuf;
13038 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013039 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13040 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13041 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013042 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013043 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13044 if (NULL == pMsg)
13045 status = eHAL_STATUS_FAILURE;
13046 else
13047 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013048 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013049 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013050 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13051 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013052 pBuf = &pMsg->sessionId;
13053 // sessionId
13054 *pBuf++ = (tANI_U8)sessionId;
13055 // transactionId
13056 *pBuf = 0;
13057 *( pBuf + 1 ) = 0;
13058 pBuf += sizeof(tANI_U16);
13059
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013060 if ( (pSession->pCurRoamProfile != NULL) &&
13061 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13062 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013063 {
13064 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013065 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13066 sizeof( tSirMacAddr ));
13067 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013068 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013069 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013070 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13071 //perMacAddr is passed as bssId for softAP
13072 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013073 pBuf = pBuf + sizeof ( tSirMacAddr );
13074 }
13075 else
13076 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013077 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013078 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13079 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013080 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013081 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13082 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013083 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013084 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013085 if(!HAL_STATUS_SUCCESS(status))
13086 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013087 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013088 break;
13089 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013090 // reasonCode
13091 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013092 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13093 status = eHAL_STATUS_SUCCESS;
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 }
13099 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013100 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13101 Here we should not send the disassoc over the air to the AP */
13102 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13103#ifdef WLAN_FEATURE_VOWIFI_11R
13104 && csrRoamIs11rAssoc(pMac)
13105#endif
13106 )
13107 {
13108 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13109 }
13110 pBuf += sizeof(tANI_U8);
13111 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013112 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013113 return( status );
13114}
Jeff Johnson295189b2012-06-20 16:38:30 -070013115eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13116{
13117 eHalStatus status = eHAL_STATUS_SUCCESS;
13118 tSirSmeTkipCntrMeasReq *pMsg;
13119 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013120 do
13121 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013122 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13123 if ( NULL == pMsg )
13124 status = eHAL_STATUS_FAILURE;
13125 else
13126 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013127 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013128 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013129 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13130 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013131 pBuf = &pMsg->sessionId;
13132 // sessionId
13133 *pBuf++ = (tANI_U8)sessionId;
13134 // transactionId
13135 *pBuf = 0;
13136 *( pBuf + 1 ) = 0;
13137 pBuf += sizeof(tANI_U16);
13138 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013139 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13140 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013141 pBuf = pBuf + sizeof ( tSirMacAddr );
13142 // bEnable
13143 *pBuf = (tANI_BOOLEAN)bEnable;
13144 if(!HAL_STATUS_SUCCESS(status))
13145 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013146 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013147 break;
13148 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013149 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013150 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013151 return( status );
13152}
Jeff Johnson295189b2012-06-20 16:38:30 -070013153eHalStatus
13154csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13155 VOS_MODULE_ID modId, tSirMacAddr bssId,
13156 void *pUsrContext, void *pfnSapEventCallback,
13157 tANI_U8 *pAssocStasBuf )
13158{
13159 eHalStatus status = eHAL_STATUS_SUCCESS;
13160 tSirSmeGetAssocSTAsReq *pMsg;
13161 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13162 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013163 do
13164 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013165 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13166 if ( NULL == pMsg )
13167 status = eHAL_STATUS_FAILURE;
13168 else
13169 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013170 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013171 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013172 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013173 pBuf = (tANI_U8 *)&pMsg->bssId;
13174 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013175 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013176 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013177 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013178 // modId
13179 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013180 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013181 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013182 // pUsrContext
13183 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013184 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013185 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013186 // pfnSapEventCallback
13187 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013188 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013189 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013190 // pAssocStasBuf
13191 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
Kiet Lam64c1b492013-07-12 13:56:44 +053013192 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013193 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013194 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013195 status = palSendMBMessage( pMac->hHdd, pMsg );
13196 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013197 return( status );
13198 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013199eHalStatus
13200csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13201 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13202 {
13203 eHalStatus status = eHAL_STATUS_SUCCESS;
13204 tSirSmeGetWPSPBCSessionsReq *pMsg;
13205 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13206 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013207 do
13208 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013209 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13210 if ( NULL == pMsg )
13211 status = eHAL_STATUS_FAILURE;
13212 else
13213 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013214 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013215 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013217 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013218 VOS_ASSERT(pBuf);
13219
Jeff Johnson295189b2012-06-20 16:38:30 -070013220 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013221 // pUsrContext
13222 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013223 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013224 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013225 // pSapEventCallback
13226 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013227 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013228 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013229 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013230 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013231 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013232 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013233 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013234 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013235 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013236 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013238 return( status );
13239}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013240
13241eHalStatus
13242csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13243{
13244 tpSirChangeBIParams pMsg;
13245 tANI_U16 len = 0;
13246 eHalStatus status = eHAL_STATUS_SUCCESS;
13247 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13248
13249 if(!pSession)
13250 {
13251 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13252 return eHAL_STATUS_FAILURE;
13253 }
13254
13255 //NO need to update the Beacon Params if update beacon parameter flag is not set
13256 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13257 return eHAL_STATUS_SUCCESS;
13258
13259 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13260
13261 /* Create the message and send to lim */
13262 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013263 pMsg = vos_mem_malloc(len);
13264 if ( NULL == pMsg )
13265 status = eHAL_STATUS_FAILURE;
13266 else
13267 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013268 if(HAL_STATUS_SUCCESS(status))
13269 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013270 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013271 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13272 pMsg->length = len;
13273
13274 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013275 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13276 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013277 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13278 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013279 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013280 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013281 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13282 status = palSendMBMessage(pMac->hHdd, pMsg);
13283 }
13284 return status;
13285}
13286
Jeff Johnson295189b2012-06-20 16:38:30 -070013287eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13288{
13289 eHalStatus status = eHAL_STATUS_SUCCESS;
13290 tSirSmeDeauthReq *pMsg;
13291 tANI_U8 *pBuf;
13292 tANI_U16 wTmp;
13293 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13294 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13295 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013296 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013297 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13298 if ( NULL == pMsg )
13299 status = eHAL_STATUS_FAILURE;
13300 else
13301 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013302 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013303 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013304 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13305 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13306 //sessionId
13307 pBuf = &pMsg->sessionId;
13308 *pBuf++ = (tANI_U8)sessionId;
13309
13310 //tansactionId
13311 *pBuf = 0;
13312 *(pBuf + 1 ) = 0;
13313 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013314 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013315 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13317 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013318 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13319 sizeof( pMsg->peerMacAddr ) );
13320 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013321 pBuf = pBuf + sizeof(tSirMacAddr);
13322 }
13323 else
13324 {
13325 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013326 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13327 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013328 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013329 }
13330 if(!HAL_STATUS_SUCCESS(status))
13331 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013332 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013333 break;
13334 }
13335 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013336 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13337 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 pBuf = pBuf + sizeof(tSirMacAddr);
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 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013345 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13346 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013347 if(!HAL_STATUS_SUCCESS(status))
13348 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013349 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013350 break;
13351 }
13352 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013353 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013354 return( status );
13355}
13356
Jeff Johnson295189b2012-06-20 16:38:30 -070013357eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13358{
13359 eHalStatus status = eHAL_STATUS_SUCCESS;
13360 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013361 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013362 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13363 if ( NULL == pMsg )
13364 status = eHAL_STATUS_FAILURE;
13365 else
13366 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013367 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013368 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013369 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13370 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13371 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013372 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13373 sizeof(pMsg->peerMacAddr));
13374 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013375 if(!HAL_STATUS_SUCCESS(status))
13376 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013377 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013378 break;
13379 }
13380//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013381 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13382 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013383 if(!HAL_STATUS_SUCCESS(status))
13384 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013385 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013386 break;
13387 }
13388//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013389 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013390 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013391 return( status );
13392}
13393
Jeff Johnson295189b2012-06-20 16:38:30 -070013394eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13395{
13396 eHalStatus status = eHAL_STATUS_SUCCESS;
13397 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013398 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013399 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13400 if ( NULL == pMsg )
13401 status = eHAL_STATUS_FAILURE;
13402 else
13403 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013404 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013405 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013406 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13407 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13408 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013409 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13410 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013411 if(!HAL_STATUS_SUCCESS(status))
13412 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013413 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013414 break;
13415 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013416 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13417 sizeof(pMsg->peerMacAddr));
13418 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013419 if(!HAL_STATUS_SUCCESS(status))
13420 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013421 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013422 break;
13423 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013424 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013425 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013426 return( status );
13427}
Jeff Johnson295189b2012-06-20 16:38:30 -070013428eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13429{
13430 eHalStatus status = eHAL_STATUS_SUCCESS;
13431 tSirSmeAssocCnf *pMsg;
13432 tANI_U8 *pBuf;
13433 tSirResultCodes statusCode;
13434 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013435 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013436 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13437 if ( NULL == pMsg )
13438 status = eHAL_STATUS_FAILURE;
13439 else
13440 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013441 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013442 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013443 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13444 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013445 pBuf = (tANI_U8 *)&pMsg->statusCode;
13446 if(HAL_STATUS_SUCCESS(Halstatus))
13447 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13448 else
13449 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013450 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013451 pBuf += sizeof(tSirResultCodes);
13452 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013453 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13454 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013455 pBuf += sizeof (tSirMacAddr);
13456 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013457 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13458 sizeof(tSirMacAddr));
13459 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013460 pBuf += sizeof (tSirMacAddr);
13461 // aid
13462 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013463 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013464 pBuf += sizeof (tANI_U16);
13465 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013466 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13467 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013468 pBuf += sizeof (tSirMacAddr);
13469 // alternateChannelId
13470 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013471 status = palSendMBMessage( pMac->hHdd, pMsg );
13472 if(!HAL_STATUS_SUCCESS(status))
13473 {
13474 //pMsg is freed by palSendMBMessage
13475 break;
13476 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013477 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013478 return( status );
13479}
Jeff Johnson295189b2012-06-20 16:38:30 -070013480eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13481 tpSirSmeAssocInd pAssocInd,
13482 eHalStatus Halstatus,
13483 tANI_U8 sessionId)
13484{
13485 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013486 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13487 tANI_U8 *pBuf;
13488 tSirResultCodes statusCode;
13489 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013490 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013491 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13492 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13493 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013494
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13496 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13497
13498 pMsg->sessionId = sessionId;
13499
13500 pBuf = (tANI_U8 *)&pMsg->statusCode;
13501 if(HAL_STATUS_SUCCESS(Halstatus))
13502 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13503 else
13504 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013505 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013506 pBuf += sizeof(tSirResultCodes);
13507 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013508 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013509 pBuf += sizeof (tSirMacAddr);
13510 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013511 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13512 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013513 pBuf += sizeof (tSirMacAddr);
13514 // StaId
13515 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013516 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013517 pBuf += sizeof (tANI_U16);
13518 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013519 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013520 pBuf += sizeof (tSirMacAddr);
13521 // alternateChannelId
13522 *pBuf = 11;
13523 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013524 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013525 //Wmm
13526 *pBuf = pAssocInd->wmmEnabledSta;
13527 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013528 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013529 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013530 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013531 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013532 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013533 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013534 //reassocReq
13535 *pBuf = pAssocInd->reassocReq;
13536 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013537 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13538 msgQ.bodyptr = pMsg;
13539 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013540 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013541 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013542 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013543}
Jeff Johnson295189b2012-06-20 16:38:30 -070013544
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013545eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13547 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13548 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13549 tANI_U8 *pKeyRsc )
13550{
13551 tSirSmeSetContextReq *pMsg;
13552 tANI_U16 msgLen;
13553 eHalStatus status = eHAL_STATUS_FAILURE;
13554 tAniEdType tmpEdType;
13555 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013556 tANI_U8 *pBuf = NULL;
13557 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013558 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013559 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013560 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013561 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13562 // key set. Since we only support upto one key, we always allocate memory for 1 key
13563 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13564 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13565 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13566 ( sizeof( pMsg->keyMaterial.key ) );
13567
Kiet Lam64c1b492013-07-12 13:56:44 +053013568 pMsg = vos_mem_malloc(msgLen);
13569 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13570 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013571 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13572 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013573 //sessionId
13574 pBuf = &pMsg->sessionId;
13575 *pBuf = (tANI_U8)sessionId;
13576 pBuf++;
13577 // transactionId
13578 *pBuf = 0;
13579 *(pBuf + 1) = 0;
13580 pBuf += sizeof(tANI_U16);
13581 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013582 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013583
13584 pBuf += sizeof(tSirMacAddr);
13585
13586 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013587 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13588 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013589
13590 pBuf += sizeof(tSirMacAddr);
13591
13592 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013593 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13594 // in the tSirKeyMaterial keyMaterial; field).
13595 //
13596 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13597 // shorter than this max size. Is LIM interpreting this ok ?
13598 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 -070013599 // set pMsg->keyMaterial.edType
13600 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013601 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013602 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013603 // set the pMsg->keyMaterial.numKeys field
13604 *p = numKeys;
13605 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013606 // set pSirKey->keyId = keyId;
13607 *p = keyId;
13608 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013609 // set pSirKey->unicast = (tANI_U8)fUnicast;
13610 *p = (tANI_U8)fUnicast;
13611 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013612 // set pSirKey->keyDirection = aniKeyDirection;
13613 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013614 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013615 p += sizeof(tAniKeyDirection);
13616 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013617 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013618 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013619 // set pSirKey->paeRole
13620 *p = paeRole; // 0 is Supplicant
13621 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013622 // set pSirKey->keyLength = keyLength;
13623 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013624 if ( keyLength && pKey )
13625 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013626 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013627 if(keyLength == 16)
13628 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013629 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 -070013630 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13631 pKey[5], pKey[6], pKey[7], pKey[8],
13632 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13633 }
13634 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013635 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013636 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013637 return( status );
13638}
13639
Jeff Johnson295189b2012-06-20 16:38:30 -070013640eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13641 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13642{
13643 eHalStatus status;
13644 tSirSmeStartBssReq *pMsg;
13645 tANI_U8 *pBuf = NULL;
13646 tANI_U8 *wTmpBuf = NULL;
13647 tANI_U16 msgLen, wTmp;
13648 tANI_U32 dwTmp;
13649 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013650 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013651 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013652 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013653
13654 if(!pSession)
13655 {
13656 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13657 return eHAL_STATUS_FAILURE;
13658 }
13659
Jeff Johnson295189b2012-06-20 16:38:30 -070013660 do {
13661 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13662 pSession->joinFailStatusCode.reasonCode = 0;
13663 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013664 pMsg = vos_mem_malloc(msgLen);
13665 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13666 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013667 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013668 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013669 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013670 //sessionId
13671 *pBuf = (tANI_U8)sessionId;
13672 pBuf++;
13673 // transactionId
13674 *pBuf = 0;
13675 *(pBuf + 1) = 0;
13676 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013677 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013678 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013679 pBuf += sizeof(tSirMacAddr);
13680 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013681 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013682 pBuf += sizeof(tSirMacAddr);
13683 // beaconInterval
13684 if( pBssDesc && pBssDesc->beaconInterval )
13685 {
13686 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13687 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013688 else if(pParam->beaconInterval)
13689 {
13690 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13691 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013692 else
13693 {
13694 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13695 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013696 if(csrIsconcurrentsessionValid (pMac, sessionId,
13697 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013698 == eHAL_STATUS_SUCCESS )
13699 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013700 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013701 pParam->bssPersona);
13702 //Update the beacon Interval
13703 pParam->beaconInterval = wTmp;
13704 }
13705 else
13706 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013707 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013708 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013709 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013710 return status;
13711 }
13712
Kiet Lam64c1b492013-07-12 13:56:44 +053013713 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013714 pBuf += sizeof(tANI_U16);
13715 // dot11mode
13716 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13717 pBuf += 1;
13718 // bssType
13719 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013720 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013721 pBuf += sizeof(tSirBssType);
13722 // ssId
13723 if( pParam->ssId.length )
13724 {
13725 // ssId len
13726 *pBuf = pParam->ssId.length;
13727 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013728 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013729 pBuf += pParam->ssId.length;
13730 }
13731 else
13732 {
13733 *pBuf = 0;
13734 pBuf++;
13735 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013736 // set the channel Id
13737 *pBuf = pParam->operationChn;
13738 pBuf++;
13739 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013740 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013741 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013742 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013743
Jeff Johnson295189b2012-06-20 16:38:30 -070013744 // Set privacy
13745 *pBuf = pParam->privacy;
13746 pBuf++;
13747
13748 //Set Uapsd
13749 *pBuf = pParam->ApUapsdEnable;
13750 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 //Set SSID hidden
13752 *pBuf = pParam->ssidHidden;
13753 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013754 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13755 pBuf++;
13756
13757 //Ht protection Enable/Disable
13758 *pBuf = (tANI_U8)pParam->protEnabled;
13759 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013760 //Enable Beacons to Receive for OBSS protection Enable/Disable
13761 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13762 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 //set cfg related to protection
13764 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013765 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013767 // Set Auth type
13768 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013769 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013770 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013771 // Set DTIM
13772 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013773 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013774 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013775 // Set wps_state
13776 *pBuf = pParam->wps_state;
13777 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080013778 // set isCoalesingInIBSSAllowed
13779 *pBuf = pMac->isCoalesingInIBSSAllowed;
13780 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013781 //Persona
13782 *pBuf = (tANI_U8)pParam->bssPersona;
13783 pBuf++;
13784
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013785 //txLdpcIniFeatureEnabled
13786 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13787 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013788
krunal soni4f087d22013-07-29 16:32:26 -070013789 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013790 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13791 {
13792 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013793 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013794 break;
13795 }
13796 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013797 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013798 pBuf += sizeof(tANI_U16);
13799 if( wTmp )
13800 {
13801 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013802 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013803 pBuf += wTmp;
13804 }
13805 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013806 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013807 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013808 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13809 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013810 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13811 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013812 pBuf += pParam->operationalRateSet.numRates ;
13813 *pBuf++ = pParam->extendedRateSet.numRates;
13814 if(0 != pParam->extendedRateSet.numRates)
13815 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013816 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13817 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013818 pBuf += pParam->extendedRateSet.numRates;
13819 }
krunal sonie9002db2013-11-25 14:24:17 -080013820
Jeff Johnson295189b2012-06-20 16:38:30 -070013821 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13822 pMsg->length = pal_cpu_to_be16(msgLen);
13823
13824 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013825 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013826 return( status );
13827}
13828
Jeff Johnson295189b2012-06-20 16:38:30 -070013829eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13830{
13831 eHalStatus status = eHAL_STATUS_FAILURE;
13832 tSirSmeStopBssReq *pMsg;
13833 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13834 tANI_U8 *pBuf;
13835 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013836
13837 if(!pSession)
13838 {
13839 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13840 return eHAL_STATUS_FAILURE;
13841 }
13842
Jeff Johnson295189b2012-06-20 16:38:30 -070013843 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013844 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13845 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13846 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013847 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13848 pBuf = &pMsg->sessionId;
13849 //sessionId
13850 *pBuf = (tANI_U8)sessionId;
13851 pBuf++;
13852 // transactionId
13853 *pBuf = 0;
13854 pBuf += sizeof(tANI_U16);
13855 //reason code
13856 *pBuf = 0;
13857 pBuf += sizeof(tSirResultCodes);
13858 // bssid
13859 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13860 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13861 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013862 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
13863 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013864 }
13865 else
13866 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013867 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13868 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013869 }
13870 pBuf += sizeof(tSirMacAddr);
13871 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13872 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013873 status = palSendMBMessage( pMac->hHdd, pMsg );
13874#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053013875 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13876 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13877 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013878 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13879 pMsg->reasonCode = 0;
13880 // bssid
13881 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13882 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13883 {
13884 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13885 }
13886 else
13887 {
13888 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13889 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013890 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013891 pMsg->transactionId = 0;
13892 pMsg->sessionId = (tANI_U8)sessionId;
13893 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13894 status = palSendMBMessage( pMac->hHdd, pMsg );
13895#endif
13896 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013897 return( status );
13898}
13899
Jeff Johnson295189b2012-06-20 16:38:30 -070013900eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13901 tCsrRoamModifyProfileFields *pModProfileFields,
13902 tANI_U32 *pRoamId, v_BOOL_t fForce)
13903{
Jeff Johnson295189b2012-06-20 16:38:30 -070013904 eHalStatus status = eHAL_STATUS_FAILURE;
13905 tANI_U32 roamId = 0;
13906 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013907 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053013908 (fForce || (!vos_mem_compare( &pModProfileFields,
13909 &pSession->connectedProfile.modifyProfileFields,
13910 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013911 {
13912 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13913 if(pRoamId)
13914 {
13915 *pRoamId = roamId;
13916 }
13917
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13919 eCsrSmeIssuedReassocToSameAP, roamId,
13920 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013921 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013922 return status;
13923}
Jeff Johnson295189b2012-06-20 16:38:30 -070013924static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13925{
13926 eHalStatus status = eHAL_STATUS_SUCCESS;
13927 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053013928 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013929 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13930 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13931 return (status);
13932}
Jeff Johnson295189b2012-06-20 16:38:30 -070013933eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13934{
13935 eHalStatus status = eHAL_STATUS_SUCCESS;
13936 tListElem *pEntry = NULL;
13937 tSmeCmd *pCommand = NULL;
13938 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013939 do
13940 {
13941 if(pMsg == NULL)
13942 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013943 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013944 status = eHAL_STATUS_FAILURE;
13945 break;
13946 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013947 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13948 if(pEntry)
13949 {
13950 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13951 if(eSmeCommandAddStaSession == pCommand->command)
13952 {
13953 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013954 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013955 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013957 //Remove this command out of the active list
13958 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13959 {
13960 //Now put this command back on the avilable command list
13961 csrReleaseCommand(pMac, pCommand);
13962 }
13963 smeProcessPendingQueue( pMac );
13964 }
13965 else
13966 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013967 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 -070013968 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013969 status = eHAL_STATUS_FAILURE;
13970 break;
13971 }
13972 }
13973 else
13974 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013975 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 -070013976 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013977 status = eHAL_STATUS_FAILURE;
13978 break;
13979 }
13980 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013981 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013982}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013983eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
13984 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070013985{
13986 tSirSmeAddStaSelfReq *pMsg;
13987 tANI_U16 msgLen;
13988 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013989 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013990 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013991 pMsg = vos_mem_malloc(msgLen);
13992 if ( NULL == pMsg ) break;
13993 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013994 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13995 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013996 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053013997 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013998 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
13999
14000 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14001
Arif Hussain24bafea2013-11-15 15:10:03 -080014002 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14003 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014004 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014005 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014006 return( status );
14007}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014008eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14009 tANI_U32 sessionId,
14010 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014011{
14012 eHalStatus status = eHAL_STATUS_SUCCESS;
14013 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014014 pCommand = csrGetCommandBuffer(pMac);
14015 if(NULL == pCommand)
14016 {
14017 status = eHAL_STATUS_RESOURCES;
14018 }
14019 else
14020 {
14021 pCommand->command = eSmeCommandAddStaSession;
14022 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014023 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14024 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014025 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014026 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14027 if( !HAL_STATUS_SUCCESS( status ) )
14028 {
14029 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014030 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014031 }
14032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014033 return (status);
14034}
Jeff Johnson295189b2012-06-20 16:38:30 -070014035eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14036{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014037 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014038}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014039eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14040 csrRoamCompleteCallback callback,
14041 void *pContext, tANI_U8 *pSelfMacAddr,
14042 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014043{
14044 eHalStatus status = eHAL_STATUS_SUCCESS;
14045 tANI_U32 i;
14046 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014047 *pbSessionId = CSR_SESSION_ID_INVALID;
14048 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14049 {
14050 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14051 {
14052 pSession = CSR_GET_SESSION( pMac, i );
14053 status = eHAL_STATUS_SUCCESS;
14054 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14055 pSession->sessionId = (tANI_U8)i;
14056 pSession->callback = callback;
14057 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014058 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014059 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014060 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14061 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014062 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014063 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014064 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014065 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014066 break;
14067 }
14068#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014069 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14070 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014071 &pSession->joinRetryTimerInfo);
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 joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014075 break;
14076 }
14077#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014078 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014079 break;
14080 }
14081 }
14082 if( CSR_ROAM_SESSION_MAX == i )
14083 {
14084 //No session is available
14085 status = eHAL_STATUS_RESOURCES;
14086 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014087 return ( status );
14088}
Jeff Johnson295189b2012-06-20 16:38:30 -070014089eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14090{
14091 eHalStatus status = eHAL_STATUS_SUCCESS;
14092 tListElem *pEntry = NULL;
14093 tSmeCmd *pCommand = NULL;
14094 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014095 do
14096 {
14097 if(pMsg == NULL)
14098 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014099 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 status = eHAL_STATUS_FAILURE;
14101 break;
14102 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014103 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14104 if(pEntry)
14105 {
14106 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14107 if(eSmeCommandDelStaSession == pCommand->command)
14108 {
14109 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014110 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014111 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014112 //This session is done.
14113 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014114 if(pCommand->u.delStaSessionCmd.callback)
14115 {
14116
14117 status = sme_ReleaseGlobalLock( &pMac->sme );
14118 if ( HAL_STATUS_SUCCESS( status ) )
14119 {
14120 pCommand->u.delStaSessionCmd.callback(
14121 pCommand->u.delStaSessionCmd.pContext);
14122 status = sme_AcquireGlobalLock( &pMac->sme );
14123 if (! HAL_STATUS_SUCCESS( status ) )
14124 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014125 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 return status;
14127 }
14128 }
14129 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014130 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014131 }
14132 }
14133
14134 //Remove this command out of the active list
14135 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14136 {
14137 //Now put this command back on the avilable command list
14138 csrReleaseCommand(pMac, pCommand);
14139 }
14140 smeProcessPendingQueue( pMac );
14141 }
14142 else
14143 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014144 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 -070014145 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014146 status = eHAL_STATUS_FAILURE;
14147 break;
14148 }
14149 }
14150 else
14151 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014152 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 -070014153 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014154 status = eHAL_STATUS_FAILURE;
14155 break;
14156 }
14157 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014158 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014159}
Jeff Johnson295189b2012-06-20 16:38:30 -070014160eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14161{
14162 tSirSmeDelStaSelfReq *pMsg;
14163 tANI_U16 msgLen;
14164 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014165 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014166 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14167 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014168 pMsg = vos_mem_malloc(msgLen);
14169 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14170 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014171 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14172 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014173 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014174 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14175 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014176 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014177 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014178 return( status );
14179}
Jeff Johnson295189b2012-06-20 16:38:30 -070014180eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14181 tSirMacAddr sessionMacAddr,
14182 csrRoamSessionCloseCallback callback,
14183 void *pContext)
14184{
14185 eHalStatus status = eHAL_STATUS_SUCCESS;
14186 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014187 pCommand = csrGetCommandBuffer(pMac);
14188 if(NULL == pCommand)
14189 {
14190 status = eHAL_STATUS_RESOURCES;
14191 }
14192 else
14193 {
14194 pCommand->command = eSmeCommandDelStaSession;
14195 pCommand->sessionId = (tANI_U8)sessionId;
14196 pCommand->u.delStaSessionCmd.callback = callback;
14197 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014198 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14199 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014200 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14201 if( !HAL_STATUS_SUCCESS( status ) )
14202 {
14203 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014204 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014205 }
14206 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014207 return (status);
14208}
Jeff Johnson295189b2012-06-20 16:38:30 -070014209eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14210{
14211 return csrSendMBDelSelfStaReqMsg( pMac,
14212 pCommand->u.delStaSessionCmd.selfMacAddr );
14213}
Jeff Johnson295189b2012-06-20 16:38:30 -070014214static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14215{
14216 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14217 tListElem *pEntry, *pNext;
14218 tSmeCmd *pCommand;
14219 tDblLinkList localList;
14220
14221 vos_mem_zero(&localList, sizeof(tDblLinkList));
14222 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14223 {
14224 smsLog(pMac, LOGE, FL(" failed to open list"));
14225 return;
14226 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014227 csrLLLock(pList);
14228 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14229 while(pEntry != NULL)
14230 {
14231 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14232 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14233 if(pCommand->sessionId == sessionId)
14234 {
14235 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14236 {
14237 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14238 }
14239 }
14240 pEntry = pNext;
14241 }
14242 csrLLUnlock(pList);
14243
14244 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14245 {
14246 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14247 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14248 }
14249 csrLLClose(&localList);
14250}
14251
Jeff Johnson295189b2012-06-20 16:38:30 -070014252void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14253{
14254 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14255 {
14256 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014257 csrRoamStop(pMac, sessionId);
14258 csrFreeConnectBssDesc(pMac, sessionId);
14259 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14260 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014261 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014262#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014263 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014264#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014265 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14266 if (pMac->fScanOffload)
14267 {
14268 purgeSmeSessionCmdList(pMac, sessionId,
14269 &pMac->sme.smeScanCmdPendingList);
14270 }
14271
Jeff Johnson295189b2012-06-20 16:38:30 -070014272 purgeCsrSessionCmdList(pMac, sessionId);
14273 csrInitSession(pMac, sessionId);
14274 }
14275}
14276
Jeff Johnson295189b2012-06-20 16:38:30 -070014277eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14278 tANI_BOOLEAN fSync,
14279 csrRoamSessionCloseCallback callback,
14280 void *pContext )
14281{
14282 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014283 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14284 {
14285 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14286 if(fSync)
14287 {
14288 csrCleanupSession(pMac, sessionId);
14289 }
14290 else
14291 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014292 purgeSmeSessionCmdList(pMac, sessionId,
14293 &pMac->sme.smeCmdPendingList);
14294 if (pMac->fScanOffload)
14295 {
14296 purgeSmeSessionCmdList(pMac, sessionId,
14297 &pMac->sme.smeScanCmdPendingList);
14298 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014299 purgeCsrSessionCmdList(pMac, sessionId);
14300 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14301 pSession->selfMacAddr, callback, pContext);
14302 }
14303 }
14304 else
14305 {
14306 status = eHAL_STATUS_INVALID_PARAMETER;
14307 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014308 return ( status );
14309}
14310
Jeff Johnson295189b2012-06-20 16:38:30 -070014311static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14312{
14313 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014314
14315 if(!pSession)
14316 {
14317 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14318 return;
14319 }
14320
Jeff Johnson295189b2012-06-20 16:38:30 -070014321 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14322 pSession->sessionId = CSR_SESSION_ID_INVALID;
14323 pSession->callback = NULL;
14324 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014325 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14326 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14327 csrFreeRoamProfile( pMac, sessionId );
14328 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14329 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14330 csrFreeConnectBssDesc(pMac, sessionId);
14331 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014332 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14333 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014334 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014335 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014336 pSession->pWpaRsnReqIE = NULL;
14337 }
14338 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014339 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014340 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014341 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014342 pSession->pWpaRsnRspIE = NULL;
14343 }
14344 pSession->nWpaRsnRspIeLength = 0;
14345#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014346 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014347 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014348 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014349 pSession->pWapiReqIE = NULL;
14350 }
14351 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014352 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014353 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014354 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014355 pSession->pWapiRspIE = NULL;
14356 }
14357 pSession->nWapiRspIeLength = 0;
14358#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014359 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014360 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014361 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014362 }
14363 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014364
Kiet Lam64c1b492013-07-12 13:56:44 +053014365 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014366 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014367 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014368 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014369 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014370 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014371}
14372
Jeff Johnson295189b2012-06-20 16:38:30 -070014373eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14374{
14375 eHalStatus status = eHAL_STATUS_FAILURE;
14376 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014377 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14378 {
14379 if( CSR_IS_SESSION_VALID( pMac, i ) )
14380 {
14381 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14382 {
14383 //Found it
14384 status = eHAL_STATUS_SUCCESS;
14385 *pSessionId = i;
14386 break;
14387 }
14388 }
14389 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014390 return( status );
14391}
14392
Jeff Johnson295189b2012-06-20 16:38:30 -070014393//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14394//session because for IBSS, the bssid changes.
14395static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14396{
14397 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14398 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014399 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14400 {
14401 if( CSR_IS_SESSION_VALID( pMac, i ) )
14402 {
14403 pSession = CSR_GET_SESSION( pMac, i );
14404 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14405 {
14406 //Found it
14407 nRet = i;
14408 break;
14409 }
14410 }
14411 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014412 return (nRet);
14413}
Jeff Johnson295189b2012-06-20 16:38:30 -070014414static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14415{
14416 /* Update the current BSS info in ho control block based on connected
14417 profile info from pmac global structure */
14418
Arif Hussain24bafea2013-11-15 15:10:03 -080014419 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14420 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014421 /* Check for user misconfig of RSSI trigger threshold */
14422 pMac->roam.configParam.vccRssiThreshold =
14423 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14424 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14425 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014426 /* Check for user misconfig of UL MAC Loss trigger threshold */
14427 pMac->roam.configParam.vccUlMacLossThreshold =
14428 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14429 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014430#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14431 {
14432 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014433 /* Indicate the neighbor roal algorithm about the connect indication */
14434 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14435 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14436 }
14437#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014438}
14439
Jeff Johnson295189b2012-06-20 16:38:30 -070014440static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14441{
14442 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014443
14444 if(!pSession)
14445 {
14446 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14447 return;
14448 }
14449
Jeff Johnson295189b2012-06-20 16:38:30 -070014450 //Only to handle the case for Handover on infra link
14451 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14452 {
14453 return;
14454 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014455 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14456 csrRoamDeregStatisticsReq(pMac);
14457 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14458#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14459 /* Indicate the neighbor roal algorithm about the disconnect indication */
14460 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14461#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014462
14463 //Remove this code once SLM_Sessionization is supported
14464 //BMPS_WORKAROUND_NOT_NEEDED
14465 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014466 csrIsInfraApStarted( pMac ) &&
14467 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014468 {
14469 pMac->roam.configParam.doBMPSWorkaround = 0;
14470 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014471}
14472
Jeff Johnson295189b2012-06-20 16:38:30 -070014473void csrRoamTlStatsTimerHandler(void *pv)
14474{
14475 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14476 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014477 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14478
Jeff Johnsone7245742012-09-05 17:12:55 -070014479 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14480
Jeff Johnson295189b2012-06-20 16:38:30 -070014481#if 0
14482 // TODO Persession .???
14483 //req TL for stats
14484 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14485 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014486 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014487 }
14488 else
14489 {
14490 //save in SME
14491 csrRoamSaveStatsFromTl(pMac, tlStats);
14492 }
14493#endif
14494 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14495 {
14496 if(pMac->roam.tlStatsReqInfo.periodicity)
14497 {
14498 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014499 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14500 pMac->roam.tlStatsReqInfo.periodicity);
14501 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014502 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014503 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014504 return;
14505 }
14506 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14507 }
14508 }
14509}
Jeff Johnson295189b2012-06-20 16:38:30 -070014510void csrRoamPeStatsTimerHandler(void *pv)
14511{
14512 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14513 eHalStatus status;
14514 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14515 VOS_STATUS vosStatus;
14516 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014517 pPeStatsReqListEntry->timerRunning = FALSE;
14518 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14519 {
14520 // If we entered here, meaning the timer could not be successfully
14521 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14522
14523 /* Destroy the timer */
14524 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14525 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14526 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014527 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014528 }
14529
14530 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014531 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014532 pPeStatsReqListEntry = NULL;
14533 }
14534 else
14535 {
14536 if(!pPeStatsReqListEntry->rspPending)
14537 {
14538 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14539 pPeStatsReqListEntry->staId);
14540 if(!HAL_STATUS_SUCCESS(status))
14541 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014542 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014543 }
14544 else
14545 {
14546 pPeStatsReqListEntry->rspPending = TRUE;
14547 }
14548 }
14549
14550 //send down a req
14551 if(pPeStatsReqListEntry->periodicity &&
14552 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14553 {
14554 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14555 if(ePMC_FULL_POWER == powerState)
14556 {
14557 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14558 {
14559 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14560 }
14561 }
14562 else
14563 {
14564 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14565 {
14566 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14567 }
14568 }
14569 //start timer
14570 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14571 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14572 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014573 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014574 return;
14575 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014576 pPeStatsReqListEntry->timerRunning = TRUE;
14577
14578 }
14579
14580 }
14581}
Jeff Johnson295189b2012-06-20 16:38:30 -070014582void csrRoamStatsClientTimerHandler(void *pv)
14583{
14584 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014585 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14586 {
14587#if 0
14588 // TODO Stats fix for multisession
14589 //start the timer
14590 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14591
14592 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014594 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014595 }
14596#endif
14597 }
14598#if 0
14599 //send up the stats report
14600 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14601 pStaEntry->staId, pStaEntry->pContext);
14602#endif
14603}
14604
14605
14606
Jeff Johnson295189b2012-06-20 16:38:30 -070014607eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14608{
14609 tAniGetPEStatsReq *pMsg;
14610 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014611 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14612 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014613 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014614 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053014615 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014616 }
14617 // need to initiate a stats request to PE
14618 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14619 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14620 pMsg->staId = staId;
14621 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014622 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014623 if(!HAL_STATUS_SUCCESS(status))
14624 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014625 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070014626 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014627 return status;
14628}
Jeff Johnson295189b2012-06-20 16:38:30 -070014629void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14630{
14631 tAniGetPEStatsRsp *pSmeStatsRsp;
14632 eHalStatus status = eHAL_STATUS_FAILURE;
14633 tListElem *pEntry = NULL;
14634 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14635 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14636 tANI_U32 tempMask = 0;
14637 tANI_U8 counter = 0;
14638 tANI_U8 *pStats = NULL;
14639 tANI_U32 length = 0;
14640 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014641 v_S7_t rssi = 0, snr = 0;
14642 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014643 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014644 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14645 if(pSmeStatsRsp->rc)
14646 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014647 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014648 goto post_update;
14649 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014650 tempMask = pSmeStatsRsp->statsMask;
14651 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014652 /* subtract all statistics from this length, and after processing the entire
14653 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14654 * in this 'stats' message.
14655 */
14656 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014657 //new stats info from PE, fill up the stats strucutres in PMAC
14658 while(tempMask)
14659 {
14660 if(tempMask & 1)
14661 {
14662 switch(counter)
14663 {
14664 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014665 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014666 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14667 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014668 pStats += sizeof(tCsrSummaryStatsInfo);
14669 length -= sizeof(tCsrSummaryStatsInfo);
14670 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014671 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014672 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014673 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14674 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014675 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14676 length -= sizeof(tCsrGlobalClassAStatsInfo);
14677 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014678 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014679 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014680 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14681 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014682 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14683 length -= sizeof(tCsrGlobalClassBStatsInfo);
14684 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014685 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014686 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014687 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14688 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014689 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14690 length -= sizeof(tCsrGlobalClassCStatsInfo);
14691 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014692 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014693 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014694 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14695 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014696 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14697 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014698 }
14699 else
14700 {
14701 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014702 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014703 VOS_ASSERT( 0 );
14704 }
14705 if(!HAL_STATUS_SUCCESS(status))
14706 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014707 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014708 }
14709 pStats += sizeof(tCsrPerStaStatsInfo);
14710 length -= sizeof(tCsrPerStaStatsInfo);
14711 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014712 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014713 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014714 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014715 }
14716 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014717 tempMask >>=1;
14718 counter++;
14719 }
14720 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14721 if (length != 0)
14722 {
14723 pRssi = (tANI_U32*)pStats;
14724 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014725 pStats += sizeof(tANI_U32);
14726 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014727 }
14728 else
14729 {
14730 /* If riva is not sending rssi, continue to use the hack */
14731 rssi = RSSI_HACK_BMPS;
14732 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014733
Jeff Johnson295189b2012-06-20 16:38:30 -070014734 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014735
14736 if (length != 0)
14737 {
14738 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014739 pStats += sizeof(tANI_U32);
14740 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014741 }
14742 else
14743 {
14744 linkCapacity = 0;
14745 }
14746
14747 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014748
14749 if (length != 0)
14750 {
14751 pSnr = (tANI_U32*)pStats;
14752 snr = (v_S7_t)*pSnr;
14753 }
14754 else
14755 {
14756 snr = SNR_HACK_BMPS;
14757 }
14758
14759 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014760post_update:
14761 //make sure to update the pe stats req list
14762 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14763 if(pEntry)
14764 {
14765 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14766 pPeStaEntry->rspPending = FALSE;
14767
14768 }
14769 //check the one timer cases
14770 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14771 if(pEntry)
14772 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014773 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014774 if(pTempStaEntry->timerExpired)
14775 {
14776 //send up the stats report
14777 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14778 pTempStaEntry->staId, pTempStaEntry->pContext);
14779 //also remove from the client list
14780 csrRoamRemoveStatListEntry(pMac, pEntry);
14781 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014782 }
14783 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014784}
Jeff Johnson295189b2012-06-20 16:38:30 -070014785tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14786{
14787 tListElem *pEntry = NULL;
14788 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014789 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014790 if(!pEntry)
14791 {
14792 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014793 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014794 return NULL;
14795 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014796 while( pEntry )
14797 {
14798 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014799 if(pTempStaEntry->statsMask == statsMask)
14800 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014801 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014802 break;
14803 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014804 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14805 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014806 return pEntry;
14807}
14808
Jeff Johnson295189b2012-06-20 16:38:30 -070014809tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14810 tANI_BOOLEAN update)
14811{
14812 tListElem *pEntry;
14813 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014814 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014815 if(!pEntry)
14816 {
14817 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014818 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014819 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014820 return NULL;
14821 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014822 while( pEntry )
14823 {
14824 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014825 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14826 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14827 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014828 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014829 if(update)
14830 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014831 pTempStaEntry->periodicity = pStaEntry->periodicity;
14832 pTempStaEntry->callback = pStaEntry->callback;
14833 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014834 }
14835 break;
14836 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014837 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14838 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014839 return pEntry;
14840}
Jeff Johnson295189b2012-06-20 16:38:30 -070014841tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14842{
14843 tListElem *pEntry;
14844 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014845 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014846 if(!pEntry)
14847 {
14848 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014849 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014850 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014851 return NULL;
14852 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014853 while( pEntry )
14854 {
14855 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014856 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14857 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014858 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014859 break;
14860 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014861 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14862 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014863 return pEntry;
14864}
Jeff Johnson295189b2012-06-20 16:38:30 -070014865eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14866 csrRoamLinkQualityIndCallback callback,
14867 void *pContext)
14868{
14869 pMac->roam.linkQualityIndInfo.callback = callback;
14870 pMac->roam.linkQualityIndInfo.context = pContext;
14871 if( NULL == callback )
14872 {
14873 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14874 }
14875 else
14876 {
14877 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014878 /* do we need to invoke the callback to notify client of initial value ?? */
14879 }
14880 return eHAL_STATUS_SUCCESS;
14881}
Jeff Johnson295189b2012-06-20 16:38:30 -070014882void csrRoamVccTrigger(tpAniSirGlobal pMac)
14883{
14884 eCsrRoamLinkQualityInd newVccLinkQuality;
14885 tANI_U32 ul_mac_loss = 0;
14886 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014887 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14888 /*-------------------------------------------------------------------------
14889 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014890 Check for a change in link quality and notify client if necessary
14891 -------------------------------------------------------------------------*/
14892 ul_mac_loss_trigger_threshold =
14893 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014894 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014895 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014896 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014897 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14898 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014899 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014900 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14901 }
14902 else
14903 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014904 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014905 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14906 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014907 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14908 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014909 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14910 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014911 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014912 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14913 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014914 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014915 newVccLinkQuality );
14916
14917 /* we now invoke the callback once to notify client of initial value */
14918 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14919 pMac->roam.linkQualityIndInfo.context );
14920 //event: EVENT_WLAN_VCC
14921 }
14922 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014923 pMac->roam.vccLinkQuality = newVccLinkQuality;
14924
Jeff Johnson295189b2012-06-20 16:38:30 -070014925}
Jeff Johnson295189b2012-06-20 16:38:30 -070014926VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14927 v_U8_t rssiNotification,
14928 void * context)
14929{
14930 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14931 eCsrRoamLinkQualityInd newVccLinkQuality;
14932 // TODO : Session info unavailable
14933 tANI_U32 sessionId = 0;
14934 VOS_STATUS status = VOS_STATUS_SUCCESS;
14935 /*-------------------------------------------------------------------------
14936 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014937 Check for a change in link quality and notify client if necessary
14938 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014939 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014940 pMac->roam.configParam.vccRssiThreshold);
14941 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14942 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014943 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014944 return VOS_STATUS_SUCCESS;
14945 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014946 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14947 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014948 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014949 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14950 }
14951 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14952 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014953 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014954 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14955 }
14956 else
14957 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014958 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014959 //Set to this so the code below won't do anything
14960 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014961 VOS_ASSERT(0);
14962 }
14963
Jeff Johnson295189b2012-06-20 16:38:30 -070014964 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14965 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014966 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014967 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14968 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014969 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014970 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014971 /* we now invoke the callback once to notify client of initial value */
14972 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14973 pMac->roam.linkQualityIndInfo.context );
14974 //event: EVENT_WLAN_VCC
14975 }
14976 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014977 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014978 return status;
14979}
Jeff Johnson295189b2012-06-20 16:38:30 -070014980tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14981 tDblLinkList *pStaList,
14982 tCsrStatsClientReqInfo *pStaEntry)
14983{
14984 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014985 //if same entity requested for same set of stats with different periodicity &
14986 // callback update it
14987 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14988 {
14989
Kiet Lam64c1b492013-07-12 13:56:44 +053014990 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
14991 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014992 {
14993 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014994 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014995 return NULL;
14996 }
14997
Jeff Johnson295189b2012-06-20 16:38:30 -070014998 pNewStaEntry->callback = pStaEntry->callback;
14999 pNewStaEntry->pContext = pStaEntry->pContext;
15000 pNewStaEntry->periodicity = pStaEntry->periodicity;
15001 pNewStaEntry->requesterId = pStaEntry->requesterId;
15002 pNewStaEntry->statsMask = pStaEntry->statsMask;
15003 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15004 pNewStaEntry->pMac = pStaEntry->pMac;
15005 pNewStaEntry->staId = pStaEntry->staId;
15006 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15007
15008 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15009 }
15010 return pNewStaEntry;
15011}
15012
Jeff Johnson295189b2012-06-20 16:38:30 -070015013tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15014 tDblLinkList *pStaList,
15015 tCsrPeStatsReqInfo *pStaEntry)
15016{
15017 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015018 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15019 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015020 {
15021 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015022 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015023 return NULL;
15024 }
15025
Jeff Johnson295189b2012-06-20 16:38:30 -070015026 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15027 pNewStaEntry->numClient = pStaEntry->numClient;
15028 pNewStaEntry->periodicity = pStaEntry->periodicity;
15029 pNewStaEntry->statsMask = pStaEntry->statsMask;
15030 pNewStaEntry->pMac = pStaEntry->pMac;
15031 pNewStaEntry->staId = pStaEntry->staId;
15032 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15033 pNewStaEntry->rspPending = pStaEntry->rspPending;
15034
15035 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015036 return pNewStaEntry;
15037}
Jeff Johnson295189b2012-06-20 16:38:30 -070015038eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15039 tCsrRssiCallback callback,
15040 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15041{
15042 eHalStatus status = eHAL_STATUS_SUCCESS;
15043 vos_msg_t msg;
15044 tANI_U32 sessionId;
15045
15046 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015047 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015048 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15049 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015050 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015051 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015052 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015053 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015054 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15055
15056 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15057 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15058 pMsg->sessionId = sessionId;
15059 pMsg->staId = staId;
15060 pMsg->rssiCallback = callback;
15061 pMsg->pDevContext = pContext;
15062 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015063 msg.type = eWNI_SME_GET_RSSI_REQ;
15064 msg.bodyptr = pMsg;
15065 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015066 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15067 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015068 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015069 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015070 status = eHAL_STATUS_FAILURE;
15071 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015072 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015073 return status;
15074}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015075
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015076eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15077 tCsrSnrCallback callback,
15078 tANI_U8 staId, tCsrBssid bssId,
15079 void *pContext)
15080{
15081 eHalStatus status = eHAL_STATUS_SUCCESS;
15082 vos_msg_t msg;
15083 tANI_U32 sessionId;
15084
15085 tAniGetSnrReq *pMsg;
15086
15087 smsLog(pMac, LOG2, FL("called"));
15088
15089 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15090 if (NULL == pMsg )
15091 {
15092 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15093 return status;
15094 }
15095
15096 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15097
15098 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15099 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15100 pMsg->sessionId = sessionId;
15101 pMsg->staId = staId;
15102 pMsg->snrCallback = callback;
15103 pMsg->pDevContext = pContext;
15104 msg.type = eWNI_SME_GET_SNR_REQ;
15105 msg.bodyptr = pMsg;
15106 msg.reserved = 0;
15107
15108 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15109 {
15110 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15111 vos_mem_free((v_VOID_t *)pMsg);
15112 status = eHAL_STATUS_FAILURE;
15113 }
15114
15115 smsLog(pMac, LOG2, FL("returned"));
15116 return status;
15117}
15118
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015119#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
15120eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15121 tCsrRssiCallback callback,
15122 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15123{
15124 eHalStatus status = eHAL_STATUS_SUCCESS;
15125 tAniGetRssiReq *pMsg;
15126
Kiet Lam64c1b492013-07-12 13:56:44 +053015127 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15128 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015129 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015130 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015131 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015132 }
15133 // need to initiate a stats request to PE
15134 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15135 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15136 pMsg->staId = staId;
15137 pMsg->rssiCallback = callback;
15138 pMsg->pDevContext = pContext;
15139 pMsg->pVosContext = pVosContext;
15140 status = palSendMBMessage(pMac->hHdd, pMsg );
15141 if(!HAL_STATUS_SUCCESS(status))
15142 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015143 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015144 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015145 status = eHAL_STATUS_FAILURE;
15146 }
15147 return status;
15148}
15149#endif
15150
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015151
15152
15153#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
15154eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15155 tCsrTsmStatsCallback callback,
15156 tANI_U8 staId,
15157 tCsrBssid bssId,
15158 void *pContext,
15159 void* pVosContext,
15160 tANI_U8 tid)
15161{
15162 eHalStatus status = eHAL_STATUS_SUCCESS;
15163 tAniGetTsmStatsReq *pMsg = NULL;
15164
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015165 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15166 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015167 {
15168 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015169 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015170 }
15171 // need to initiate a stats request to PE
15172 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15173 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15174 pMsg->staId = staId;
15175 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015176 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015177 pMsg->tsmStatsCallback = callback;
15178 pMsg->pDevContext = pContext;
15179 pMsg->pVosContext = pVosContext;
15180 status = palSendMBMessage(pMac->hHdd, pMsg );
15181 if(!HAL_STATUS_SUCCESS(status))
15182 {
15183 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15184 //pMsg is freed by palSendMBMessage
15185 status = eHAL_STATUS_FAILURE;
15186 }
15187 return status;
15188}
15189#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
15190
15191
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015192/* ---------------------------------------------------------------------------
15193 \fn csrGetTLSTAState
15194 \helper function to get teh TL STA State whenever the function is called.
15195
15196 \param staId - The staID to be passed to the TL
15197 to get the relevant TL STA State
15198 \return the state as tANI_U16
15199 ---------------------------------------------------------------------------*/
15200tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15201{
15202 WLANTL_STAStateType tlSTAState;
15203 tlSTAState = WLANTL_STA_INIT;
15204
15205 //request TL for STA State
15206 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15207 {
15208 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15209 }
15210
15211 return tlSTAState;
15212}
15213
Jeff Johnson295189b2012-06-20 16:38:30 -070015214eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15215 tANI_U32 statsMask,
15216 tCsrStatsCallback callback,
15217 tANI_U32 periodicity, tANI_BOOLEAN cache,
15218 tANI_U8 staId, void *pContext)
15219{
15220 tCsrStatsClientReqInfo staEntry;
15221 tCsrStatsClientReqInfo *pStaEntry = NULL;
15222 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15223 tListElem *pEntry = NULL;
15224 tANI_BOOLEAN found = FALSE;
15225 eHalStatus status = eHAL_STATUS_SUCCESS;
15226 tANI_BOOLEAN insertInClientList = FALSE;
15227 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015228 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015229
15230 if( csrIsAllSessionDisconnected(pMac) )
15231 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015232 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015233 return eHAL_STATUS_FAILURE;
15234 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015235 if((!statsMask) && (!callback))
15236 {
15237 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015238 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015239 return eHAL_STATUS_FAILURE;
15240 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015241 //for the search list method for deregister
15242 staEntry.requesterId = requesterId;
15243 staEntry.statsMask = statsMask;
15244 //requester wants to deregister or just an error
15245 if((statsMask) && (!callback))
15246 {
15247 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15248 if(!pEntry)
15249 {
15250 //msg
15251 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015252 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015253 return eHAL_STATUS_FAILURE;
15254 }
15255 else
15256 {
15257 //clean up & return
15258 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015259 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015260 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015261 pStaEntry->pPeStaEntry->numClient--;
15262 //check if we need to delete the entry from peStatsReqList too
15263 if(!pStaEntry->pPeStaEntry->numClient)
15264 {
15265 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15266 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015267 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015268
Jeff Johnson295189b2012-06-20 16:38:30 -070015269 //check if we need to stop the tl stats timer too
15270 pMac->roam.tlStatsReqInfo.numClient--;
15271 if(!pMac->roam.tlStatsReqInfo.numClient)
15272 {
15273 if(pMac->roam.tlStatsReqInfo.timerRunning)
15274 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015275 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15276 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015277 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015278 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015279 return eHAL_STATUS_FAILURE;
15280 }
15281 }
15282 pMac->roam.tlStatsReqInfo.periodicity = 0;
15283 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15284 }
15285 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015286 // Destroy the vos timer...
15287 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15288 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15289 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015290 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015291 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015292 csrRoamRemoveStatListEntry(pMac, pEntry);
15293 pStaEntry = NULL;
15294 return eHAL_STATUS_SUCCESS;
15295 }
15296 }
15297
15298 if(cache && !periodicity)
15299 {
15300 //return the cached stats
15301 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15302 }
15303 else
15304 {
15305 //add the request in the client req list
15306 staEntry.callback = callback;
15307 staEntry.pContext = pContext;
15308 staEntry.periodicity = periodicity;
15309 staEntry.pPeStaEntry = NULL;
15310 staEntry.staId = staId;
15311 staEntry.pMac = pMac;
15312 staEntry.timerExpired = FALSE;
15313
15314
Jeff Johnson295189b2012-06-20 16:38:30 -070015315 //if periodic report requested with non cached result from PE/TL
15316 if(periodicity)
15317 {
15318
15319 //if looking for stats from PE
15320 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15321 {
15322
15323 //check if same request made already & waiting for rsp
15324 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15325 periodicity, &found, staId);
15326 if(!pPeStaEntry)
15327 {
15328 //bail out, maxed out on number of req for PE
15329 return eHAL_STATUS_FAILURE;
15330 }
15331 else
15332 {
15333 staEntry.pPeStaEntry = pPeStaEntry;
15334 }
15335
15336 }
15337 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15338 if(statsMask & (1 << eCsrGlobalClassDStats))
15339 {
15340 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15341 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015342 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015343 }
15344 else
15345 {
15346
15347 //update periodicity
15348 if(pMac->roam.tlStatsReqInfo.periodicity)
15349 {
15350 pMac->roam.tlStatsReqInfo.periodicity =
15351 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15352 }
15353 else
15354 {
15355 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15356 }
15357 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15358 {
15359 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15360 }
15361
15362 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15363 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015364 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015365 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015366 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015367 //req TL for class D stats
15368 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15369 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015370 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015371 }
15372 else
15373 {
15374 //save in SME
15375 csrRoamSaveStatsFromTl(pMac, pTlStats);
15376 }
15377 vos_mem_free(pTlStats);
15378 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015379 }
15380 else
15381 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015382 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015383 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015384
Jeff Johnson295189b2012-06-20 16:38:30 -070015385 if(pMac->roam.tlStatsReqInfo.periodicity)
15386 {
15387 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015388 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15389 pMac->roam.tlStatsReqInfo.periodicity);
15390 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015391 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015392 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015393 return eHAL_STATUS_FAILURE;
15394 }
15395 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15396 }
15397 }
15398 }
15399 pMac->roam.tlStatsReqInfo.numClient++;
15400 }
15401
15402 insertInClientList = TRUE;
15403 }
15404 //if one time report requested with non cached result from PE/TL
15405 else if(!cache && !periodicity)
15406 {
15407 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15408 {
15409 //send down a req
15410 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15411 if(!HAL_STATUS_SUCCESS(status))
15412 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015413 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015414 }
15415 //so that when the stats rsp comes back from PE we respond to upper layer
15416 //right away
15417 staEntry.timerExpired = TRUE;
15418 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015419 }
15420 if(statsMask & (1 << eCsrGlobalClassDStats))
15421 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015422 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015423 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015424 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015425 //req TL for class D stats
15426 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15427 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015428 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015429 }
15430 else
15431 {
15432 //save in SME
15433 csrRoamSaveStatsFromTl(pMac, pTlStats);
15434 }
15435 vos_mem_free(pTlStats);
15436 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015437 }
15438 else
15439 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015440 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015441 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015442
15443 }
15444 //if looking for stats from TL only
15445 if(!insertInClientList)
15446 {
15447 //return the stats
15448 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15449 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015450 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015451 if(insertInClientList)
15452 {
15453 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15454 if(!pStaEntry)
15455 {
15456 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015457 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015458 return eHAL_STATUS_FAILURE;
15459 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015460 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015461 //Init & start timer if needed
15462 if(periodicity)
15463 {
15464 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15465 csrRoamStatsClientTimerHandler, pStaEntry );
15466 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15467 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015468 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015469 return eHAL_STATUS_FAILURE;
15470 }
15471 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15472 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15473 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015474 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015475 return eHAL_STATUS_FAILURE;
15476 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015477 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015478 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015479 }
15480 return eHAL_STATUS_SUCCESS;
15481}
15482
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015483#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15484
15485static tSirRetStatus
15486csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15487 tANI_U8* pBD,
15488 tANI_U8 type,
15489 tANI_U8 subType,
15490 tSirMacAddr peerAddr,
15491 tSirMacAddr selfMacAddr)
15492{
15493 tSirRetStatus statusCode = eSIR_SUCCESS;
15494 tpSirMacMgmtHdr pMacHdr;
15495
15496 /* Prepare MAC management header */
15497 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15498
15499 /* Prepare FC */
15500 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15501 pMacHdr->fc.type = type;
15502 pMacHdr->fc.subType = subType;
15503
15504 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015505 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15506 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015507
15508 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15509
15510 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015511 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15512 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015513 return statusCode;
15514} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15515
15516static tSirRetStatus
15517csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15518 tANI_U8 nChannelNum,
15519 tANI_U32 dot11mode,
15520 tSirMacAddr selfMacAddr,
15521 tANI_U8 *pFrame,
15522 tANI_U16 *pusLen)
15523{
15524 tDot11fProbeRequest pr;
15525 tANI_U32 nStatus, nBytes, nPayload;
15526 tSirRetStatus nSirStatus;
15527 /*Bcast tx*/
15528 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15529 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15530
15531
Kiet Lam64c1b492013-07-12 13:56:44 +053015532 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015533
15534 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15535
15536 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15537 {
15538 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15539 }
15540
15541
15542 if (IS_DOT11_MODE_HT(dot11mode))
15543 {
15544 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15545 }
15546
15547
15548 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15549 if ( DOT11F_FAILED( nStatus ) )
15550 {
15551 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15552 "Failed to calculate the packed size f"
15553 "or a Probe Request (0x%08x).\n", nStatus );
15554
15555
15556 nPayload = sizeof( tDot11fProbeRequest );
15557 }
15558 else if ( DOT11F_WARNED( nStatus ) )
15559 {
15560 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15561 "There were warnings while calculating"
15562 "the packed size for a Probe Request ("
15563 "0x%08x).\n", nStatus );
15564 }
15565
15566 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15567
15568 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015569 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015570
15571
15572 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015573 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015574
15575 if ( eSIR_SUCCESS != nSirStatus )
15576 {
15577 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15578 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15579 nSirStatus );
15580 return nSirStatus;
15581 }
15582
15583
15584 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15585 sizeof( tSirMacMgmtHdr ),
15586 nPayload, &nPayload );
15587 if ( DOT11F_FAILED( nStatus ) )
15588 {
15589 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15590 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15591 return eSIR_FAILURE;
15592 }
15593 else if ( DOT11F_WARNED( nStatus ) )
15594 {
15595 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015596 "There were warnings while packing a Probe Request (0x%08x).\n",
15597 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015598 }
15599
15600 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15601 return eSIR_SUCCESS;
15602}
15603
15604eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15605{
15606 vos_msg_t msg;
15607 tSirRoamOffloadScanReq *pRequestBuf;
15608 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15609 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015610 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015611 tANI_U8 *ChannelList = NULL;
15612 tANI_U32 sessionId;
15613 eHalStatus status = eHAL_STATUS_SUCCESS;
15614 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015615 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015616 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015617 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015618 tSirBssDescription *pBssDesc = NULL;
15619 tDot11fBeaconIEs *pIes = NULL;
15620 tANI_U8 minRate = 0, dataRate;
15621 tANI_U8 operationChannel;
15622
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015623 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15624
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015625 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015626 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015627 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015628 return eHAL_STATUS_FAILURE;
15629 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015630
15631 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15632 {
15633 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15634 return eHAL_STATUS_FAILURE;
15635 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015636 status = csrRoamGetSessionIdFromBSSID(pMac,
15637 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15638 &sessionId);
15639 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15640 * It is important to ensure that the command is passed down to the FW only
15641 * if the Infra Station is in a connected state.A connected station could also be
15642 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15643 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15644 * irrespective of whichever state we are in.*/
15645 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15646 (command != ROAM_SCAN_OFFLOAD_STOP))
15647 {
15648 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
15649 pMac->roam.neighborRoamInfo.neighborRoamState, command);
15650 return eHAL_STATUS_FAILURE;
15651 }
15652
15653 if ( !HAL_STATUS_SUCCESS( status ) )
15654 {
15655 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15656 return eHAL_STATUS_FAILURE;
15657 }
15658 pSession = CSR_GET_SESSION( pMac, sessionId );
krunal soni587bf012014-02-04 12:35:11 -080015659 if (NULL == pSession)
15660 {
15661 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15662 "%s:pSession is null", __func__);
15663 return eHAL_STATUS_FAILURE;
15664 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015665 pBssDesc = pSession->pConnectBssDesc;
15666 if (pBssDesc == NULL)
15667 {
15668 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: pBssDesc not found for current session", __func__);
15669 return eHAL_STATUS_FAILURE;
15670 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015671 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15672 if (NULL == pRequestBuf)
15673 {
15674 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15675 return eHAL_STATUS_FAILED_ALLOC;
15676 }
15677
Kiet Lam64c1b492013-07-12 13:56:44 +053015678 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015679 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15680 * host driver reloads, but Riva still up and running*/
15681 if(command == ROAM_SCAN_OFFLOAD_STOP)
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015682 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015683 pRequestBuf->RoamScanOffloadEnabled = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015684 /*For a STOP Command, there is no need to
15685 * go through filling up all the below parameters
15686 * since they are not required for the STOP command*/
15687 goto send_roam_scan_offload_cmd;
15688 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015689 else
15690 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015691 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15692 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015693 sizeof(tCsrBssid));
15694 pRequestBuf->ConnectedNetwork.ssId.length =
15695 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15696 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15697 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15698 pRequestBuf->ConnectedNetwork.ssId.length);
15699 pRequestBuf->ConnectedNetwork.authentication =
15700 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15701 pRequestBuf->ConnectedNetwork.encryption =
15702 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15703 pRequestBuf->ConnectedNetwork.mcencryption =
15704 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015705 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
15706 {
15707 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015708 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015709 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15710 }
15711 else
15712 {
15713 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
15714 operationChannel = pSession->connectedProfile.operationChannel;
15715
15716 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
15717 {
15718 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15719 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
15720 vos_mem_free(pRequestBuf);
15721 return eHAL_STATUS_FAILURE;
15722 }
15723 if (pIes->SuppRates.present)
15724 {
15725 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
15726 /*Check for both basic rates and extended rates.*/
15727 for (i = 0; i < pIes->SuppRates.num_rates; i++)
15728 {
15729 /*Check if the Rate is Mandatory or Not*/
15730 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
15731 && (pIes->SuppRates.rates[i] & 0x80))
15732 {
15733 /*Retrieve the actual data rate*/
15734 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
15735 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15736 if (minRate == 0)
15737 minRate = dataRate;
15738 else
15739 minRate = (minRate < dataRate) ? minRate:dataRate;
15740 }
15741 }
15742
15743 if (pIes->ExtSuppRates.present)
15744 {
15745 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
15746 {
15747 /*Check if the Rate is Mandatory or Not*/
15748 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
15749 && (pIes->ExtSuppRates.rates[i] & 0x80))
15750 {
15751 /*Retrieve the actual data rate*/
15752 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
15753 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15754 if (minRate == 0)
15755 minRate = dataRate;
15756 else
15757 minRate = (minRate < dataRate) ? minRate:dataRate;
15758 }
15759 }
15760 }
15761 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
15762 }
15763 else
15764 {
15765 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15766 "%s: Supp Rates not present in pIes", __func__);
15767 vos_mem_free(pRequestBuf);
15768 return eHAL_STATUS_FAILURE;
15769 }
15770 if (NULL != pIes)
15771 {
15772 vos_mem_free(pIes);
15773 pIes = NULL;
15774 }
15775 switch (minRate)
15776 {
15777 case 1:
15778 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
15779 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
15780 break;
15781 case 2:
15782 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
15783 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
15784 break;
15785 case 5:
15786 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
15787 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
15788 break;
15789 case 6:
15790 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15791 {
15792 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
15793 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
15794 }
15795 else
15796 {
15797 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
15798 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
15799 }
15800 break;
15801 case 11:
15802 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
15803 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
15804 break;
15805 case 12:
15806 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15807 {
15808 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
15809 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
15810 }
15811 else
15812 {
15813 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
15814 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
15815 }
15816 break;
15817 case 24:
15818 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15819 {
15820 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
15821 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
15822 }
15823 else
15824 {
15825 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
15826 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
15827 }
15828 break;
15829 default:
15830 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
15831 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15832 break;
15833 }
15834 }
15835 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15836 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
15837 operationChannel, minRate,
15838 pRequestBuf->RxSensitivityThreshold,
15839 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015840 pRequestBuf->RoamRssiDiff =
15841 pMac->roam.configParam.RoamRssiDiff;
15842 pRequestBuf->Command = command;
15843 pRequestBuf->StartScanReason = reason;
15844 pRequestBuf->NeighborScanTimerPeriod =
15845 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
15846 pRequestBuf->NeighborRoamScanRefreshPeriod =
15847 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
15848 pRequestBuf->NeighborScanChannelMinTime =
15849 pNeighborRoamInfo->cfgParams.minChannelScanTime;
15850 pRequestBuf->NeighborScanChannelMaxTime =
15851 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
15852 pRequestBuf->EmptyRefreshScanPeriod =
15853 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080015854 /* MAWC feature */
15855 pRequestBuf->MAWCEnabled =
15856 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015857#ifdef FEATURE_WLAN_CCX
15858 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
15859#endif
15860 if (
15861#ifdef FEATURE_WLAN_CCX
15862 ((pNeighborRoamInfo->isCCXAssoc) &&
15863 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
15864 eANI_BOOLEAN_FALSE)) ||
15865 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
15866#endif // CCX
15867 currChannelListInfo->numOfChannels == 0)
15868 {
15869
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015870 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
15871 * Give Preference to INI Channels.*/
15872 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
15873 {
15874 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
15875 /*The INI channels need to be filtered with respect to the current
15876 * band that is supported.*/
15877 eBand = pMac->roam.configParam.bandCapability;
15878 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015879 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015880 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15881 "Invalid band, No operation carried out (Band %d)", eBand);
15882 vos_mem_free(pRequestBuf);
15883 return eHAL_STATUS_FAILURE;
15884 }
15885 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
15886 {
15887 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
15888 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
15889 (eCSR_BAND_ALL == eBand))
15890 {
15891 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
15892 csrRoamIsChannelValid(pMac, *ChannelList) &&
15893 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
15894 {
15895 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15896 }
15897 }
15898 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015899 }
15900 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15901 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015902 }
15903 else
15904 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015905 ChannelList = pMac->scan.occupiedChannels.channelList;
15906 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
15907 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015908 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
15909 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
15910 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015911 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015912 }
15913 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015914 }
15915 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15916 /* If the profile changes as to what it was earlier, inform the FW through
15917 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
15918 * for the earlier profile and try to learn them afresh.*/
15919 if (reason == REASON_FLUSH_CHANNEL_LIST)
15920 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
15921 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015922 if (csrNeighborRoamIsNewConnectedProfile(pMac))
15923 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
15924 else
15925 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015926 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015927 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015928 }
15929#ifdef FEATURE_WLAN_CCX
15930 else
15931 {
15932 /* If CCX is enabled, and a neighbor Report is received,then
15933 * Ignore the INI Channels or the Occupied Channel List. Consider
15934 * the channels in the neighbor list sent by the CCX AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015935 if (currChannelListInfo->numOfChannels != 0)
15936 {
15937 ChannelList = currChannelListInfo->ChannelList;
15938 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015939 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015940 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15941 {
15942 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15943 }
15944 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015945 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015946 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15947 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15948 }
15949 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015950#endif
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015951 for (i = 0, j = 0; i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
15952 {
15953 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
15954 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
15955 }
15956 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15957 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
15958 pRequestBuf->ChannelCacheType,
15959 pRequestBuf->ConnectedNetwork.ChannelCount,
15960 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015961 num_channels = 0;
15962 ChannelList = NULL;
15963
15964 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070015965 host_channels = sizeof(pMac->roam.validChannelList);
15966 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015967 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070015968 ChannelList = pMac->roam.validChannelList;
15969 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015970 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070015971 else
15972 {
15973 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15974 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070015975 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070015976 return eHAL_STATUS_FAILURE;
15977 }
15978 for(i=0; i<pMac->roam.numValidChannels; i++)
15979 {
15980 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15981 {
15982 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15983 }
15984 ChannelList++;
15985 }
15986 pRequestBuf->ValidChannelCount = num_channels;
15987
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015988 pRequestBuf->MDID.mdiePresent =
15989 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
15990 pRequestBuf->MDID.mobilityDomain =
15991 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015992 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
15993
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015994 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015995 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
15996 * where RFS is the RF Switching time. It is twice RFS to consider the
15997 * time to go off channel and return to the home channel. */
15998 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
15999 {
16000 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16001 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16002 " Hence enforcing home away time to disable (0)",
16003 __func__, pRequestBuf->HomeAwayTime,
16004 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16005 pRequestBuf->HomeAwayTime = 0;
16006 }
16007 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016008
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016009 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16010 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16011 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16012 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16013 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16014
16015 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16016 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016017send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016018 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016019 msg.reserved = 0;
16020 msg.bodyptr = pRequestBuf;
16021 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16022 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016023 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16024 vos_mem_free(pRequestBuf);
16025 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016026 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016027 else
16028 {
16029 if (ROAM_SCAN_OFFLOAD_START == command)
16030 bRoamScanOffloadStarted = VOS_TRUE;
16031 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16032 bRoamScanOffloadStarted = VOS_FALSE;
16033 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016034
16035 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16036 return status;
16037}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016038
16039eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16040{
16041 switch(reason)
16042 {
16043 case 0:
16044 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16045 break;
16046 case REASON_OS_REQUESTED_ROAMING_NOW:
16047 csrNeighborRoamProceedWithHandoffReq(pMac);
16048 break;
16049 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016050 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 -070016051 }
16052 return eHAL_STATUS_SUCCESS;
16053}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016054#endif
16055
Jeff Johnson295189b2012-06-20 16:38:30 -070016056tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16057 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16058{
16059 tANI_BOOLEAN found = FALSE;
16060 eHalStatus status = eHAL_STATUS_SUCCESS;
16061 tCsrPeStatsReqInfo staEntry;
16062 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16063 tListElem *pStaEntry = NULL;
16064 VOS_STATUS vosStatus;
16065 tPmcPowerState powerState;
16066 *pFound = FALSE;
16067
16068 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16069 if(pStaEntry)
16070 {
16071 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16072 if(pTempStaEntry->periodicity)
16073 {
16074 pTempStaEntry->periodicity =
16075 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16076 }
16077 else
16078 {
16079 pTempStaEntry->periodicity = periodicity;
16080 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016081 pTempStaEntry->numClient++;
16082 found = TRUE;
16083 }
16084 else
16085 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016086 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016087 staEntry.numClient = 1;
16088 staEntry.periodicity = periodicity;
16089 staEntry.pMac = pMac;
16090 staEntry.rspPending = FALSE;
16091 staEntry.staId = staId;
16092 staEntry.statsMask = statsMask;
16093 staEntry.timerRunning = FALSE;
16094 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16095 if(!pTempStaEntry)
16096 {
16097 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016098 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016099 return NULL;
16100 }
16101 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016102 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16103 if(ePMC_FULL_POWER == powerState)
16104 {
16105 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16106 {
16107 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16108 }
16109 }
16110 else
16111 {
16112 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16113 {
16114 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16115 }
16116 }
16117 if(!pTempStaEntry->timerRunning)
16118 {
16119 //send down a req in case of one time req, for periodic ones wait for timer to expire
16120 if(!pTempStaEntry->rspPending &&
16121 !pTempStaEntry->periodicity)
16122 {
16123 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16124 if(!HAL_STATUS_SUCCESS(status))
16125 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016126 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016127 }
16128 else
16129 {
16130 pTempStaEntry->rspPending = TRUE;
16131 }
16132 }
16133 if(pTempStaEntry->periodicity)
16134 {
16135 if(!found)
16136 {
16137
16138 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16139 csrRoamPeStatsTimerHandler, pTempStaEntry );
16140 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16141 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016142 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016143 return NULL;
16144 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016145 }
16146 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016147 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016148 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16149 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16150 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016151 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016152 return NULL;
16153 }
16154 pTempStaEntry->timerRunning = TRUE;
16155 }
16156 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016157 *pFound = found;
16158 return pTempStaEntry;
16159}
16160
Jeff Johnson295189b2012-06-20 16:38:30 -070016161/*
16162 pStaEntry is no longer invalid upon the return of this function.
16163*/
16164static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16165{
16166 if(pEntry)
16167 {
16168 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16169 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016170 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016171 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016172 }
16173 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016174
16175void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16176{
16177 tListElem *pEntry;
16178 tCsrPeStatsReqInfo *pTempStaEntry;
16179 VOS_STATUS vosStatus;
16180 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016181 if(!pEntry)
16182 {
16183 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016184 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016185 return;
16186 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016187 while( pEntry )
16188 {
16189 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016190 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16191 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016192 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016193 if(pTempStaEntry->timerRunning)
16194 {
16195 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16196 /* If we are not able to stop the timer here, just remove
16197 * the entry from the linked list. Destroy the timer object
16198 * and free the memory in the timer CB
16199 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016200 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016201 {
16202 /* the timer is successfully stopped */
16203 pTempStaEntry->timerRunning = FALSE;
16204
16205 /* Destroy the timer */
16206 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16207 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16208 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016209 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016210 }
16211 }
16212 else
16213 {
16214 // the timer could not be stopped. Hence destroy and free the
16215 // memory for the PE stat entry in the timer CB.
16216 pTempStaEntry->timerStopFailed = TRUE;
16217 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016218 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016219
16220 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16221 {
16222 // Only free the memory if we could stop the timer successfully
16223 if(!pTempStaEntry->timerStopFailed)
16224 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016225 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016226 pTempStaEntry = NULL;
16227 }
16228 break;
16229 }
16230
16231 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16232 }
16233 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016234 return;
16235}
16236
16237
Jeff Johnsone7245742012-09-05 17:12:55 -070016238void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016239{
16240
Jeff Johnsone7245742012-09-05 17:12:55 -070016241 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16242 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16243 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16244 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16245 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16246 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16247 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016248 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016249 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16250 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16251 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16252 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16253 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16254 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016255 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016256 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16257 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016258
16259}
16260
Jeff Johnson295189b2012-06-20 16:38:30 -070016261void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16262 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16263{
16264 tANI_U8 stats[500];
16265 tANI_U8 *pStats = NULL;
16266 tANI_U32 tempMask = 0;
16267 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016268 if(!callback)
16269 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016270 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016271 return;
16272 }
16273 if(!statsMask)
16274 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016275 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016276 return;
16277 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016278 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016279 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016280 while(tempMask)
16281 {
16282 if(tempMask & 1)
16283 {
16284 //new stats info from PE, fill up the stats strucutres in PMAC
16285 switch(counter)
16286 {
16287 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016288 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016289 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16290 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016291 pStats += sizeof(tCsrSummaryStatsInfo);
16292 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016293 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016294 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016295 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16296 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016297 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016298 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016299 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016300 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016301 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16302 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016303 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016304 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016305 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016306 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016307 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16308 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016309 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016310 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016311 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016312 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016313 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16314 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016315 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016316 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016317 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016318 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016319 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16320 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016321 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016322 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016323 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016324 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016325 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016326 }
16327 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016328 tempMask >>=1;
16329 counter++;
16330 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016331 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016332}
16333
Jeff Johnson295189b2012-06-20 16:38:30 -070016334eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16335{
16336 tListElem *pEntry = NULL;
16337 tListElem *pPrevEntry = NULL;
16338 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16339 eHalStatus status = eHAL_STATUS_SUCCESS;
16340 VOS_STATUS vosStatus;
16341 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016342 if(!pEntry)
16343 {
16344 //list empty
16345 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016346 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016347 return status;
16348 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016349 while( pEntry )
16350 {
16351 if(pPrevEntry)
16352 {
16353 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16354 //send up the stats report
16355 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16356 pTempStaEntry->staId, pTempStaEntry->pContext);
16357 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16358 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016359 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016360 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16361 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016362 pTempStaEntry->pPeStaEntry->numClient--;
16363 //check if we need to delete the entry from peStatsReqList too
16364 if(!pTempStaEntry->pPeStaEntry->numClient)
16365 {
16366 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16367 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016368 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016369 //check if we need to stop the tl stats timer too
16370 pMac->roam.tlStatsReqInfo.numClient--;
16371 if(!pMac->roam.tlStatsReqInfo.numClient)
16372 {
16373 if(pMac->roam.tlStatsReqInfo.timerRunning)
16374 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016375 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16376 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016377 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016378 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016379 //we will continue
16380 }
16381 }
16382 pMac->roam.tlStatsReqInfo.periodicity = 0;
16383 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16384 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016385 if (pTempStaEntry->periodicity)
16386 {
16387 //While creating StaEntry in csrGetStatistics,
16388 //Initializing and starting timer only when periodicity is set.
16389 //So Stop and Destroy timer only when periodicity is set.
16390
Jeff Johnsone7245742012-09-05 17:12:55 -070016391 vos_timer_stop( &pTempStaEntry->timer );
16392 // Destroy the vos timer...
16393 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16394 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16395 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016396 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016397 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016398 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016399
Jeff Johnson295189b2012-06-20 16:38:30 -070016400
16401 pPrevEntry = pEntry;
16402 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16403 }
16404 //the last one
16405 if(pPrevEntry)
16406 {
16407 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16408 //send up the stats report
16409 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16410 pTempStaEntry->staId, pTempStaEntry->pContext);
16411 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16412 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016413 return status;
16414
16415}
16416
Jeff Johnson295189b2012-06-20 16:38:30 -070016417eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16418 tRequestFullPowerReason *pReason,
16419 tANI_BOOLEAN *pfNeedPower )
16420{
16421 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16422 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16423 tPmcState pmcState;
16424 eHalStatus status = eHAL_STATUS_SUCCESS;
16425 // TODO : Session info unavailable
16426 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016427 if( pfNeedPower )
16428 {
16429 *pfNeedPower = eANI_BOOLEAN_FALSE;
16430 }
16431 //We only handle CSR commands
16432 if( !(eSmeCsrCommandMask & pCommand->command) )
16433 {
16434 return eHAL_STATUS_SUCCESS;
16435 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016436 //Check PMC state first
16437 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016438 switch( pmcState )
16439 {
16440 case REQUEST_IMPS:
16441 case IMPS:
16442 if( eSmeCommandScan == pCommand->command )
16443 {
16444 switch( pCommand->u.scanCmd.reason )
16445 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016446#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16447 case eCsrScanGetLfrResult:
16448#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016449 case eCsrScanGetResult:
16450 case eCsrScanBGScanAbort:
16451 case eCsrScanBGScanEnable:
16452 case eCsrScanGetScanChnInfo:
16453 //Internal process, no need for full power
16454 fNeedFullPower = eANI_BOOLEAN_FALSE;
16455 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016456 default:
16457 //Other scans are real scan, ask for power
16458 fNeedFullPower = eANI_BOOLEAN_TRUE;
16459 break;
16460 } //switch
16461 }
16462 else
16463 {
16464 //ask for power for roam and status change
16465 fNeedFullPower = eANI_BOOLEAN_TRUE;
16466 }
16467 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016468 case REQUEST_BMPS:
16469 case BMPS:
16470 case REQUEST_START_UAPSD:
16471 case UAPSD:
16472 //We treat WOWL same as BMPS
16473 case REQUEST_ENTER_WOWL:
16474 case WOWL:
16475 if( eSmeCommandRoam == pCommand->command )
16476 {
16477 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16478 tCsrScanResult *pScanResult;
16479 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016480 switch ( pCommand->u.roamCmd.roamReason )
16481 {
16482 case eCsrForcedDisassoc:
16483 case eCsrForcedDisassocMICFailure:
16484 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16485 fNeedFullPower = eANI_BOOLEAN_TRUE;
16486 break;
16487 case eCsrSmeIssuedDisassocForHandoff:
16488 case eCsrForcedDeauth:
16489 case eCsrHddIssuedReassocToSameAP:
16490 case eCsrSmeIssuedReassocToSameAP:
16491 fNeedFullPower = eANI_BOOLEAN_TRUE;
16492 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016493 case eCsrCapsChange:
16494 fNeedFullPower = eANI_BOOLEAN_TRUE;
16495 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016496 default:
16497 //Check whether the profile is already connected. If so, no need for full power
16498 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16499 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16500 {
16501 //Only need to check the first one
16502 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16503 if( pEntry )
16504 {
16505 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16506#if 0
16507 // TODO : Session Specific info pConnectBssDesc
16508 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16509 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16510 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16511 {
16512 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16513 // with Authenticating first. To force this, stop the current association (Disassociate) and
16514 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16515 // a new Association.
16516 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16517 {
16518 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16519 {
16520 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16521 //No need for full power
16522 //Set the flag so the code later can avoid to do the above
16523 //check again.
16524 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16525 break;
16526 }
16527 }
16528 }
16529#endif
16530 }
16531 }
16532 //If we are here, full power is needed
16533 fNeedFullPower = eANI_BOOLEAN_TRUE;
16534 break;
16535 }
16536 }
16537 else if( eSmeCommandWmStatusChange == pCommand->command )
16538 {
16539 //need full power for all
16540 fNeedFullPower = eANI_BOOLEAN_TRUE;
16541 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16542 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016543#ifdef FEATURE_WLAN_TDLS
16544 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16545 {
16546 //TDLS link is getting established. need full power
16547 fNeedFullPower = eANI_BOOLEAN_TRUE;
16548 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16549 }
16550#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016551 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016552 case REQUEST_STOP_UAPSD:
16553 case REQUEST_EXIT_WOWL:
16554 if( eSmeCommandRoam == pCommand->command )
16555 {
16556 fNeedFullPower = eANI_BOOLEAN_TRUE;
16557 switch ( pCommand->u.roamCmd.roamReason )
16558 {
16559 case eCsrForcedDisassoc:
16560 case eCsrForcedDisassocMICFailure:
16561 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16562 break;
16563 default:
16564 break;
16565 }
16566 }
16567 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016568 case STOPPED:
16569 case REQUEST_STANDBY:
16570 case STANDBY:
16571 case LOW_POWER:
16572 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016573 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016574 status = eHAL_STATUS_FAILURE;
16575 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016576 case FULL_POWER:
16577 case REQUEST_FULL_POWER:
16578 default:
16579 //No need to ask for full power. This has to be FULL_POWER state
16580 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016581 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016582 if( pReason )
16583 {
16584 *pReason = reason;
16585 }
16586 if( pfNeedPower )
16587 {
16588 *pfNeedPower = fNeedFullPower;
16589 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016590 return ( status );
16591}
16592
Jeff Johnson295189b2012-06-20 16:38:30 -070016593static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16594{
16595 eHalStatus status = eHAL_STATUS_SUCCESS;
16596 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16597 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016598 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016599 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16600 {
16601 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16602 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016603 return ( status );
16604}
16605
Jeff Johnson295189b2012-06-20 16:38:30 -070016606tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16607{
16608 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016609 if( pCmd )
16610 {
16611 pMac->roam.sPendingCommands++;
16612 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016613 return ( pCmd );
16614}
16615
Jeff Johnson295189b2012-06-20 16:38:30 -070016616void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16617{
16618 if (pMac->roam.sPendingCommands > 0)
16619 {
16620 //All command allocated through csrGetCommandBuffer need to
16621 //decrement the pending count when releasing.
16622 pMac->roam.sPendingCommands--;
16623 smeReleaseCommand( pMac, pCommand );
16624 }
16625 else
16626 {
16627 smsLog(pMac, LOGE, FL( "no pending commands"));
16628 VOS_ASSERT(0);
16629 }
16630}
16631
Jeff Johnson295189b2012-06-20 16:38:30 -070016632//Return SUCCESS is the command is queued, failed
16633eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16634{
16635 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016636 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16637 {
16638 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16639 pCommand->u.scanCmd.reason);
16640 return eHAL_STATUS_CSR_WRONG_STATE;
16641 }
16642
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016643 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16644 {
16645 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16646 &pCommand->Link, LL_ACCESS_LOCK);
16647 // process the command queue...
16648 smeProcessPendingQueue(pMac);
16649 status = eHAL_STATUS_SUCCESS;
16650 goto end;
16651 }
16652
Jeff Johnson295189b2012-06-20 16:38:30 -070016653 //We can call request full power first before putting the command into pending Q
16654 //because we are holding SME lock at this point.
16655 status = csrRequestFullPower( pMac, pCommand );
16656 if( HAL_STATUS_SUCCESS( status ) )
16657 {
16658 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016659 //make sure roamCmdPendingList is not empty first
16660 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16661 if( fNoCmdPending )
16662 {
16663 smePushCommand( pMac, pCommand, fHighPriority );
16664 }
16665 else
16666 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016667 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016668 //no list lock is needed since SME lock is held
16669 if( !fHighPriority )
16670 {
16671 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16672 }
16673 else {
16674 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16675 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016676 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016677 }
16678 else if( eHAL_STATUS_PMC_PENDING == status )
16679 {
16680 //no list lock is needed since SME lock is held
16681 if( !fHighPriority )
16682 {
16683 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16684 }
16685 else {
16686 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16687 }
16688 //Let caller know the command is queue
16689 status = eHAL_STATUS_SUCCESS;
16690 }
16691 else
16692 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016693 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016694 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016695 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016696 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016697end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016698 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016699}
Jeff Johnson295189b2012-06-20 16:38:30 -070016700eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16701{
16702 eHalStatus status = eHAL_STATUS_SUCCESS;
16703 tSirUpdateAPWPSIEsReq *pMsg;
16704 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16705
16706 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16707 if (NULL == pSession)
16708 {
16709 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16710 return eHAL_STATUS_FAILURE;
16711 }
16712
Jeff Johnson295189b2012-06-20 16:38:30 -070016713 do
16714 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016715 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
16716 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16717 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016718 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
16719
16720 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070016721 VOS_ASSERT(pBuf);
16722
Jeff Johnson295189b2012-06-20 16:38:30 -070016723 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016724 // transactionId
16725 *pBuf = 0;
16726 *( pBuf + 1 ) = 0;
16727 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070016728 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016729 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16730 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016731 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016732 //sessionId
16733 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016734 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016735 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070016736 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070016737 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016738 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016739 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016740 return ( status );
16741}
Jeff Johnson295189b2012-06-20 16:38:30 -070016742eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
16743{
16744 eHalStatus status = eHAL_STATUS_SUCCESS;
16745 tSirUpdateAPWPARSNIEsReq *pMsg;
16746 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016747 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16748 if (NULL == pSession)
16749 {
16750 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16751 return eHAL_STATUS_FAILURE;
16752 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016753 do
16754 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016755 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
16756 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16757 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016758 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016759 pBuf = (tANI_U8 *)&pMsg->transactionId;
16760 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016761 // transactionId
16762 *pBuf = 0;
16763 *( pBuf + 1 ) = 0;
16764 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070016765 VOS_ASSERT(pBuf);
16766
Jeff Johnson295189b2012-06-20 16:38:30 -070016767 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016768 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16769 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016770 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016771 // sessionId
16772 *pBuf++ = (tANI_U8)sessionId;
16773
16774 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016775 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070016776 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070016777 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016778 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016779 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016780 return ( status );
16781}
Jeff Johnson295189b2012-06-20 16:38:30 -070016782
16783#ifdef WLAN_FEATURE_VOWIFI_11R
16784//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
16785eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
16786{
16787 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16788 tpSirFTPreAuthReq pftPreAuthReq;
16789 tANI_U16 auth_req_len = 0;
16790 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016791 auth_req_len = sizeof(tSirFTPreAuthReq);
16792 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053016793 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070016794 {
16795 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
16796 return eHAL_STATUS_RESOURCES;
16797 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016798 // Save the SME Session ID here. We need it while processing the preauth response
16799 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016800 vos_mem_zero(pftPreAuthReq, auth_req_len);
16801
16802 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
16803 sizeof(pBssDescription->length) + pBssDescription->length);
16804
16805 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
16806
16807 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
16808
Kiet Lam64c1b492013-07-12 13:56:44 +053016809 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
16810 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
16811 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
16812 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016813
Jeff Johnson295189b2012-06-20 16:38:30 -070016814#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080016815 if (csrRoamIs11rAssoc(pMac) &&
16816 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070016817 {
16818 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053016819 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
16820 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070016821 }
16822 else
16823#endif
16824 {
16825 pftPreAuthReq->ft_ies_length = 0;
16826 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070016827 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
16828 sizeof(pBssDescription->length) + pBssDescription->length);
16829 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070016830 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
16831}
Jeff Johnson295189b2012-06-20 16:38:30 -070016832/*--------------------------------------------------------------------------
16833 * This will receive and process the FT Pre Auth Rsp from the current
16834 * associated ap.
16835 *
16836 * This will invoke the hdd call back. This is so that hdd can now
16837 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
16838 ------------------------------------------------------------------------*/
16839void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
16840{
16841 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16842 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016843#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016844 tCsrRoamInfo roamInfo;
16845#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016846
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016847#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016848 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016849 if (status != eHAL_STATUS_SUCCESS) {
16850 /*
16851 * Bail out if pre-auth was not even processed.
16852 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016853 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
16854 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016855 return;
16856 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016857#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016858 /* The below function calls/timers should be invoked only if the pre-auth is successful */
16859 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
16860 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070016861 // Implies a success
16862 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016863 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
16864 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070016865 /* No need to notify qos module if this is a non 11r roam*/
16866 if (csrRoamIs11rAssoc(pMac))
16867 {
16868 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
16869 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016870 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
16871 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016872 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
16873 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070016874 if (eHAL_STATUS_SUCCESS != status)
16875 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016876 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016877 return;
16878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016879 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016880 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
16881 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016882 if (csrRoamIs11rAssoc(pMac))
16883 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
16884 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
16885
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016886#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16887 if (csrRoamIsCCXAssoc(pMac))
16888 {
16889 /* read TSF */
16890 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
16891
16892 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080016893 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016894 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
16895 }
16896#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016897#ifdef FEATURE_WLAN_LFR
16898 // If Legacy Fast Roaming is enabled, signal the supplicant
16899 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053016900 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016901 {
16902 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016903 vos_mem_copy((void *)&roamInfo.bssid,
16904 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016905 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
16906 }
16907
16908#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016909
16910 // Done with it, init it.
16911 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
16912}
16913#endif
16914#ifdef FEATURE_WLAN_BTAMP_UT_RF
16915void csrRoamJoinRetryTimerHandler(void *pv)
16916{
16917 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
16918 tpAniSirGlobal pMac = pInfo->pMac;
16919 tANI_U32 sessionId = pInfo->sessionId;
16920 tCsrRoamSession *pSession;
16921
16922 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16923 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016924 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016925 pSession = CSR_GET_SESSION( pMac, sessionId );
16926 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
16927 {
16928 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
16929 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016930 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016931 }
16932 }
16933 }
16934}
Jeff Johnson295189b2012-06-20 16:38:30 -070016935eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
16936{
16937 eHalStatus status = eHAL_STATUS_FAILURE;
16938 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16939
16940 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
16941 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016942 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070016943 pSession->maxRetryCount--;
16944 pSession->joinRetryTimerInfo.pMac = pMac;
16945 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016946 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
16947 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016948 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016949 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016950 }
16951 }
16952 else
16953 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016954 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070016955 pSession->maxRetryCount);
16956 }
16957
16958 return (status);
16959}
Jeff Johnson295189b2012-06-20 16:38:30 -070016960eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
16961{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016962 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070016963 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16964 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016965 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070016966 }
16967
16968 return eHAL_STATUS_SUCCESS;
16969}
16970#endif
16971
16972
16973/*
16974 pBuf points to the beginning of the message
16975 LIM packs disassoc rsp as below,
16976 messageType - 2 bytes
16977 messageLength - 2 bytes
16978 sessionId - 1 byte
16979 transactionId - 2 bytes (tANI_U16)
16980 reasonCode - 4 bytes (sizeof(tSirResultCodes))
16981 peerMacAddr - 6 bytes
16982 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
16983*/
16984static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
16985{
16986 if(pBuf && pRsp)
16987 {
16988 pBuf += 4; //skip type and length
16989 pRsp->sessionId = *pBuf++;
16990 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
16991 pBuf += 2;
16992 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
16993 pBuf += 4;
16994 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
16995 }
16996}
16997
Jeff Johnsond13512a2012-07-17 11:42:19 -070016998eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16999{
17000 static uNvTables nvTables;
17001 eHalStatus status = eHAL_STATUS_SUCCESS;
17002 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17003
17004 /* read the country code from NV and use it */
17005 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17006 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017007 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17008 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017009 return status;
17010 }
17011 else
17012 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017013 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017014 status = eHAL_STATUS_FAILURE;
17015 return status;
17016 }
17017}
17018
17019eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17020{
Kiet Lam64c1b492013-07-12 13:56:44 +053017021 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017022 return eHAL_STATUS_SUCCESS;
17023}
schang86c22c42013-03-13 18:41:24 -070017024
17025eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17026{
17027 tSirSetTxPowerReq *pMsg = NULL;
17028 eHalStatus status = eHAL_STATUS_SUCCESS;
17029 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17030
17031 if (!pSession)
17032 {
17033 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17034 return eHAL_STATUS_FAILURE;
17035 }
17036
Kiet Lam64c1b492013-07-12 13:56:44 +053017037 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17038 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17039 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17040 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17041 pMsg->length = sizeof(tSirSetTxPowerReq);
17042 pMsg->mwPower = mW;
17043 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17044 sizeof(tSirMacAddr));
17045 status = palSendMBMessage(pMac->hHdd, pMsg);
17046 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017047 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017048 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17049 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017050 }
17051 return status;
17052}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017053
17054/* Returns whether a session is in VOS_STA_MODE...or not */
17055tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17056{
17057 tCsrRoamSession *pSession = NULL;
17058 pSession = CSR_GET_SESSION ( pMac, sessionId );
17059 if(!pSession)
17060 {
17061 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17062 return eANI_BOOLEAN_FALSE;
17063 }
17064 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17065 {
17066 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17067 return eANI_BOOLEAN_FALSE;
17068 }
17069 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17070 {
17071 return eANI_BOOLEAN_FALSE;
17072 }
17073 /* There is a possibility that the above check may fail,because
17074 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17075 * when it is connected.So,we may sneak through the above check even
17076 * if we are not a STA mode INFRA station. So, if we sneak through
17077 * the above condition, we can use the following check if we are
17078 * really in STA Mode.*/
17079
17080 if ( NULL != pSession->pCurRoamProfile )
17081 {
17082 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17083 {
17084 return eANI_BOOLEAN_TRUE;
17085 } else {
17086 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17087 return eANI_BOOLEAN_FALSE;
17088 }
17089 }
17090
17091 return eANI_BOOLEAN_FALSE;
17092}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017093
17094#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17095eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17096 tCsrHandoffRequest *pHandoffInfo)
17097{
17098 eHalStatus status = eHAL_STATUS_SUCCESS;
17099 vos_msg_t msg;
17100
17101 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017102 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17103 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017104 {
17105 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017106 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017107 }
17108 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17109 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17110 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17111 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017112 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017113 pHandoffInfo->bssid,
17114 6);
17115 msg.type = eWNI_SME_HANDOFF_REQ;
17116 msg.bodyptr = pMsg;
17117 msg.reserved = 0;
17118 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17119 {
17120 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017121 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017122 status = eHAL_STATUS_FAILURE;
17123 }
17124 return status;
17125}
17126#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017127
17128#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
17129/* ---------------------------------------------------------------------------
17130 \fn csrSetCCKMIe
17131 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17132 data structure and this IE will be packed inside reassociation request
17133 \param pMac - pMac global structure
17134 \param sessionId - Current session id
17135 \param pCckmIe - pointer to CCKM IE data
17136 \param ccKmIeLen - length of the CCKM IE
17137 \- return Success or failure
17138 -------------------------------------------------------------------------*/
17139VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17140 const tANI_U8 *pCckmIe,
17141 const tANI_U8 ccKmIeLen)
17142{
17143 eHalStatus status = eHAL_STATUS_SUCCESS;
17144 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17145
17146 if (!pSession)
17147 {
17148 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17149 return eHAL_STATUS_FAILURE;
17150 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017151 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017152 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17153 return status;
17154}
17155
17156/* ---------------------------------------------------------------------------
17157 \fn csrRoamReadTSF
17158 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17159 probe response reception from the hand off AP to arrive at the latest TSF value.
17160 \param pMac - pMac global structure
17161 \param pTimestamp - output TSF timestamp
17162 \- return Success or failure
17163 -------------------------------------------------------------------------*/
17164VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17165{
17166 eHalStatus status = eHAL_STATUS_SUCCESS;
17167 tCsrNeighborRoamBSSInfo handoffNode;
17168 tANI_U32 timer_diff = 0;
17169 tANI_U32 timeStamp[2];
17170 tpSirBssDescription pBssDescription = NULL;
17171
17172 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17173 pBssDescription = handoffNode.pBssDescription;
17174
17175 // Get the time diff in milli seconds
17176 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17177 // Convert msec to micro sec timer
17178 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17179
17180 timeStamp[0] = pBssDescription->timeStamp[0];
17181 timeStamp[1] = pBssDescription->timeStamp[1];
17182
17183 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17184
Kiet Lamf2f201e2013-11-16 21:24:16 +053017185 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017186 sizeof (tANI_U32) * 2);
17187 return status;
17188}
17189
17190#endif /*FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
17191