blob: 6b8323c958ed128c5c967520edb3c99360278d06 [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 }
2438 if (NULL == pRoamInfo)
2439 {
2440 smsLog(pMac, LOGE, "%s: pRoamInfo is NULL", __func__);
2441 VOS_ASSERT(0);
2442 return eHAL_STATUS_FAILURE;
2443 }
2444 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2445
2446 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1)
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002448 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002450 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2451 /*
2452 * Decrement bRefAssocStartCnt for FT reassoc failure.
2453 * Reason: For FT reassoc failures, we first call
2454 * csrRoamCallCallback before notifying a failed roam
2455 * completion through csrRoamComplete. The latter in
2456 * turn calls csrRoamProcessResults which tries to
2457 * once again call csrRoamCallCallback if bRefAssocStartCnt
2458 * is non-zero. Since this is redundant for FT reassoc
2459 * failure, decrement bRefAssocStartCnt.
2460 */
2461 pSession->bRefAssocStartCnt--;
2462 }
2463
Jeff Johnson295189b2012-06-20 16:38:30 -07002464 if(NULL != pSession->callback)
2465 {
2466 if( pRoamInfo )
2467 {
2468 pRoamInfo->sessionId = (tANI_U8)sessionId;
2469 }
2470
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302471 /* avoid holding the global lock when making the roaming callback, original change came
2472 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2473 is possible on other OS ports where the callback may need to take locks to protect
2474 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002475 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2476 that may actually depend on the lock being held */
2477 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2478 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2479 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2480 }
2481 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2482 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2483#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302484 vos_mem_set(&connectionStatus,
2485 sizeof(vos_event_wlan_status_payload_type), 0);
2486
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2488 {
2489 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2490 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2491 if(NULL != pRoamInfo->pBssDesc)
2492 {
2493 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2494 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2497 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2498 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302499 vos_mem_copy(connectionStatus.ssid,
2500 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2501
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2503 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2504 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002505 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2506 {
2507 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2508 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2509 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 if(eCSR_ROAM_RESULT_FORCED == u2)
2512 {
2513 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2514 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2515 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2518 {
2519 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2520 connectionStatus.reason = eCSR_REASON_DISASSOC;
2521 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002523 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2524 {
2525 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2526 connectionStatus.reason = eCSR_REASON_DEAUTH;
2527 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002529#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2530
2531 return (status);
2532}
Jeff Johnson295189b2012-06-20 16:38:30 -07002533// Returns whether handoff is currently in progress or not
2534tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2535{
2536#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2537 return csrNeighborRoamIsHandoffInProgress(pMac);
2538#else
2539 return eANI_BOOLEAN_FALSE;
2540#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002541}
Jeff Johnson295189b2012-06-20 16:38:30 -07002542eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2543 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2544{
2545 eHalStatus status = eHAL_STATUS_SUCCESS;
2546 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2547 tANI_U16 reasonCode;
2548 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002549
2550 if(!pSession)
2551 {
2552 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2553 return eHAL_STATUS_FAILURE;
2554 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002555
2556 //Restore AC weight in case we change it
2557 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2558 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002559 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 -07002560 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2561 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2562 }
2563
2564 if ( fMICFailure )
2565 {
2566 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2567 }
2568 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2569 {
2570 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002571 }
2572 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002573 {
2574 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2575 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002576#ifdef WLAN_FEATURE_VOWIFI_11R
2577 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2578 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2579 {
2580 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302581 vos_mem_copy(&bssId,
2582 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2583 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002584 }
2585 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002586#endif
2587 if(pSession->pConnectBssDesc)
2588 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302589 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002591
Jeff Johnson295189b2012-06-20 16:38:30 -07002592
Arif Hussain24bafea2013-11-15 15:10:03 -08002593 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2594 " subState = %d reason=%d",
2595 MAC_ADDR_ARRAY(bssId), NewSubstate, reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002596
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2598
2599 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2600
2601 if(HAL_STATUS_SUCCESS(status))
2602 {
2603 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002604#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2605 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2606 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2607 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002608 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2610 }
2611#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002612 }
2613 else
2614 {
2615 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2616 }
2617
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 return (status);
2619}
Jeff Johnson295189b2012-06-20 16:38:30 -07002620
Jeff Johnson295189b2012-06-20 16:38:30 -07002621/* ---------------------------------------------------------------------------
2622 \fn csrRoamIssueDisassociateStaCmd
2623 \brief csr function that HDD calls to disassociate a associated station
2624 \param sessionId - session Id for Soft AP
2625 \param pPeerMacAddr - MAC of associated station to delete
2626 \param reason - reason code, be one of the tSirMacReasonCodes
2627 \return eHalStatus
2628 ---------------------------------------------------------------------------*/
2629eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2630 tANI_U32 sessionId,
2631 tANI_U8 *pPeerMacAddr,
2632 tANI_U32 reason)
2633{
2634 eHalStatus status = eHAL_STATUS_SUCCESS;
2635 tSmeCmd *pCommand;
2636
2637 do
2638 {
2639 pCommand = csrGetCommandBuffer( pMac );
2640 if ( !pCommand )
2641 {
2642 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2643 status = eHAL_STATUS_RESOURCES;
2644 break;
2645 }
2646 pCommand->command = eSmeCommandRoam;
2647 pCommand->sessionId = (tANI_U8)sessionId;
2648 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2649 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2650 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2651 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2652 if( !HAL_STATUS_SUCCESS( status ) )
2653 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002654 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 csrReleaseCommandRoam( pMac, pCommand );
2656 }
2657 }while(0);
2658
2659 return status;
2660}
2661
2662
Jeff Johnson295189b2012-06-20 16:38:30 -07002663/* ---------------------------------------------------------------------------
2664 \fn csrRoamIssueDeauthSta
2665 \brief csr function that HDD calls to delete a associated station
2666 \param sessionId - session Id for Soft AP
2667 \param pPeerMacAddr - MAC of associated station to delete
2668 \param reason - reason code, be one of the tSirMacReasonCodes
2669 \return eHalStatus
2670 ---------------------------------------------------------------------------*/
2671eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2672 tANI_U32 sessionId,
2673 tANI_U8 *pPeerMacAddr,
2674 tANI_U32 reason)
2675{
2676 eHalStatus status = eHAL_STATUS_SUCCESS;
2677 tSmeCmd *pCommand;
2678
2679 do
2680 {
2681 pCommand = csrGetCommandBuffer( pMac );
2682 if ( !pCommand )
2683 {
2684 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2685 status = eHAL_STATUS_RESOURCES;
2686 break;
2687 }
2688 pCommand->command = eSmeCommandRoam;
2689 pCommand->sessionId = (tANI_U8)sessionId;
2690 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2691 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2692 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2693 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2694 if( !HAL_STATUS_SUCCESS( status ) )
2695 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002696 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 csrReleaseCommandRoam( pMac, pCommand );
2698 }
2699 }while(0);
2700
2701 return status;
2702}
Jeff Johnson295189b2012-06-20 16:38:30 -07002703eHalStatus
2704csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2705 tANI_BOOLEAN bEnable )
2706{
2707 eHalStatus status = eHAL_STATUS_FAILURE;
2708 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2709 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002710 if (!pSession)
2711 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002712 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 return (status);
2714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 if (pSession->pConnectBssDesc)
2716 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302717 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 }
2719 else
2720 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002721 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002722 return (status);
2723 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002724 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2725 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2727 return (status);
2728}
Jeff Johnson295189b2012-06-20 16:38:30 -07002729eHalStatus
2730csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2731 VOS_MODULE_ID modId, void *pUsrContext,
2732 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2733{
2734 eHalStatus status = eHAL_STATUS_SUCCESS;
2735 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2736 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 if (!pSession)
2738 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002739 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 return (status);
2741 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 if(pSession->pConnectBssDesc)
2743 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302744 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 }
2746 else
2747 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002748 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002749 return (status);
2750 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002751 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2752 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002753 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2754 return (status);
2755}
Jeff Johnson295189b2012-06-20 16:38:30 -07002756eHalStatus
2757csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2758 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2759{
2760 eHalStatus status = eHAL_STATUS_SUCCESS;
2761 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2762 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2763
2764 if (!pSession)
2765 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002766 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 return (status);
2768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 if(pSession->pConnectBssDesc)
2770 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302771 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002772 }
2773 else
2774 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002775 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 return (status);
2777 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002778 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2779 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002780
2781 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2782
2783 return (status);
2784}
Jeff Johnson295189b2012-06-20 16:38:30 -07002785eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2786{
2787 eHalStatus status = eHAL_STATUS_SUCCESS;
2788 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2789 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002790
2791 if (!pSession)
2792 {
2793 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2794 return eHAL_STATUS_FAILURE;
2795 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002796
2797 if(pSession->pConnectBssDesc)
2798 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302799 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002801 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2802 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2804
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302805 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002806 if(!HAL_STATUS_SUCCESS(status))
2807 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302808 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2809 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002810 }
2811
Jeff Johnson295189b2012-06-20 16:38:30 -07002812 return (status);
2813}
2814
Jeff Johnson295189b2012-06-20 16:38:30 -07002815eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2816{
2817 eHalStatus status = eHAL_STATUS_SUCCESS;
2818 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2819 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002820
2821 if(!pSession)
2822 {
2823 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2824 return eHAL_STATUS_FAILURE;
2825 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002826
2827 // If no BSS description was found in this connection (happens with start IBSS), then
2828 // nix the BSS description that we keep around for the connected BSS) and get out...
2829 if(NULL == pBssDesc)
2830 {
2831 csrFreeConnectBssDesc(pMac, sessionId);
2832 }
2833 else
2834 {
2835 size = pBssDesc->length + sizeof( pBssDesc->length );
2836 if(NULL != pSession->pConnectBssDesc)
2837 {
2838 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2839 {
2840 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2841 csrFreeConnectBssDesc(pMac, sessionId);
2842 }
2843 }
2844 if(NULL == pSession->pConnectBssDesc)
2845 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302846 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302848 if (NULL == pSession->pConnectBssDesc)
2849 status = eHAL_STATUS_FAILURE;
2850 else
2851 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2852 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 return (status);
2854}
2855
Jeff Johnson295189b2012-06-20 16:38:30 -07002856eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2857 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2858 tDot11fBeaconIEs *pIes)
2859{
2860 eHalStatus status = eHAL_STATUS_SUCCESS;
2861 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302863 if (pIes == NULL)
2864 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002865
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 do
2867 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302868 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2869 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 //get qos
2871 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2872 //get SSID
2873 if(pIes->SSID.present)
2874 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302875 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2877 }
2878 else
2879 pBssConfig->SSID.length = 0;
2880 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2881 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002882 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 //Return failed if profile doesn't have an SSID either.
2884 if(pProfile->SSIDs.numOfSSIDs == 0)
2885 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002886 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 status = eHAL_STATUS_FAILURE;
2888 break;
2889 }
2890 }
2891 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2892 {
2893 pBssConfig->eBand = eCSR_BAND_5G;
2894 }
2895 else
2896 {
2897 pBssConfig->eBand = eCSR_BAND_24;
2898 }
2899 //phymode
2900 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2901 {
2902 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2903 }
2904 else
2905 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002906 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 //force it
2908 if(eCSR_BAND_24 == pBssConfig->eBand)
2909 {
2910 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2911 }
2912 else
2913 {
2914 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2915 }
2916 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002917 //Qos
2918 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2919 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2920 {
2921 //Joining BSS is not 11n capable and WMM is disabled on client.
2922 //Disable QoS and WMM
2923 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2924 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302925
2926 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302927 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302928 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2929 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2930 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2931 {
2932 //Joining BSS is 11n capable and WMM is disabled on AP.
2933 //Assume all HT AP's are QOS AP's and enable WMM
2934 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2935 }
2936
Jeff Johnson295189b2012-06-20 16:38:30 -07002937 //auth type
2938 switch( pProfile->negotiatedAuthType )
2939 {
2940 default:
2941 case eCSR_AUTH_TYPE_WPA:
2942 case eCSR_AUTH_TYPE_WPA_PSK:
2943 case eCSR_AUTH_TYPE_WPA_NONE:
2944 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2945 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2946 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002947 case eCSR_AUTH_TYPE_SHARED_KEY:
2948 pBssConfig->authType = eSIR_SHARED_KEY;
2949 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 case eCSR_AUTH_TYPE_AUTOSWITCH:
2951 pBssConfig->authType = eSIR_AUTO_SWITCH;
2952 break;
2953 }
2954 //short slot time
2955 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2956 {
2957 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2958 }
2959 else
2960 {
2961 pBssConfig->uShortSlotTime = 0;
2962 }
2963 if(pBssConfig->BssCap.ibss)
2964 {
2965 //We don't support 11h on IBSS
2966 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2967 }
2968 else
2969 {
2970 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2971 }
2972 //power constraint
2973 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2974 //heartbeat
2975 if ( CSR_IS_11A_BSS( pBssDesc ) )
2976 {
2977 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2978 }
2979 else
2980 {
2981 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2982 }
2983 //Join timeout
2984 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002985 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002986 if ( pBssDesc->beaconInterval )
2987 {
2988 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002989 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002990 }
2991 else
2992 {
2993 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2994 }
2995 //validate CB
2996 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
2997 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 return (status);
2999}
3000
Jeff Johnson295189b2012-06-20 16:38:30 -07003001static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3002 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3003{
3004 eHalStatus status = eHAL_STATUS_SUCCESS;
3005 tANI_U8 operationChannel = 0;
3006 tANI_U8 qAPisEnabled = FALSE;
3007 //SSID
3008 pBssConfig->SSID.length = 0;
3009 if(pProfile->SSIDs.numOfSSIDs)
3010 {
3011 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303012 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3013 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003014 }
3015 else
3016 {
3017 //SSID must present
3018 return eHAL_STATUS_FAILURE;
3019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 //Settomg up the capabilities
3021 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3022 {
3023 pBssConfig->BssCap.ibss = 1;
3024 }
3025 else
3026 {
3027 pBssConfig->BssCap.ess = 1;
3028 }
3029 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3030 {
3031 pBssConfig->BssCap.privacy = 1;
3032 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003033 pBssConfig->eBand = pMac->roam.configParam.eBand;
3034 //phymode
3035 if(pProfile->ChannelInfo.ChannelList)
3036 {
3037 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3040 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 //QOS
3042 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 if ( pBssConfig->BssCap.ess == 1 )
3044 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003045 /*For Softap case enable WMM*/
3046 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3047 qAPisEnabled = TRUE;
3048 }
3049 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3051 qAPisEnabled = TRUE;
3052 } else {
3053 qAPisEnabled = FALSE;
3054 }
3055 } else {
3056 qAPisEnabled = TRUE;
3057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3059 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3060 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3061 )
3062 {
3063 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3064 } else {
3065 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3066 }
3067
3068 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003069 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003070 {
3071 default:
3072 case eCSR_AUTH_TYPE_WPA:
3073 case eCSR_AUTH_TYPE_WPA_PSK:
3074 case eCSR_AUTH_TYPE_WPA_NONE:
3075 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3076 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3077 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 case eCSR_AUTH_TYPE_SHARED_KEY:
3079 pBssConfig->authType = eSIR_SHARED_KEY;
3080 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 case eCSR_AUTH_TYPE_AUTOSWITCH:
3082 pBssConfig->authType = eSIR_AUTO_SWITCH;
3083 break;
3084 }
3085 //short slot time
3086 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3087 {
3088 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3089 }
3090 else
3091 {
3092 pBssConfig->uShortSlotTime = 0;
3093 }
3094 //power constraint. We don't support 11h on IBSS
3095 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3096 pBssConfig->uPowerLimit = 0;
3097 //heartbeat
3098 if ( eCSR_BAND_5G == pBssConfig->eBand )
3099 {
3100 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3101 }
3102 else
3103 {
3104 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3105 }
3106 //Join timeout
3107 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003108
Jeff Johnson295189b2012-06-20 16:38:30 -07003109 return (status);
3110}
Jeff Johnson295189b2012-06-20 16:38:30 -07003111static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3112{
3113 eHalStatus status = eHAL_STATUS_FAILURE;
3114 tDot11fBeaconIEs *pIes = NULL;
3115
3116 do
3117 {
3118 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3119 {
3120 //err msg
3121 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003122 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 break;
3124 }
3125 //check if the AP is QAP & it supports APSD
3126 if( CSR_IS_QOS_BSS(pIes) )
3127 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303128 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 }
3130 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303131
3132 if (NULL != pIes)
3133 {
3134 vos_mem_free(pIes);
3135 }
3136
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 return status;
3138}
3139
Jeff Johnson295189b2012-06-20 16:38:30 -07003140void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3141{
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3143 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3144 // See !!Note: below in this function...
3145 tANI_U32 PrivacyEnabled = 0;
3146 tANI_U32 RsnEnabled = 0;
3147 tANI_U32 WepDefaultKeyId = 0;
3148 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3149 tANI_U32 Key0Length = 0;
3150 tANI_U32 Key1Length = 0;
3151 tANI_U32 Key2Length = 0;
3152 tANI_U32 Key3Length = 0;
3153
3154 // Reserve for the biggest key
3155 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3156 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3157 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3158 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3159
3160 switch ( pProfile->negotiatedUCEncryptionType )
3161 {
3162 case eCSR_ENCRYPT_TYPE_NONE:
3163
3164 // for NO encryption, turn off Privacy and Rsn.
3165 PrivacyEnabled = 0;
3166 RsnEnabled = 0;
3167
3168 // WEP key length and Wep Default Key ID don't matter in this case....
3169
3170 // clear out the WEP keys that may be hanging around.
3171 Key0Length = 0;
3172 Key1Length = 0;
3173 Key2Length = 0;
3174 Key3Length = 0;
3175
3176 break;
3177
3178 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303179 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003180
3181 // Privacy is ON. NO RSN for Wep40 static key.
3182 PrivacyEnabled = 1;
3183 RsnEnabled = 0;
3184
3185 // Set the Wep default key ID.
3186 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 // Wep key size if 5 bytes (40 bits).
3188 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3189
3190 // set encryption keys in the CFG database or clear those that are not present in this profile.
3191 if ( pProfile->Keys.KeyLength[0] )
3192 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303193 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3194 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3196 }
3197 else
3198 {
3199 Key0Length = 0;
3200 }
3201
3202 if ( pProfile->Keys.KeyLength[1] )
3203 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303204 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3205 WNI_CFG_WEP_KEY_LENGTH_5);
3206 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 }
3208 else
3209 {
3210 Key1Length = 0;
3211 }
3212
3213 if ( pProfile->Keys.KeyLength[2] )
3214 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303215 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3216 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3218 }
3219 else
3220 {
3221 Key2Length = 0;
3222 }
3223
3224 if ( pProfile->Keys.KeyLength[3] )
3225 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303226 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3227 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003228 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3229 }
3230 else
3231 {
3232 Key3Length = 0;
3233 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 break;
3235
3236 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303237 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003238
3239 // Privacy is ON. NO RSN for Wep40 static key.
3240 PrivacyEnabled = 1;
3241 RsnEnabled = 0;
3242
3243 // Set the Wep default key ID.
3244 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3245
3246 // Wep key size if 13 bytes (104 bits).
3247 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3248
3249 // set encryption keys in the CFG database or clear those that are not present in this profile.
3250 if ( pProfile->Keys.KeyLength[0] )
3251 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303252 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3253 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003254 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3255 }
3256 else
3257 {
3258 Key0Length = 0;
3259 }
3260
3261 if ( pProfile->Keys.KeyLength[1] )
3262 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303263 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3264 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003265 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3266 }
3267 else
3268 {
3269 Key1Length = 0;
3270 }
3271
3272 if ( pProfile->Keys.KeyLength[2] )
3273 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303274 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3275 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003276 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3277 }
3278 else
3279 {
3280 Key2Length = 0;
3281 }
3282
3283 if ( pProfile->Keys.KeyLength[3] )
3284 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303285 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3286 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3288 }
3289 else
3290 {
3291 Key3Length = 0;
3292 }
3293
3294 break;
3295
Jeff Johnson295189b2012-06-20 16:38:30 -07003296 case eCSR_ENCRYPT_TYPE_TKIP:
3297 case eCSR_ENCRYPT_TYPE_AES:
3298#ifdef FEATURE_WLAN_WAPI
3299 case eCSR_ENCRYPT_TYPE_WPI:
3300#endif /* FEATURE_WLAN_WAPI */
3301 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3302 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3303 PrivacyEnabled = (0 != fPrivacy);
3304
3305 // turn on RSN enabled for WPA associations
3306 RsnEnabled = 1;
3307
3308 // WEP key length and Wep Default Key ID don't matter in this case....
3309
3310 // clear out the static WEP keys that may be hanging around.
3311 Key0Length = 0;
3312 Key1Length = 0;
3313 Key2Length = 0;
3314 Key3Length = 0;
3315
3316 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003317 default:
3318 PrivacyEnabled = 0;
3319 RsnEnabled = 0;
3320 break;
3321 }
3322
3323 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3324 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3325 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3326 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3327 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3328 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3329 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3330 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3331}
3332
Jeff Johnson295189b2012-06-20 16:38:30 -07003333static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3334{
3335 tANI_U32 len = 0;
3336 if(pSSID->length <= WNI_CFG_SSID_LEN)
3337 {
3338 len = pSSID->length;
3339 }
3340 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3341}
3342
Jeff Johnson295189b2012-06-20 16:38:30 -07003343eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3344{
3345 eHalStatus status = eHAL_STATUS_SUCCESS;
3346 tANI_U32 QoSEnabled;
3347 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 // set the CFG enable/disable variables based on the qosType being configured...
3349 switch( qosType )
3350 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3352 QoSEnabled = FALSE;
3353 WmeEnabled = TRUE;
3354 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003355 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3356 QoSEnabled = FALSE;
3357 WmeEnabled = TRUE;
3358 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003359 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3360 QoSEnabled = FALSE;
3361 WmeEnabled = TRUE;
3362 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003363 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3364 QoSEnabled = TRUE;
3365 WmeEnabled = FALSE;
3366 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 case eCSR_MEDIUM_ACCESS_11e_HCF:
3368 QoSEnabled = TRUE;
3369 WmeEnabled = FALSE;
3370 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 default:
3372 case eCSR_MEDIUM_ACCESS_DCF:
3373 QoSEnabled = FALSE;
3374 WmeEnabled = FALSE;
3375 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003376 }
3377 //save the WMM setting for later use
3378 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303379 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 return (status);
3381}
Jeff Johnson295189b2012-06-20 16:38:30 -07003382static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3383 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3384{
3385 eHalStatus status = eHAL_STATUS_FAILURE;
3386 int i;
3387 eCsrCfgDot11Mode cfgDot11Mode;
3388 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303389 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3390 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003391 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003392
3393 if( NULL != pIes )
3394 {
3395 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 // Originally, we thought that for 11a networks, the 11a rates are always
3397 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3398 // appear in the Operational Rate set. Consequently, in either case, we
3399 // would blindly put the rates we support into our Operational Rate set
3400 // (including the basic rates, which we have already verified are
3401 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 // However, it turns out that this is not always the case. Some AP's
3403 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3404 // too. Now, we're a little more careful:
3405 pDstRate = pOpRateSet->rate;
3406 if(pIes->SuppRates.present)
3407 {
3408 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3409 {
3410 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3411 {
3412 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003413 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 }
3415 }
3416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3418 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3419 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3420 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3421 {
3422 // If there are Extended Rates in the beacon, we will reflect those
3423 // extended rates that we support in out Extended Operational Rate
3424 // set:
3425 pDstRate = pExRateSet->rate;
3426 if(pIes->ExtSuppRates.present)
3427 {
3428 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3429 {
3430 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3431 {
3432 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3433 pExRateSet->numRates++;
3434 }
3435 }
3436 }
3437 }
3438 }//Parsing BSSDesc
3439 else
3440 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003441 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 }
3443 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3444 return status;
3445}
3446
3447static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3448 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3449{
3450 int i;
3451 tANI_U8 *pDstRate;
3452 eCsrCfgDot11Mode cfgDot11Mode;
3453 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3454 tANI_U32 OperationalRatesLength = 0;
3455 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3456 tANI_U32 ExtendedOperationalRatesLength = 0;
3457 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3458 tANI_U32 ProprietaryOperationalRatesLength = 0;
3459 tANI_U32 PropRatesEnable = 0;
3460 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3461 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003462 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003463 if( NULL != pIes )
3464 {
3465 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 // Originally, we thought that for 11a networks, the 11a rates are always
3467 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3468 // appear in the Operational Rate set. Consequently, in either case, we
3469 // would blindly put the rates we support into our Operational Rate set
3470 // (including the basic rates, which we have already verified are
3471 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 // However, it turns out that this is not always the case. Some AP's
3473 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3474 // too. Now, we're a little more careful:
3475 pDstRate = OperationalRates;
3476 if(pIes->SuppRates.present)
3477 {
3478 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3479 {
3480 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3481 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3482 {
3483 *pDstRate++ = pIes->SuppRates.rates[ i ];
3484 OperationalRatesLength++;
3485 }
3486 }
3487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003488 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3489 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3490 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3491 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3492 {
3493 // If there are Extended Rates in the beacon, we will reflect those
3494 // extended rates that we support in out Extended Operational Rate
3495 // set:
3496 pDstRate = ExtendedOperationalRates;
3497 if(pIes->ExtSuppRates.present)
3498 {
3499 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3500 {
3501 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3502 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3503 {
3504 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3505 ExtendedOperationalRatesLength++;
3506 }
3507 }
3508 }
3509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003510 // Enable proprietary MAC features if peer node is Airgo node and STA
3511 // user wants to use them
3512 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3513 {
3514 PropRatesEnable = 1;
3515 }
3516 else
3517 {
3518 PropRatesEnable = 0;
3519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003520 // For ANI network companions, we need to populate the proprietary rate
3521 // set with any proprietary rates we found in the beacon, only if user
3522 // allows them...
3523 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3524 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3525 {
3526 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3527 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3528 {
3529 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3530 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303531 vos_mem_copy(ProprietaryOperationalRates,
3532 pIes->Airgo.PropSuppRates.rates,
3533 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 }
3535 else {
3536 // No proprietary modes...
3537 ProprietaryOperationalRatesLength = 0;
3538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 /* Get MCS Rate */
3540 pDstRate = MCSRateIdxSet;
3541 if ( pIes->HTCaps.present )
3542 {
3543 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3544 {
3545 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3546 {
3547 MCSRateLength++;
3548 *pDstRate++ = i;
3549 }
3550 }
3551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003552 // Set the operational rate set CFG variables...
3553 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3554 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3555 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3556 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3557 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3558 ProprietaryOperationalRates,
3559 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3560 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3561 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3562 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3563 }//Parsing BSSDesc
3564 else
3565 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003566 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003567 }
3568}
3569
Jeff Johnson295189b2012-06-20 16:38:30 -07003570static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3571 tCsrRoamProfile *pProfile )
3572{
3573 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3574 { 8,
3575 { SIR_MAC_RATE_6,
3576 SIR_MAC_RATE_9,
3577 SIR_MAC_RATE_12,
3578 SIR_MAC_RATE_18,
3579 SIR_MAC_RATE_24,
3580 SIR_MAC_RATE_36,
3581 SIR_MAC_RATE_48,
3582 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3584 { 4,
3585 { SIR_MAC_RATE_1,
3586 SIR_MAC_RATE_2,
3587 SIR_MAC_RATE_5_5,
3588 SIR_MAC_RATE_11 } } };
3589
3590
3591 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3592 { SIR_MAC_RATE_72,
3593 SIR_MAC_RATE_96,
3594 SIR_MAC_RATE_108 } };
3595 eCsrCfgDot11Mode cfgDot11Mode;
3596 eCsrBand eBand;
3597 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3598 tANI_U32 OperationalRatesLength = 0;
3599 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3600 tANI_U32 ExtendedOperationalRatesLength = 0;
3601 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3602 tANI_U32 ProprietaryOperationalRatesLength = 0;
3603 tANI_U32 PropRatesEnable = 0;
3604 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003605 if(pProfile->ChannelInfo.ChannelList)
3606 {
3607 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003609 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003610 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3611 // networks, the 11b rates appear in the Operational Rate set. In either case,
3612 // we can blindly put the rates we support into our Operational Rate set
3613 // (including the basic rates, which we have already verified are supported
3614 // earlier in the roaming decision).
3615 if ( eCSR_BAND_5G == eBand )
3616 {
3617 // 11a rates into the Operational Rate Set.
3618 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3619 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303620 vos_mem_copy(OperationalRates,
3621 DefaultSupportedRates11a.supportedRateSet.rate,
3622 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003623
3624 // Nothing in the Extended rate set.
3625 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 // populate proprietary rates if user allows them
3627 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3628 {
3629 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3630 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303631 vos_mem_copy(ProprietaryOperationalRates,
3632 DefaultSupportedPropRates.propRate,
3633 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 }
3635 else
3636 {
3637 // No proprietary modes
3638 ProprietaryOperationalRatesLength = 0;
3639 }
3640 }
3641 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3642 {
3643 // 11b rates into the Operational Rate Set.
3644 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3645 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303646 vos_mem_copy(OperationalRates,
3647 DefaultSupportedRates11b.supportedRateSet.rate,
3648 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 // Nothing in the Extended rate set.
3650 ExtendedOperationalRatesLength = 0;
3651 // No proprietary modes
3652 ProprietaryOperationalRatesLength = 0;
3653 }
3654 else
3655 {
3656 // 11G
3657
3658 // 11b rates into the Operational Rate Set.
3659 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3660 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303661 vos_mem_copy(OperationalRates,
3662 DefaultSupportedRates11b.supportedRateSet.rate,
3663 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003664
3665 // 11a rates go in the Extended rate set.
3666 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3667 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303668 vos_mem_copy(ExtendedOperationalRates,
3669 DefaultSupportedRates11a.supportedRateSet.rate,
3670 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003671
3672 // populate proprietary rates if user allows them
3673 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3674 {
3675 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3676 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303677 vos_mem_copy(ProprietaryOperationalRates,
3678 DefaultSupportedPropRates.propRate,
3679 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003680 }
3681 else
3682 {
3683 // No proprietary modes
3684 ProprietaryOperationalRatesLength = 0;
3685 }
3686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003687 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3688 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3689 {
3690 PropRatesEnable = 1;
3691 }
3692 else
3693 {
3694 PropRatesEnable = 0;
3695 }
3696
3697 // Set the operational rate set CFG variables...
3698 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3699 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3700 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3701 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3702 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3703 ProprietaryOperationalRates,
3704 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3705 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003706}
Jeff Johnson295189b2012-06-20 16:38:30 -07003707void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3708{
3709 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003710
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3712 tANI_U32 sessionId;
3713 tSmeCmd *pCommand = NULL;
3714
3715 if(NULL == pEntry)
3716 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003717 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003718 return;
3719 }
3720 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3721 sessionId = pCommand->sessionId;
3722
3723 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3724 {
3725 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3726 }
3727}
3728
Jeff Johnson295189b2012-06-20 16:38:30 -07003729//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3730tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3731{
3732 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3733 {
3734 return (WNI_CFG_PHY_MODE_11B);
3735 }
3736 else
3737 {
3738 if(eCSR_BAND_24 == band)
3739 return (WNI_CFG_PHY_MODE_11G);
3740 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 return (WNI_CFG_PHY_MODE_11A);
3742}
Jeff Johnson295189b2012-06-20 16:38:30 -07003743
Jeff Johnsone7245742012-09-05 17:12:55 -07003744
3745#ifdef WLAN_FEATURE_11AC
3746ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3747{
3748 switch ( aniCBMode )
3749 {
3750 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3751 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3752 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3753 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3754 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3755 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3756 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3757 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3758 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003759 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003760 return PHY_SINGLE_CHANNEL_CENTERED;
3761 }
3762}
3763#endif
3764
Jeff Johnson295189b2012-06-20 16:38:30 -07003765//pIes may be NULL
3766eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3767 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303768 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003769{
3770 eHalStatus status = eHAL_STATUS_SUCCESS;
3771 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3772 tANI_U8 channel = 0;
3773 //Make sure we have the domain info for the BSS we try to connect to.
3774 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303775 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003776 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303777 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003778 {
3779 //Make sure the 11d info from this BSSDesc can be applied
3780 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303781 if (VOS_TRUE == resetCountry)
3782 {
3783 csrApplyCountryInformation(pMac, FALSE);
3784 }
3785 else
3786 {
3787 csrApplyCountryInformation(pMac, TRUE);
3788 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 }
Kiran4a17ebe2013-01-31 10:43:43 -08003790 if ((csrIs11dSupported (pMac)) && pIes)
3791 {
3792 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003793 {
Kiran4a17ebe2013-01-31 10:43:43 -08003794 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003795 }
3796 else
3797 {
3798 //Let's also update the below to make sure we don't update CC while
3799 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303800 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003801 pBssDesc->bssId, sizeof(tSirMacAddr));
3802 }
Kiran4a17ebe2013-01-31 10:43:43 -08003803 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 //Qos
3806 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3807 //SSID
3808 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3809 //fragment threshold
3810 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3811 //RTS threshold
3812 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3813
3814 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3815
3816 //Auth type
3817 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3818 //encryption type
3819 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3820 //short slot time
3821 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003822 //11d
3823 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3824 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3825 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003826 /*//11h
3827 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3828 */
3829 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3830 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003831
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003832 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003833 {
3834 channel = pProfile->operationChannel;
3835 }
3836 else
3837 {
3838 if(pBssDesc)
3839 {
3840 channel = pBssDesc->channelId;
3841 }
3842 }
3843 if(0 != channel)
3844 {
3845 if(CSR_IS_CHANNEL_24GHZ(channel))
3846 {//for now if we are on 2.4 Ghz, CB will be always disabled
3847 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3848 }
3849 else
3850 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003851 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 }
3853 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003854#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003855 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3856 // in function csrConvertCBIniValueToPhyCBState()
3857 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3858 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003859 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003860 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003861 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003862 }
3863 else
3864 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003865 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003866 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003867 }
3868 else
3869#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003870 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3871 //Rate
3872 //Fixed Rate
3873 if(pBssDesc)
3874 {
3875 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3876 }
3877 else
3878 {
3879 csrSetCfgRateSetFromProfile(pMac, pProfile);
3880 }
3881 //Make this the last CFG to set. The callback will trigger a join_req
3882 //Join time out
3883 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3884
3885 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 return (status);
3887}
3888
Jeff Johnson295189b2012-06-20 16:38:30 -07003889eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3890 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3891{
3892 eHalStatus status;
3893 tBssConfigParam *pBssConfig;
3894 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003895
3896 if(!pSession)
3897 {
3898 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3899 return eHAL_STATUS_FAILURE;
3900 }
3901
Kiet Lam64c1b492013-07-12 13:56:44 +05303902 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
3903 if ( NULL == pBssConfig )
3904 status = eHAL_STATUS_FAILURE;
3905 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303907 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003908 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3909 if(HAL_STATUS_SUCCESS(status))
3910 {
3911 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003912 /* This will allow to pass cbMode during join req */
3913 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 //For IBSS, we need to prepare some more information
3915 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 )
3918 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003919 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 }
3921 // If we are in an IBSS, then stop the IBSS...
3922 ////Not worry about WDS connection for now
3923 if ( csrIsConnStateIbss( pMac, sessionId ) )
3924 {
3925 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3926 }
3927 else
3928 {
3929 // if we are in an Infrastructure association....
3930 if ( csrIsConnStateInfra( pMac, sessionId ) )
3931 {
3932 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3933 // across SSIDs (roaming to a new SSID)... //
3934 //Not worry about WDS connection for now
3935 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303936 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003937 {
3938 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303939 status = csrRoamIssueDisassociate( pMac, sessionId,
3940 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003941 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303942 else
3943 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3945 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303946 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303948 // Set parameters for this Bss.
3949 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3950 pBssDesc, pBssConfig,
3951 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303955 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 {
3957 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3958 // Nothing to stop.
3959 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303961 )
3962 {
3963 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3964 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3965 // Set parameters for this Bss.
3966 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3967 pBssDesc, pBssConfig,
3968 pIes, is11rRoamingFlag);
3969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 }
3971 }
3972 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05303973 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 return (status);
3976}
3977
Jeff Johnson295189b2012-06-20 16:38:30 -07003978eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3979 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3980{
3981 eCsrJoinState eRoamState = eCsrContinueRoaming;
3982 eHalStatus status;
3983 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3984 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3985 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003986
3987 if(!pSession)
3988 {
3989 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3990 return (eCsrStopRoaming);
3991 }
3992
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 if( CSR_IS_WDS_STA( pProfile ) )
3994 {
3995 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3996 if( !HAL_STATUS_SUCCESS( status ) )
3997 {
3998 eRoamState = eCsrStopRoaming;
3999 }
4000 }
4001 else
4002 {
4003 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4004 {
4005 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4006 return (eCsrStopRoaming);
4007 }
4008 if ( csrIsInfraBssDesc( pBssDesc ) )
4009 {
4010 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4011 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4012 // have changed and handle the changes (without disturbing the current association).
4013
4014 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4015 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4016 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4017 )
4018 {
4019 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4020 // with Authenticating first. To force this, stop the current association (Disassociate) and
4021 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4022 // a new Association.
4023 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4024 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004025 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004026 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4027 {
4028 eRoamState = eCsrReassocToSelfNoCapChange;
4029 }
4030 else
4031 {
4032 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304034 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4036 if(HAL_STATUS_SUCCESS(status))
4037 {
4038 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004039 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304041 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4042 pBssDesc, &bssConfig,
4043 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 if(!HAL_STATUS_SUCCESS(status))
4045 {
4046 eRoamState = eCsrStopRoaming;
4047 }
4048 }
4049 else
4050 {
4051 eRoamState = eCsrStopRoaming;
4052 }
4053 }//same profile
4054 }
4055 else
4056 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304057 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4059 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304060 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4061 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304063 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304065 }
4066 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 {
4068 // 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 +05304069 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 // work much better.
4071 //
4072 //
4073 // stop the existing network before attempting to join the new network...
4074 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4075 {
4076 eRoamState = eCsrStopRoaming;
4077 }
4078 }
4079 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304080 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004081 {
4082 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4083 {
4084 eRoamState = eCsrStopRoaming;
4085 }
4086 }
4087 if( pIesLocal && !pScanResult->pvIes )
4088 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304089 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 }
4091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 return( eRoamState );
4093}
4094
Jeff Johnson295189b2012-06-20 16:38:30 -07004095eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4096 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4097{
4098 eHalStatus status = eHAL_STATUS_SUCCESS;
4099 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304100 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 roamInfo.pBssDesc = pBssDesc;
4102 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4103 return (status);
4104}
Jeff Johnson295189b2012-06-20 16:38:30 -07004105//In case no matching BSS is found, use whatever default we can find
4106static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4107{
4108 //Need to get all negotiated types in place first
4109 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004110 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 {
4112 default:
4113 case eCSR_AUTH_TYPE_WPA:
4114 case eCSR_AUTH_TYPE_WPA_PSK:
4115 case eCSR_AUTH_TYPE_WPA_NONE:
4116 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4117 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4118 break;
4119
4120 case eCSR_AUTH_TYPE_SHARED_KEY:
4121 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4122 break;
4123
4124 case eCSR_AUTH_TYPE_AUTOSWITCH:
4125 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4126 break;
4127 }
4128 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4129 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4130 //In this case, the multicast encryption needs to follow the uncast ones.
4131 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4132 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4133}
4134
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004135
4136static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4137{
4138 switch(pCommand->u.roamCmd.roamReason)
4139 {
4140 case eCsrLostLink1:
4141 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4142 break;
4143 case eCsrLostLink2:
4144 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4145 break;
4146 case eCsrLostLink3:
4147 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4148 break;
4149 default:
4150 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4151 pCommand->u.roamCmd.roamReason);
4152 break;
4153 }
4154}
4155
Jeff Johnson295189b2012-06-20 16:38:30 -07004156static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4157{
4158 eHalStatus status;
4159 tCsrScanResult *pScanResult = NULL;
4160 eCsrJoinState eRoamState = eCsrStopRoaming;
4161 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4162 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4163 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4164#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4165 v_U8_t acm_mask = 0;
4166#endif
4167 tANI_U32 sessionId = pCommand->sessionId;
4168 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4169 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4170 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004171
4172 if(!pSession)
4173 {
4174 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4175 return (eCsrStopRoaming);
4176 }
4177
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 do
4179 {
4180 // Check for Cardbus eject condition, before trying to Roam to any BSS
4181 //***if( !balIsCardPresent(pAdapter) ) break;
4182
Kiet Lam64c1b492013-07-12 13:56:44 +05304183 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004184 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 if(NULL != pBSSList)
4186 {
4187 // When handling AP's capability change, continue to associate to
4188 // same BSS and make sure pRoamBssEntry is not Null.
4189 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4190 {
4191 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4192 {
4193 //Try the first BSS
4194 pCommand->u.roamCmd.pLastRoamBss = NULL;
4195 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4196 }
4197 else
4198 {
4199 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4200 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4201 {
4202 //Done with all the BSSs
4203 //In this case, will tell HDD the completion
4204 break;
4205 }
4206 else
4207 {
4208 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304209 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4211 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4212 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4213 pRoamInfo = &roamInfo;
4214 }
4215 }
4216 while(pCommand->u.roamCmd.pRoamBssEntry)
4217 {
4218 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004219 /*If concurrency enabled take the concurrent connected channel first. */
4220 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004221 if (vos_concurrent_sessions_running() &&
4222 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004223 {
4224 concurrentChannel =
4225 csrGetConcurrentOperationChannel(pMac);
4226 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004227 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004228 if ((concurrentChannel) &&
4229 (concurrentChannel ==
4230 pScanResult->Result.BssDescriptor.channelId))
4231 {
4232 //make this 0 because we do not want the
4233 //below check to pass as we don't want to
4234 //connect on other channel
4235 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4236 FL("Concurrent channel match =%d"),
4237 concurrentChannel);
4238 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 }
4240 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004241
4242 if (!concurrentChannel)
4243 {
4244
4245 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4246 sessionId, &pScanResult->Result.BssDescriptor,
4247 pCommand->u.roamCmd.roamId)))
4248 {
4249 //Ok to roam this
4250 break;
4251 }
4252 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004253 else
4254 {
4255 eRoamState = eCsrStopRoamingDueToConcurrency;
4256 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4258 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4259 {
4260 //Done with all the BSSs
4261 fDone = eANI_BOOLEAN_TRUE;
4262 break;
4263 }
4264 }
4265 if(fDone)
4266 {
4267 break;
4268 }
4269 }
4270 }
4271 //We have something to roam, tell HDD when it is infra.
4272 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4273 //For WDS, the indication is eCSR_ROAM_WDS_IND
4274 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4275 {
4276 if(pRoamInfo)
4277 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004278 if(pSession->bRefAssocStartCnt)
4279 {
4280 pSession->bRefAssocStartCnt--;
4281 //Complete the last association attemp because a new one is about to be tried
4282 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4283 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004285 }
4286 }
4287 /* If the roaming has stopped, not to continue the roaming command*/
4288 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4289 {
4290 //No need to complete roaming here as it already completes
4291 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4292 pCommand->u.roamCmd.roamReason);
4293 eRoamState = eCsrStopRoaming;
4294 csrSetAbortRoamingCommand(pMac, pCommand);
4295 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304297 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 if(pScanResult)
4299 {
4300 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004301 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4302 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004303 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 fDone = eANI_BOOLEAN_TRUE;
4305 eRoamState = eCsrStopRoaming;
4306 break;
4307 }
4308 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4309 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4310 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4311 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4312 CSR_IS_QOS_BSS(pIesLocal) &&
4313 CSR_IS_UAPSD_BSS(pIesLocal) )
4314 {
4315#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004316 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4317 pIesLocal);
4318 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4319#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004320 }
4321 else
4322 {
4323 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4324 }
4325 if( pIesLocal && !pScanResult->Result.pvIes)
4326 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304327 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004328 }
4329 }
4330 else
4331 {
4332 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4333 }
4334 roamInfo.pProfile = pProfile;
4335 pSession->bRefAssocStartCnt++;
4336 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4337 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004339 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4340 {
4341 // If this is a start IBSS profile, then we need to start the IBSS.
4342 if ( CSR_IS_START_IBSS(pProfile) )
4343 {
4344 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 // Attempt to start this IBSS...
4346 csrRoamAssignDefaultParam( pMac, pCommand );
4347 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4348 if(HAL_STATUS_SUCCESS(status))
4349 {
4350 if ( fSameIbss )
4351 {
4352 eRoamState = eCsrStartIbssSameIbss;
4353 }
4354 else
4355 {
4356 eRoamState = eCsrContinueRoaming;
4357 }
4358 }
4359 else
4360 {
4361 //it somehow fail need to stop
4362 eRoamState = eCsrStopRoaming;
4363 }
4364 break;
4365 }
4366 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004367 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004368 )
4369 {
4370 // Attempt to start this WDS...
4371 csrRoamAssignDefaultParam( pMac, pCommand );
4372 /* For AP WDS, we dont have any BSSDescription */
4373 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4374 if(HAL_STATUS_SUCCESS(status))
4375 {
4376 eRoamState = eCsrContinueRoaming;
4377 }
4378 else
4379 {
4380 //it somehow fail need to stop
4381 eRoamState = eCsrStopRoaming;
4382 }
4383 }
4384 else
4385 {
4386 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004387 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004388 eRoamState = eCsrStopRoaming;
4389 break;
4390 }
4391 }
4392 else //We have BSS
4393 {
4394 //Need to assign these value because they are used in csrIsSameProfile
4395 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4396 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4397 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4398 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4399 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4400 {
4401 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4402 {
4403 eRoamState = eCsrStartIbssSameIbss;
4404 break;
4405 }
4406 }
4407 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4408 {
4409 //trying to connect to the one already connected
4410 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4411 eRoamState = eCsrReassocToSelfNoCapChange;
4412 break;
4413 }
4414 // Attempt to Join this Bss...
4415 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4416 break;
4417 }
4418
4419 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4421 {
4422 //Need to indicate association_completion if association_start has been done
4423 if(pSession->bRefAssocStartCnt > 0)
4424 {
4425 pSession->bRefAssocStartCnt--;
4426 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004427 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4429 eCSR_ROAM_ASSOCIATION_COMPLETION,
4430 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4431 }
4432 }
4433
4434 return( eRoamState );
4435}
4436
Jeff Johnson295189b2012-06-20 16:38:30 -07004437static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4438{
4439 eHalStatus status = eHAL_STATUS_SUCCESS;
4440 eCsrJoinState RoamState;
4441 tANI_U32 sessionId = pCommand->sessionId;
4442
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 //***if( hddIsRadioStateOn( pAdapter ) )
4444 {
4445 // Attept to join a Bss...
4446 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004447
Jeff Johnson295189b2012-06-20 16:38:30 -07004448 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004449 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 {
4451 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004452 // and if connected in Infrastructure mode...
4453 if ( csrIsConnStateInfra(pMac, sessionId) )
4454 {
4455 //... then we need to issue a disassociation
4456 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4457 if(!HAL_STATUS_SUCCESS(status))
4458 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004459 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 //roam command is completed by caller in the failed case
4461 fComplete = eANI_BOOLEAN_TRUE;
4462 }
4463 }
4464 else if( csrIsConnStateIbss(pMac, sessionId) )
4465 {
4466 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4467 if(!HAL_STATUS_SUCCESS(status))
4468 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004469 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 //roam command is completed by caller in the failed case
4471 fComplete = eANI_BOOLEAN_TRUE;
4472 }
4473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4475 {
4476 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4477 if(!HAL_STATUS_SUCCESS(status))
4478 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004479 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 //roam command is completed by caller in the failed case
4481 fComplete = eANI_BOOLEAN_TRUE;
4482 }
4483 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004484 else
4485 {
4486 fComplete = eANI_BOOLEAN_TRUE;
4487 }
4488 if(fComplete)
4489 {
4490 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004491 if(eCsrStopRoamingDueToConcurrency == RoamState)
4492 {
4493 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4494 }
4495 else
4496 {
4497 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 }
4500 }
4501 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4502 {
4503 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4504 }
4505 else if ( eCsrStartIbssSameIbss == RoamState )
4506 {
4507 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4508 }
4509 }//hddIsRadioStateOn
4510
4511 return status;
4512}
Jeff Johnson295189b2012-06-20 16:38:30 -07004513eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4514{
4515 tANI_U32 sessionId;
4516 tCsrRoamSession *pSession;
4517 tCsrScanResult *pScanResult = NULL;
4518 tSirBssDescription *pBssDesc = NULL;
4519 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 sessionId = pCommand->sessionId;
4521 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004522
4523 if(!pSession)
4524 {
4525 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4526 return eHAL_STATUS_FAILURE;
4527 }
4528
Jeff Johnson295189b2012-06-20 16:38:30 -07004529 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4530 {
4531 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004532 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004533 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4534 return eHAL_STATUS_FAILURE;
4535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 if (pCommand->u.roamCmd.pRoamBssEntry)
4537 {
4538 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4539 pBssDesc = &pScanResult->Result.BssDescriptor;
4540 }
4541 else
4542 {
4543 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004544 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4546 return eHAL_STATUS_FAILURE;
4547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4549 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4550 return status;
4551}
4552
Jeff Johnson295189b2012-06-20 16:38:30 -07004553eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4554{
4555 eHalStatus status = eHAL_STATUS_SUCCESS;
4556 tCsrRoamInfo roamInfo;
4557 tANI_U32 sessionId = pCommand->sessionId;
4558 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004559
4560 if(!pSession)
4561 {
4562 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4563 return eHAL_STATUS_FAILURE;
4564 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004565
4566 switch ( pCommand->u.roamCmd.roamReason )
4567 {
4568 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004570 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004572 case eCsrSmeIssuedDisassocForHandoff:
4573 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4574#if 0 // TODO : Confirm this change
4575 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4576#else
4577 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4578#endif
4579
4580 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004583 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004586 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004587 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004589 case eCsrHddIssuedReassocToSameAP:
4590 case eCsrSmeIssuedReassocToSameAP:
4591 {
4592 tDot11fBeaconIEs *pIes = NULL;
4593
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 if( pSession->pConnectBssDesc )
4595 {
4596 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4597 if(!HAL_STATUS_SUCCESS(status) )
4598 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004599 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004600 }
4601 else
4602 {
4603 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4604 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4605 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4607 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4608 pSession->bRefAssocStartCnt++;
4609 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4610 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4611
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004612 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004613 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4614 &pCommand->u.roamCmd.roamProfile );
4615 if(!HAL_STATUS_SUCCESS(status))
4616 {
4617 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004618 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004619 }
4620
Kiet Lam64c1b492013-07-12 13:56:44 +05304621 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 pIes = NULL;
4623 }
4624 }
4625 break;
4626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004628 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4630 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4631 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004633 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4635 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004636
Jeff Johnson295189b2012-06-20 16:38:30 -07004637 case eCsrStopBss:
4638 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4639 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4640 break;
4641
4642 case eCsrForcedDisassocSta:
4643 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4644 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4645 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4646 pCommand->u.roamCmd.reason);
4647 break;
4648
4649 case eCsrForcedDeauthSta:
4650 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4651 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4652 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4653 pCommand->u.roamCmd.reason);
4654 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004655
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004656 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004657 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004658 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4659 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004660 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004661
4662 default:
4663 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4664
4665 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4666 {
4667 //Remember the roaming profile
4668 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304669 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4670 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304672 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4674 }
4675 }
4676
4677 //At this point, original uapsd_mask is saved in pCurRoamProfile
4678 //uapsd_mask in the pCommand may change from this point on.
4679
4680 // Attempt to roam with the new scan results (if we need to..)
4681 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004682 if(!HAL_STATUS_SUCCESS(status))
4683 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004684 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004686 break;
4687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004688 return (status);
4689}
4690
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004691void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4692{
4693 pCommand->u.roamCmd.pLastRoamBss = NULL;
4694 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4695 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304696 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004697}
4698
Jeff Johnson295189b2012-06-20 16:38:30 -07004699void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4700{
4701 if(pCommand->u.roamCmd.fReleaseBssList)
4702 {
4703 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4704 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4705 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4706 }
4707 if(pCommand->u.roamCmd.fReleaseProfile)
4708 {
4709 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4710 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4711 }
4712 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4713 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304714 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004715}
4716
Jeff Johnson295189b2012-06-20 16:38:30 -07004717void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4718{
Kiet Lam64c1b492013-07-12 13:56:44 +05304719 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004720}
Jeff Johnson295189b2012-06-20 16:38:30 -07004721void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4722{
4723 tListElem *pEntry;
4724 tSmeCmd *pCommand;
4725 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004726 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004727 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4728 if ( pEntry )
4729 {
4730 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004731 // If the head of the queue is Active and it is a ROAM command, remove
4732 // and put this on the Free queue.
4733 if ( eSmeCommandRoam == pCommand->command )
4734 {
4735 //we need to process the result first before removing it from active list because state changes
4736 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4737 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4738 if( fReleaseCommand )
4739 {
4740 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4741 {
4742 csrReleaseCommandRoam( pMac, pCommand );
4743 }
4744 else
4745 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004746 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004747 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 }
4749 }
4750 else
4751 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004752 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004753 pCommand->u.roamCmd.roamReason );
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 ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 }
4760 }
4761 else
4762 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004763 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004764 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004765 if( fReleaseCommand )
4766 {
4767 smeProcessPendingQueue( pMac );
4768 }
4769}
4770
Jeff Johnson295189b2012-06-20 16:38:30 -07004771void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4772{
4773 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004774 if(!pSession)
4775 {
4776 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4777 return;
4778 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304779 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4780 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004781 pSession->NumPmkidCandidate = 0;
4782}
Jeff Johnson295189b2012-06-20 16:38:30 -07004783#ifdef FEATURE_WLAN_WAPI
4784void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4785{
4786 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004787 if(!pSession)
4788 {
4789 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4790 return;
4791 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304792 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4793 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004794 pSession->NumBkidCandidate = 0;
4795}
4796#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004797extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4798
Jeff Johnson295189b2012-06-20 16:38:30 -07004799static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4800 tSirBssDescription *pSirBssDesc,
4801 tDot11fBeaconIEs *pIes)
4802{
4803 eHalStatus status = eHAL_STATUS_SUCCESS;
4804 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4805 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004806
4807 if(!pSession)
4808 {
4809 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4810 return eHAL_STATUS_FAILURE;
4811 }
4812
Jeff Johnson295189b2012-06-20 16:38:30 -07004813 if((eCSR_AUTH_TYPE_WPA == authType) ||
4814 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4815 (eCSR_AUTH_TYPE_RSN == authType) ||
4816 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4817#if defined WLAN_FEATURE_VOWIFI_11R
4818 ||
4819 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4820 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4821#endif /* FEATURE_WLAN_WAPI */
4822#ifdef FEATURE_WLAN_WAPI
4823 ||
4824 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4825 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4826#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004827#ifdef WLAN_FEATURE_11W
4828 ||
4829 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4830#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004831 )
4832 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004833 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4834 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004835 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004836 }
4837 if( pIesLocal )
4838 {
4839 tANI_U32 nIeLen;
4840 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004841 if((eCSR_AUTH_TYPE_RSN == authType) ||
4842#if defined WLAN_FEATURE_VOWIFI_11R
4843 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4844 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4845#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004846#if defined WLAN_FEATURE_11W
4847 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4848#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4850 {
4851 if(pIesLocal->RSN.present)
4852 {
4853 //Calculate the actual length
4854 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4855 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4856 + 2 //akm_suite_count
4857 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4858 + 2; //reserved
4859 if( pIesLocal->RSN.pmkid_count )
4860 {
4861 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4862 }
4863 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304864 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4865 if (NULL == pSession->pWpaRsnRspIE)
4866 status = eHAL_STATUS_FAILURE;
4867 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304869 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004870 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4871 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4872 //copy upto akm_suites
4873 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304874 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4875 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004876 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304877 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4878 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004879 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304880 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4881 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004882 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004883 if( pIesLocal->RSN.pwise_cipher_suite_count )
4884 {
4885 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304886 vos_mem_copy(pIeBuf,
4887 pIesLocal->RSN.pwise_cipher_suites,
4888 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004889 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4890 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304891 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004892 pIeBuf += 2;
4893 if( pIesLocal->RSN.akm_suite_count )
4894 {
4895 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304896 vos_mem_copy(pIeBuf,
4897 pIesLocal->RSN.akm_suites,
4898 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004899 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4900 }
4901 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05304902 vos_mem_copy(pIeBuf,
4903 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
4904 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004905 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4906 }
4907 }
4908 }
4909 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4910 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4911 {
4912 if(pIesLocal->WPA.present)
4913 {
4914 //Calculate the actual length
4915 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4916 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4917 + 2 //auth_suite_count
4918 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4919 // The WPA capabilities follows the Auth Suite (two octects)--
4920 // this field is optional, and we always "send" zero, so just
4921 // remove it. This is consistent with our assumptions in the
4922 // frames compiler; c.f. bug 15234:
4923 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304924
4925 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4926 if ( NULL == pSession->pWpaRsnRspIE )
4927 status = eHAL_STATUS_FAILURE;
4928 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004929 {
4930 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4931 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4932 pIeBuf = pSession->pWpaRsnRspIE + 2;
4933 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05304934 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004935 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304936 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
4937 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004938 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304939 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
4940 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4942 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4943 }
4944 }
4945 }
4946#ifdef FEATURE_WLAN_WAPI
4947 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4948 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4949 {
4950 if(pIesLocal->WAPI.present)
4951 {
4952 //Calculate the actual length
4953 nIeLen = 4 //version + akm_suite_count
4954 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4955 + 2 //pwise_cipher_suite_count
4956 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4957 + 6; //gp_cipher_suite + preauth + reserved
4958 if( pIesLocal->WAPI.bkid_count )
4959 {
4960 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4961 }
4962
4963 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304964 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
4965 if ( NULL == pSession->pWapiRspIE )
4966 status = eHAL_STATUS_FAILURE;
4967 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 {
4969 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4970 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4971 pIeBuf = pSession->pWapiRspIE + 2;
4972 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05304973 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 pIeBuf += 4;
4975 if( pIesLocal->WAPI.akm_suite_count )
4976 {
4977 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304978 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
4979 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304981 }
4982 vos_mem_copy(pIeBuf,
4983 &pIesLocal->WAPI.unicast_cipher_suite_count,
4984 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4987 {
4988 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304989 vos_mem_copy( pIeBuf,
4990 pIesLocal->WAPI.unicast_cipher_suites,
4991 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4993 }
lukez3c809222013-05-03 10:23:02 -07004994 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05304995 vos_mem_copy(pIeBuf,
4996 pIesLocal->WAPI.multicast_cipher_suite,
4997 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07004998 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304999 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305000 vos_mem_copy(pIeBuf,
5001 pIesLocal->WAPI.multicast_cipher_suite + 4,
5002 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005003 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305004 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305005 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5006
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005007 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005008 if( pIesLocal->WAPI.bkid_count )
5009 {
5010 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305011 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5012 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005013 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5014 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305015 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005016 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005017 }
5018 }
5019#endif /* FEATURE_WLAN_WAPI */
5020 if( !pIes )
5021 {
5022 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305023 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005024 }
5025 }
5026 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005027 return (status);
5028}
5029
Jeff Johnson295189b2012-06-20 16:38:30 -07005030static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5031{
5032 v_U8_t bACWeights[WLANTL_MAX_AC];
5033 v_U8_t paramBk, paramBe, paramVi, paramVo;
5034 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005035 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5036 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5037 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5038 //This doesn't address the case where the lower AC needs a real higher weight
5039 if( pIEs->WMMParams.present )
5040 {
5041 //no change to the lowest ones
5042 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5043 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5044 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5045 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5046 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5047 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5048 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5049 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5050 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5051 {
5052 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5053 fWeightChange = VOS_TRUE;
5054 }
5055 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5056 {
5057 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5058 fWeightChange = VOS_TRUE;
5059 }
5060 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5061 {
5062 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5063 fWeightChange = VOS_TRUE;
5064 }
5065 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5066 {
5067 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5068 fWeightChange = VOS_TRUE;
5069 }
5070 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5071 {
5072 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5073 fWeightChange = VOS_TRUE;
5074 }
5075 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5076 {
5077 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5078 fWeightChange = VOS_TRUE;
5079 }
5080 if(fWeightChange)
5081 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005082 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 bACWeights[2], bACWeights[3]);
5084 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5085 }
5086 }
5087}
Jeff Johnson295189b2012-06-20 16:38:30 -07005088#ifdef WLAN_FEATURE_VOWIFI_11R
5089//Returns whether the current association is a 11r assoc or not
5090tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5091{
5092#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5093 return csrNeighborRoamIs11rAssoc(pMac);
5094#else
5095 return eANI_BOOLEAN_FALSE;
5096#endif
5097}
5098#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005099#ifdef FEATURE_WLAN_CCX
5100//Returns whether the current association is a CCX assoc or not
5101tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
5102{
5103#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5104 return csrNeighborRoamIsCCXAssoc(pMac);
5105#else
5106 return eANI_BOOLEAN_FALSE;
5107#endif
5108}
5109#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005110#ifdef FEATURE_WLAN_LFR
5111//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305112tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005113{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305114 tCsrRoamSession *pSession = NULL;
5115
5116 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5117 {
5118 pSession = CSR_GET_SESSION( pMac, sessionId );
5119 if (NULL != pSession->pCurRoamProfile)
5120 {
5121 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5122 {
5123 return eANI_BOOLEAN_FALSE;
5124 }
5125 }
5126 }
5127
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005128#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5129 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5130 {
5131 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5132 }
5133 else
5134#endif
5135 {
5136 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005137 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005138 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005139}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005140
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005141#ifdef FEATURE_WLAN_CCX
5142/* ---------------------------------------------------------------------------
5143
5144 \fn csrNeighborRoamIsCCXAssoc
5145
5146 \brief This function returns whether the current association is a CCX assoc or not
5147
5148 \param pMac - The handle returned by macOpen.
5149
5150 \return eANI_BOOLEAN_TRUE if current assoc is CCX, eANI_BOOLEAN_FALSE otherwise
5151
5152---------------------------------------------------------------------------*/
5153tANI_BOOLEAN csrNeighborRoamIsCCXAssoc(tpAniSirGlobal pMac)
5154{
5155 return pMac->roam.neighborRoamInfo.isCCXAssoc;
5156}
5157#endif /* FEATURE_WLAN_CCX */
5158
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005159#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5160//Returns whether "FW based BG scan" is currently enabled...or not
5161tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5162{
5163 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5164}
5165#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005166#endif
5167
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005168#if defined(FEATURE_WLAN_CCX)
5169tANI_BOOLEAN csrRoamIsCcxIniFeatureEnabled(tpAniSirGlobal pMac)
5170{
5171 return pMac->roam.configParam.isCcxIniFeatureEnabled;
5172}
5173#endif /*FEATURE_WLAN_CCX*/
5174
Jeff Johnson295189b2012-06-20 16:38:30 -07005175//Return true means the command can be release, else not
5176static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5177 eCsrRoamCompleteResult Result, void *Context )
5178{
5179 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5180 tSirBssDescription *pSirBssDesc = NULL;
5181 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5182 tCsrScanResult *pScanResult = NULL;
5183 tCsrRoamInfo roamInfo;
5184 sme_QosAssocInfo assocInfo;
5185 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5186 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5187 tDot11fBeaconIEs *pIes = NULL;
5188 tANI_U32 sessionId = pCommand->sessionId;
5189 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5190 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5191 eRoamCmdStatus roamStatus;
5192 eCsrRoamResult roamResult;
5193 eHalStatus status;
5194 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005195 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005196
Jeff Johnson32d95a32012-09-10 13:15:23 -07005197 if(!pSession)
5198 {
5199 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5200 return eANI_BOOLEAN_FALSE;
5201 }
5202
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005203 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005204 switch( Result )
5205 {
5206 case eCsrJoinSuccess:
5207 // reset the IDLE timer
5208 // !!
5209 // !! fall through to the next CASE statement here is intentional !!
5210 // !!
5211 case eCsrReassocSuccess:
5212 if(eCsrReassocSuccess == Result)
5213 {
5214 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5215 }
5216 else
5217 {
5218 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5219 }
5220 // Success Join Response from LIM. Tell NDIS we are connected and save the
5221 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005222 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305223 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005224 //always free the memory here
5225 if(pSession->pWpaRsnRspIE)
5226 {
5227 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305228 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005229 pSession->pWpaRsnRspIE = NULL;
5230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005231#ifdef FEATURE_WLAN_WAPI
5232 if(pSession->pWapiRspIE)
5233 {
5234 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305235 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 pSession->pWapiRspIE = NULL;
5237 }
5238#endif /* FEATURE_WLAN_WAPI */
5239#ifdef FEATURE_WLAN_BTAMP_UT_RF
5240 //Reset counter so no join retry is needed.
5241 pSession->maxRetryCount = 0;
5242 csrRoamStopJoinRetryTimer(pMac, sessionId);
5243#endif
5244 /* This creates problem since we have not saved the connected profile.
5245 So moving this after saving the profile
5246 */
5247 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
5248 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5249 {
5250 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5251 }
5252 else
5253 {
5254 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5255 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 //Use the last connected bssdesc for reassoc-ing to the same AP.
5257 //NOTE: What to do when reassoc to a different AP???
5258 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5259 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5260 {
5261 pSirBssDesc = pSession->pConnectBssDesc;
5262 if(pSirBssDesc)
5263 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305264 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5265 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005266 }
5267 }
5268 else
5269 {
5270
5271 if(pCommand->u.roamCmd.pRoamBssEntry)
5272 {
5273 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5274 if(pScanResult != NULL)
5275 {
5276 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5277 //this can be NULL
5278 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305279 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5280 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005281 }
5282 }
5283 }
5284 if( pSirBssDesc )
5285 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005286 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5288 //Save WPA/RSN IE
5289 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5290#ifdef FEATURE_WLAN_CCX
5291 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5292#endif
5293
5294 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5295 // substate change.
5296 // Moving even save profile above so that below mentioned conditon is also met.
5297 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5298 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5300 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5301 // will be dropped for the security context may not be set properly.
5302 //
5303 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5304 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5305 //
5306 // this reordering was done on titan_prod_usb branch and is being replicated here.
5307 //
5308
5309 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5310 !pProfile->bWPSAssociation)
5311 {
5312 // Issue the set Context request to LIM to establish the Unicast STA context
5313 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5314 pProfile->negotiatedUCEncryptionType,
5315 pSirBssDesc, &(pSirBssDesc->bssId),
5316 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5317 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005318 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005319 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5320 }
5321 // Issue the set Context request to LIM to establish the Broadcast STA context
5322 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5323 pSirBssDesc, &BroadcastMac,
5324 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5325 }
5326 else
5327 {
5328 //Need to wait for supplicant authtication
5329 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005330 //Set the subestate to WaitForKey in case authentiation is needed
5331 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5332
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 if(pProfile->bWPSAssociation)
5334 {
5335 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5336 }
5337 else
5338 {
5339 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5340 }
5341
5342 //Save sessionId in case of timeout
5343 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5344 //This time should be long enough for the rest of the process plus setting key
5345 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5346 {
5347 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005348 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5350 }
5351 }
5352
5353 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5354 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005355 if(Context)
5356 {
5357 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5358 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5360 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5361#ifdef WLAN_FEATURE_VOWIFI_11R
5362 len += pJoinRsp->parsedRicRspLen;
5363#endif /* WLAN_FEATURE_VOWIFI_11R */
5364#ifdef FEATURE_WLAN_CCX
5365 len += pJoinRsp->tspecIeLen;
5366#endif
5367 if(len)
5368 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305369 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5370 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305372 vos_mem_copy(pSession->connectedInfo.pbFrames,
5373 pJoinRsp->frames, len);
5374 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5375 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5376 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005377#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305378 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005379#endif /* WLAN_FEATURE_VOWIFI_11R */
5380#ifdef FEATURE_WLAN_CCX
Kiet Lam64c1b492013-07-12 13:56:44 +05305381 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005382#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305383 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5384 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5385 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5386 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005387 }
5388 }
5389 if(pCommand->u.roamCmd.fReassoc)
5390 {
5391 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5392 }
5393 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5394 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5395 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5396 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5397 }
5398 else
5399 {
5400 if(pCommand->u.roamCmd.fReassoc)
5401 {
5402 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5403 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5404 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5405 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5406 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5407 }
5408 }
5409#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5410 // Indicate SME-QOS with reassoc success event, only after
5411 // copying the frames
5412 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5413#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005414 roamInfo.pBssDesc = pSirBssDesc;
5415 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5416 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5417#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5418 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5419#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5420 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5422 //It may be better to let QoS do this????
5423 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5424 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005425 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005426 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5427 pmcStartUapsd( pMac, NULL, NULL );
5428 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305429 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5431 if( pSession->bRefAssocStartCnt > 0 )
5432 {
5433 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005434 //Remove this code once SLM_Sessionization is supported
5435 //BMPS_WORKAROUND_NOT_NEEDED
5436 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005437 {
5438 pMac->roam.configParam.doBMPSWorkaround = 1;
5439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5441 }
5442
5443 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 // reset the PMKID candidate list
5445 csrResetPMKIDCandidateList( pMac, sessionId );
5446 //Update TL's AC weight base on the current EDCA parameters
5447 //These parameters may change in the course of the connection, that sictuation
5448 //is not taken care here. This change is mainly to address a WIFI WMM test where
5449 //BE has a equal or higher TX priority than VI.
5450 //We only do this for infra link
5451 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5452 {
5453 csrCheckAndUpdateACWeight(pMac, pIes);
5454 }
5455#ifdef FEATURE_WLAN_WAPI
5456 // reset the BKID candidate list
5457 csrResetBKIDCandidateList( pMac, sessionId );
5458#endif /* FEATURE_WLAN_WAPI */
5459 }
5460 else
5461 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005462 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 csrScanCancelIdleScan(pMac);
5465 //Not to signal link up because keys are yet to be set.
5466 //The linkup function will overwrite the sub-state that we need to keep at this point.
5467 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5468 {
5469 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005471 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5472 //enough to let security and DHCP handshake succeed before entry into BMPS
5473 if (pmcShouldBmpsTimerRun(pMac))
5474 {
5475 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5476 != eHAL_STATUS_SUCCESS)
5477 {
5478 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5479 }
5480 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5481 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 break;
5483
Jeff Johnson295189b2012-06-20 16:38:30 -07005484 case eCsrStartBssSuccess:
5485 // on the StartBss Response, LIM is returning the Bss Description that we
5486 // are beaconing. Add this Bss Description to our scan results and
5487 // chain the Profile to this Bss Description. On a Start BSS, there was no
5488 // detected Bss description (no partner) so we issued the Start Bss to
5489 // start the Ibss without any Bss description. Lim was kind enough to return
5490 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005491 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305494 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005495 if( CSR_IS_IBSS( pProfile ) )
5496 {
5497 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 else if (CSR_IS_INFRA_AP(pProfile))
5500 {
5501 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005503 else
5504 {
5505 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5506 }
5507 if( !CSR_IS_WDS_STA( pProfile ) )
5508 {
5509 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5512 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305513 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 roamInfo.pBssDesc = pSirBssDesc;
5515 //We need to associate_complete it first, becasue Associate_start already indicated.
5516 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5517 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5518 break;
5519 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005520 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005521 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005522 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 }
5524 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5525 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5526 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5527 if(pSirBssDesc)
5528 {
5529 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305530 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5531 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 }
5533 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305534 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005535#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5536 {
5537 vos_log_ibss_pkt_type *pIbssLog;
5538 tANI_U32 bi;
5539
5540 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5541 if(pIbssLog)
5542 {
5543 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5544 {
5545 //We start the IBSS (didn't find any matched IBSS out there)
5546 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5547 }
5548 else
5549 {
5550 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5551 }
5552 if(pSirBssDesc)
5553 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305554 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005555 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5556 }
5557 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5558 {
5559 //***U8 is not enough for beacon interval
5560 pIbssLog->beaconInterval = (v_U8_t)bi;
5561 }
5562 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5563 }
5564 }
5565#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5566 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5567 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005568 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5569 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005570 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5571 csrRoamIssueSetContextReq( pMac, sessionId,
5572 pProfile->negotiatedMCEncryptionType,
5573 pSirBssDesc, &BroadcastMac,
5574 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5575 }
5576 }
5577 else
5578 {
5579 //Keep the state to eCSR_ROAMING_STATE_JOINING
5580 //Need to send join_req.
5581 if(pCommand->u.roamCmd.pRoamBssEntry)
5582 {
5583 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5584 {
5585 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5586 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5587 // Set the roaming substate to 'join attempt'...
5588 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005589 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 }
5591 }
5592 else
5593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005594 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 VOS_ASSERT( 0 );
5596 }
5597 }
5598 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5599 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5600 //trigger the connection start indication in Vista
5601 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5602 {
5603 roamStatus = eCSR_ROAM_IBSS_IND;
5604 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5605 if( CSR_IS_WDS( pProfile ) )
5606 {
5607 roamStatus = eCSR_ROAM_WDS_IND;
5608 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5609 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 if( CSR_IS_INFRA_AP( pProfile ) )
5611 {
5612 roamStatus = eCSR_ROAM_INFRA_IND;
5613 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5614 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005615
5616 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5617 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5618 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305619 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5621 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005622 //We start the IBSS (didn't find any matched IBSS out there)
5623 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005624 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305625 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5626 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005627 //Remove this code once SLM_Sessionization is supported
5628 //BMPS_WORKAROUND_NOT_NEEDED
5629 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005630 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005631 {
5632 pMac->roam.configParam.doBMPSWorkaround = 1;
5633 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005634
Jeff Johnson295189b2012-06-20 16:38:30 -07005635 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5636 }
5637
5638 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005639
5640 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005641 {
5642 //need to send stop BSS because we fail to send join_req
5643 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5644 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5645 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5646 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005647 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 case eCsrStartBssFailure:
5649#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5650 {
5651 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005652 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5653 if(pIbssLog)
5654 {
5655 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5656 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5657 }
5658 }
5659#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 roamStatus = eCSR_ROAM_IBSS_IND;
5661 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5662 if( CSR_IS_WDS( pProfile ) )
5663 {
5664 roamStatus = eCSR_ROAM_WDS_IND;
5665 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 if( CSR_IS_INFRA_AP( pProfile ) )
5668 {
5669 roamStatus = eCSR_ROAM_INFRA_IND;
5670 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005672 if(Context)
5673 {
5674 pSirBssDesc = (tSirBssDescription *)Context;
5675 }
5676 else
5677 {
5678 pSirBssDesc = NULL;
5679 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305680 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005681 roamInfo.pBssDesc = pSirBssDesc;
5682 //We need to associate_complete it first, becasue Associate_start already indicated.
5683 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5684 csrSetDefaultDot11Mode( pMac );
5685 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005686 case eCsrSilentlyStopRoaming:
5687 // We are here because we try to start the same IBSS
5688 //No message to PE
5689 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005690 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005691 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5692 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305693 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5695 if( roamInfo.pBssDesc )
5696 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305697 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5698 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005699 }
5700 //Since there is no change in the current state, simply pass back no result otherwise
5701 //HDD may be mistakenly mark to disconnected state.
5702 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5703 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005704 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 case eCsrSilentlyStopRoamingSaveState:
5706 //We are here because we try to connect to the same AP
5707 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005708 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305709 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005710
5711 //to aviod resetting the substate to NONE
5712 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5713 //No need to change substate to wai_for_key because there is no state change
5714 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5715 if( roamInfo.pBssDesc )
5716 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305717 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5718 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005720 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5721 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5722 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5723 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5724 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5725 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5726 roamInfo.staId = pSession->connectedInfo.staId;
5727 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005728 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005729 pSession->bRefAssocStartCnt--;
5730 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5731 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5732 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5733 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005734 case eCsrReassocFailure:
5735#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5736 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5737#endif
5738 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005739 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005740 csrFreeConnectBssDesc(pMac, sessionId);
5741 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5742 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305743 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005744 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5745 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5746 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5747 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5748 eCSR_ROAM_WDS_IND,
5749 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5750 //Need to issue stop_bss
5751 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005752 case eCsrJoinFailure:
5753 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005754 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005755 default:
5756 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005757 smsLog(pMac, LOGW, FL("receives no association indication"));
5758 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005759 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005760 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5761 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5762 {
5763 //do not free for the other profiles as we need to send down stop BSS later
5764 csrFreeConnectBssDesc(pMac, sessionId);
5765 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5766 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5767 csrSetDefaultDot11Mode( pMac );
5768 }
5769
5770 switch( pCommand->u.roamCmd.roamReason )
5771 {
5772 // If this transition is because of an 802.11 OID, then we transition
5773 // back to INIT state so we sit waiting for more OIDs to be issued and
5774 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005775 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005776 case eCsrSmeIssuedAssocToSimilarAP:
5777 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005778 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005779 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305780 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5782 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5783 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305784 vos_mem_copy(&roamInfo.bssid,
5785 &pSession->joinFailStatusCode.bssId,
5786 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005787
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 /* Defeaturize this later if needed */
5789#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5790 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5791 if (csrRoamIsHandoffInProgress(pMac))
5792 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005793 /* Should indicate neighbor roam algorithm about the connect failure here */
5794 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5795 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005796#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005797 if(pSession->bRefAssocStartCnt > 0)
5798 {
5799 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005800 if(eCsrJoinFailureDueToConcurrency == Result)
5801 {
5802 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5803 eCSR_ROAM_ASSOCIATION_COMPLETION,
5804 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5805 }
5806 else
5807 {
5808 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005809 eCSR_ROAM_ASSOCIATION_COMPLETION,
5810 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005811 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005813 else
5814 {
5815 /* bRefAssocStartCnt is not incremented when
5816 * eRoamState == eCsrStopRoamingDueToConcurrency
5817 * in csrRoamJoinNextBss API. so handle this in
5818 * else case by sending assoc failure
5819 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005820 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005821 pCommand->u.scanCmd.roamId,
5822 eCSR_ROAM_ASSOCIATION_FAILURE,
5823 eCSR_ROAM_RESULT_FAILURE);
5824 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005825 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005826#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05305827 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005828 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5829#endif
5830 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5831 csrScanStartIdleScan(pMac);
5832#ifdef FEATURE_WLAN_BTAMP_UT_RF
5833 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5834 //BT activity and not able to recevie WLAN traffic. Retry the join
5835 if( CSR_IS_WDS_STA(pProfile) )
5836 {
5837 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5838 }
5839#endif
5840 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 case eCsrHddIssuedReassocToSameAP:
5842 case eCsrSmeIssuedReassocToSameAP:
5843 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5844
5845 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5846#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5847 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5848#endif
5849 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5850 csrScanStartIdleScan(pMac);
5851 break;
5852 case eCsrForcedDisassoc:
5853 case eCsrForcedDeauth:
5854 case eCsrSmeIssuedIbssJoinFailure:
5855 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5856
5857 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5858 {
5859 // Notify HDD that IBSS join failed
5860 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5861 }
5862 else
5863 {
5864 csrRoamCallCallback(pMac, sessionId, NULL,
5865 pCommand->u.roamCmd.roamId,
5866 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5867 }
5868#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5869 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5870#endif
5871 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08005872 /*
5873 *DelSta not done FW still in conneced state so dont
5874 *issue IMPS req
5875 */
5876 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
5877 {
5878 smsLog(pMac, LOGW, FL("FW still in connected state "));
5879 break;
5880 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005881 csrScanStartIdleScan(pMac);
5882 break;
5883 case eCsrForcedIbssLeave:
5884 csrRoamCallCallback(pMac, sessionId, NULL,
5885 pCommand->u.roamCmd.roamId,
5886 eCSR_ROAM_IBSS_LEAVE,
5887 eCSR_ROAM_RESULT_IBSS_STOP);
5888 break;
5889 case eCsrForcedDisassocMICFailure:
5890 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5891
5892 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5893#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5894 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5895#endif
5896 csrScanStartIdleScan(pMac);
5897 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005898 case eCsrStopBss:
5899 csrRoamCallCallback(pMac, sessionId, NULL,
5900 pCommand->u.roamCmd.roamId,
5901 eCSR_ROAM_INFRA_IND,
5902 eCSR_ROAM_RESULT_INFRA_STOPPED);
5903 break;
5904 case eCsrForcedDisassocSta:
5905 case eCsrForcedDeauthSta:
5906 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5907 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5908 {
5909 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005910
5911 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5912 {
5913 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05305914 vos_mem_copy(roamInfo.peerMac,
5915 pCommand->u.roamCmd.peerMac,
5916 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005917 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5918 roamInfo.statusCode = eSIR_SME_SUCCESS;
5919 status = csrRoamCallCallback(pMac, sessionId,
5920 &roamInfo, pCommand->u.roamCmd.roamId,
5921 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5922 }
5923 }
5924 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005925 case eCsrLostLink1:
5926 // if lost link roam1 failed, then issue lost link Scan2 ...
5927 csrScanRequestLostLink2(pMac, sessionId);
5928 break;
5929 case eCsrLostLink2:
5930 // if lost link roam2 failed, then issue lost link scan3 ...
5931 csrScanRequestLostLink3(pMac, sessionId);
5932 break;
5933 case eCsrLostLink3:
5934 default:
5935 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5936
5937 //We are done with one round of lostlink roaming here
5938 csrScanHandleFailedLostlink3(pMac, sessionId);
5939 break;
5940 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 break;
5942 }
5943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005944 return ( fReleaseCommand );
5945}
5946
Jeff Johnson295189b2012-06-20 16:38:30 -07005947eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5948{
5949 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 return (status);
5951}
5952
Jeff Johnson295189b2012-06-20 16:38:30 -07005953eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5954{
5955 eHalStatus status = eHAL_STATUS_SUCCESS;
5956 tANI_U32 size = 0;
5957
5958 do
5959 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305960 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5962 {
5963 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305964 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
5965 if ( NULL == pDstProfile->BSSIDs.bssid )
5966 status = eHAL_STATUS_FAILURE;
5967 else
5968 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005969 if(!HAL_STATUS_SUCCESS(status))
5970 {
5971 break;
5972 }
5973 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305974 vos_mem_copy(pDstProfile->BSSIDs.bssid,
5975 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005976 }
5977 if(pSrcProfile->SSIDs.numOfSSIDs)
5978 {
5979 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305980 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
5981 if ( NULL == pDstProfile->SSIDs.SSIDList )
5982 status = eHAL_STATUS_FAILURE;
5983 else
5984 status = eHAL_STATUS_SUCCESS;
5985 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005986 {
5987 break;
5988 }
5989 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305990 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
5991 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 }
5993 if(pSrcProfile->nWPAReqIELength)
5994 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305995 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
5996 if ( NULL == pDstProfile->pWPAReqIE )
5997 status = eHAL_STATUS_FAILURE;
5998 else
5999 status = eHAL_STATUS_SUCCESS;
6000
6001 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 {
6003 break;
6004 }
6005 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306006 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6007 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006008 }
6009 if(pSrcProfile->nRSNReqIELength)
6010 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306011 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6012 if ( NULL == pDstProfile->pRSNReqIE )
6013 status = eHAL_STATUS_FAILURE;
6014 else
6015 status = eHAL_STATUS_SUCCESS;
6016
6017 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006018 {
6019 break;
6020 }
6021 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306022 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6023 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 }
6025#ifdef FEATURE_WLAN_WAPI
6026 if(pSrcProfile->nWAPIReqIELength)
6027 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306028 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6029 if ( NULL == pDstProfile->pWAPIReqIE )
6030 status = eHAL_STATUS_FAILURE;
6031 else
6032 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006033 if(!HAL_STATUS_SUCCESS(status))
6034 {
6035 break;
6036 }
6037 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306038 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6039 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 }
6041#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006042 if(pSrcProfile->nAddIEScanLength)
6043 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306044 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6045 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306047 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306048 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306049 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6050 }
6051 else
6052 {
6053 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6054 FL(" AddIEScanLength is not valid %u"),
6055 pSrcProfile->nAddIEScanLength);
6056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 if(pSrcProfile->nAddIEAssocLength)
6059 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306060 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6061 if ( NULL == pDstProfile->pAddIEAssoc )
6062 status = eHAL_STATUS_FAILURE;
6063 else
6064 status = eHAL_STATUS_SUCCESS;
6065
Jeff Johnson295189b2012-06-20 16:38:30 -07006066 if(!HAL_STATUS_SUCCESS(status))
6067 {
6068 break;
6069 }
6070 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306071 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6072 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006074 if(pSrcProfile->ChannelInfo.ChannelList)
6075 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306076 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6077 pSrcProfile->ChannelInfo.numOfChannels);
6078 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6079 status = eHAL_STATUS_FAILURE;
6080 else
6081 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 if(!HAL_STATUS_SUCCESS(status))
6083 {
6084 break;
6085 }
6086 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306087 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6088 pSrcProfile->ChannelInfo.ChannelList,
6089 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006090 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 pDstProfile->AuthType = pSrcProfile->AuthType;
6092 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6093 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6094 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6095 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6096 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006097#ifdef WLAN_FEATURE_11W
6098 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6099 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6100 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6101#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 pDstProfile->BSSType = pSrcProfile->BSSType;
6103 pDstProfile->phyMode = pSrcProfile->phyMode;
6104 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6105
6106#ifdef FEATURE_WLAN_WAPI
6107 if(csrIsProfileWapi(pSrcProfile))
6108 {
6109 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6110 {
6111 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6112 }
6113 }
6114#endif /* FEATURE_WLAN_WAPI */
6115 pDstProfile->CBMode = pSrcProfile->CBMode;
6116 /*Save the WPS info*/
6117 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
6118 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006119 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 pDstProfile->privacy = pSrcProfile->privacy;
6121 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6122 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6123 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6124 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6125 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6126 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6127 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6128 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6129 pDstProfile->wps_state = pSrcProfile->wps_state;
6130 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306131 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6132 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006133#ifdef WLAN_FEATURE_VOWIFI_11R
6134 if (pSrcProfile->MDID.mdiePresent)
6135 {
6136 pDstProfile->MDID.mdiePresent = 1;
6137 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6138 }
6139#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 }while(0);
6141
6142 if(!HAL_STATUS_SUCCESS(status))
6143 {
6144 csrReleaseProfile(pMac, pDstProfile);
6145 pDstProfile = NULL;
6146 }
6147
6148 return (status);
6149}
Jeff Johnson295189b2012-06-20 16:38:30 -07006150eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6151{
6152 eHalStatus status = eHAL_STATUS_SUCCESS;
6153 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6154 do
6155 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306156 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 if(pSrcProfile->bssid)
6158 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306159 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6160 if ( NULL == pDstProfile->BSSIDs.bssid )
6161 status = eHAL_STATUS_FAILURE;
6162 else
6163 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006164 if(!HAL_STATUS_SUCCESS(status))
6165 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306166 smsLog( pMac, LOGE,
6167 FL("failed to allocate memory for BSSID"
6168 "%02x:%02x:%02x:%02x:%02x:%02x"),
6169 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6170 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006171 break;
6172 }
6173 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306174 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6175 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006176 }
6177 if(pSrcProfile->SSID.ssId)
6178 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306179 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6180 if ( NULL == pDstProfile->SSIDs.SSIDList )
6181 status = eHAL_STATUS_FAILURE;
6182 else
6183 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006184 if(!HAL_STATUS_SUCCESS(status))
6185 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306186 smsLog( pMac, LOGE,
6187 FL("failed to allocate memory for SSIDList"
6188 "%02x:%02x:%02x:%02x:%02x:%02x"),
6189 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6190 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 break;
6192 }
6193 pDstProfile->SSIDs.numOfSSIDs = 1;
6194 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6195 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306196 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6197 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006198 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006199 if(pSrcProfile->nAddIEAssocLength)
6200 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306201 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6202 if ( NULL == pDstProfile->pAddIEAssoc)
6203 status = eHAL_STATUS_FAILURE;
6204 else
6205 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006206 if(!HAL_STATUS_SUCCESS(status))
6207 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006208 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006209 break;
6210 }
6211 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306212 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6213 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006214 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306215 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6216 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6217 status = eHAL_STATUS_FAILURE;
6218 else
6219 status = eHAL_STATUS_SUCCESS;
6220
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 if(!HAL_STATUS_SUCCESS(status))
6222 {
6223 break;
6224 }
6225 pDstProfile->ChannelInfo.numOfChannels = 1;
6226 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006227 pDstProfile->AuthType.numEntries = 1;
6228 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6229 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6230 pDstProfile->EncryptionType.numEntries = 1;
6231 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6232 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6233 pDstProfile->mcEncryptionType.numEntries = 1;
6234 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6235 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6236 pDstProfile->BSSType = pSrcProfile->BSSType;
6237 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306238 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6239 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006240#ifdef WLAN_FEATURE_VOWIFI_11R
6241 if (pSrcProfile->MDID.mdiePresent)
6242 {
6243 pDstProfile->MDID.mdiePresent = 1;
6244 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6245 }
6246#endif
6247
6248 }while(0);
6249
6250 if(!HAL_STATUS_SUCCESS(status))
6251 {
6252 csrReleaseProfile(pMac, pDstProfile);
6253 pDstProfile = NULL;
6254 }
6255
6256 return (status);
6257}
6258
Jeff Johnson295189b2012-06-20 16:38:30 -07006259eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6260 tScanResultHandle hBSSList,
6261 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6262 tANI_BOOLEAN fClearScan)
6263{
6264 eHalStatus status = eHAL_STATUS_SUCCESS;
6265 tSmeCmd *pCommand;
6266
6267 pCommand = csrGetCommandBuffer(pMac);
6268 if(NULL == pCommand)
6269 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006270 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006271 status = eHAL_STATUS_RESOURCES;
6272 }
6273 else
6274 {
6275 if( fClearScan )
6276 {
6277 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306278 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006279 }
6280 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6281 if(NULL == pProfile)
6282 {
6283 //We can roam now
6284 //Since pProfile is NULL, we need to build our own profile, set everything to default
6285 //We can only support open and no encryption
6286 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6287 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6288 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6289 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6290 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6291 }
6292 else
6293 {
6294 //make a copy of the profile
6295 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6296 if(HAL_STATUS_SUCCESS(status))
6297 {
6298 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6299 }
6300 }
6301 pCommand->command = eSmeCommandRoam;
6302 pCommand->sessionId = (tANI_U8)sessionId;
6303 pCommand->u.roamCmd.hBSSList = hBSSList;
6304 pCommand->u.roamCmd.roamId = roamId;
6305 pCommand->u.roamCmd.roamReason = reason;
6306 //We need to free the BssList when the command is done
6307 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6308 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6310 FL("CSR PERSONA=%d"),
6311 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006312 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6313 if( !HAL_STATUS_SUCCESS( status ) )
6314 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006315 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006316 csrReleaseCommandRoam( pMac, pCommand );
6317 }
6318 }
6319
6320 return (status);
6321}
Jeff Johnson295189b2012-06-20 16:38:30 -07006322eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6323 tCsrRoamModifyProfileFields *pMmodProfileFields,
6324 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6325{
6326 eHalStatus status = eHAL_STATUS_SUCCESS;
6327 tSmeCmd *pCommand;
6328
6329 pCommand = csrGetCommandBuffer(pMac);
6330 if(NULL == pCommand)
6331 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006332 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 status = eHAL_STATUS_RESOURCES;
6334 }
6335 else
6336 {
6337 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306338 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 if(pProfile)
6340 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006341 //This is likely trying to reassoc to different profile
6342 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6343 //make a copy of the profile
6344 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6345 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006346 }
6347 else
6348 {
6349 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6350 //how to update WPA/WPA2 info in roamProfile??
6351 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006353 if(HAL_STATUS_SUCCESS(status))
6354 {
6355 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6356 }
6357 pCommand->command = eSmeCommandRoam;
6358 pCommand->sessionId = (tANI_U8)sessionId;
6359 pCommand->u.roamCmd.roamId = roamId;
6360 pCommand->u.roamCmd.roamReason = reason;
6361 //We need to free the BssList when the command is done
6362 //For reassoc there is no BSS list, so the boolean set to false
6363 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6364 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6365 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006366 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6367 if( !HAL_STATUS_SUCCESS( status ) )
6368 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006369 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006370 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6371 csrReleaseCommandRoam( pMac, pCommand );
6372 }
6373 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 return (status);
6375}
6376
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006377eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6378 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306379// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006380{
6381 eHalStatus status = eHAL_STATUS_SUCCESS;
6382 tSmeCmd *pCommand;
6383
6384 pCommand = csrGetCommandBuffer(pMac);
6385 if(NULL == pCommand)
6386 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006387 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006388 status = eHAL_STATUS_RESOURCES;
6389 }
6390 else
6391 {
6392 if(pBssDescription)
6393 {
6394 //copy over the parameters we need later
6395 pCommand->command = eSmeCommandRoam;
6396 pCommand->sessionId = (tANI_U8)sessionId;
6397 pCommand->u.roamCmd.roamReason = reason;
6398 //this is the important parameter
6399 //in this case we are using this field for the "next" BSS
6400 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6401 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6402 if( !HAL_STATUS_SUCCESS( status ) )
6403 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006404 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006405 csrReleaseCommandPreauth( pMac, pCommand );
6406 }
6407 }
6408 else
6409 {
6410 //Return failure
6411 status = eHAL_STATUS_RESOURCES;
6412 }
6413 }
6414 return (status);
6415}
6416
6417eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6418{
6419 tListElem *pEntry;
6420 tSmeCmd *pCommand;
6421 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6422 if ( pEntry )
6423 {
6424 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6425 if ( (eSmeCommandRoam == pCommand->command) &&
6426 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6427 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006428 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006429 pCommand->command, pCommand->u.roamCmd.roamReason);
6430 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6431 csrReleaseCommandPreauth( pMac, pCommand );
6432 }
6433 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006434 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006435 pCommand->command, pCommand->u.roamCmd.roamReason);
6436 }
6437 }
6438 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006439 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006440 }
6441 smeProcessPendingQueue( pMac );
6442 return eHAL_STATUS_SUCCESS;
6443}
6444
Jeff Johnson295189b2012-06-20 16:38:30 -07006445eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6446 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6447{
6448 eHalStatus status = eHAL_STATUS_FAILURE;
6449 tScanResultHandle hBSSList;
6450 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006451 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6452 if(HAL_STATUS_SUCCESS(status))
6453 {
6454 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6455 if(pRoamId)
6456 {
6457 *pRoamId = roamId;
6458 }
6459 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6460 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6461 if(!HAL_STATUS_SUCCESS(status))
6462 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006463 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006464 csrScanResultPurge(pMac, hBSSList);
6465 }
6466 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006467 return (status);
6468}
6469
Jeff Johnson295189b2012-06-20 16:38:30 -07006470eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6471 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6472{
6473 eHalStatus status = eHAL_STATUS_SUCCESS;
6474 tScanResultHandle hBSSList;
6475 tCsrScanResultFilter *pScanFilter;
6476 tANI_U32 roamId = 0;
6477 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6478 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 if (NULL == pProfile)
6480 {
6481 smsLog(pMac, LOGP, FL("No profile specified"));
6482 return eHAL_STATUS_FAILURE;
6483 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006484 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 if( CSR_IS_WDS( pProfile ) &&
6487 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6488 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006489 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006490 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006491 return status;
6492 }
6493 csrRoamCancelRoaming(pMac, sessionId);
6494 csrScanRemoveFreshScanCommand(pMac, sessionId);
6495 csrScanCancelIdleScan(pMac);
6496 //Only abort the scan if it is not used for other roam/connect purpose
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306497 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006498 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6499 {
6500 csrScanDisable(pMac);
6501 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006502 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6503 //Check whether ssid changes
6504 if(csrIsConnStateConnected(pMac, sessionId))
6505 {
6506 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6507 {
6508 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6509 }
6510 }
6511#ifdef FEATURE_WLAN_BTAMP_UT_RF
6512 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6513#endif
6514 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6515 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006516 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006517 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6518 if(pRoamId)
6519 {
6520 roamId = *pRoamId;
6521 }
6522 if(!HAL_STATUS_SUCCESS(status))
6523 {
6524 fCallCallback = eANI_BOOLEAN_TRUE;
6525 }
6526 }
6527 else
6528 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306529 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6530 if ( NULL == pScanFilter )
6531 status = eHAL_STATUS_FAILURE;
6532 else
6533 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006534 if(HAL_STATUS_SUCCESS(status))
6535 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306536 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006537 //Try to connect to any BSS
6538 if(NULL == pProfile)
6539 {
6540 //No encryption
6541 pScanFilter->EncryptionType.numEntries = 1;
6542 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6543 }//we don't have a profile
6544 else
6545 {
6546 //Here is the profile we need to connect to
6547 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6548 }//We have a profile
6549 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6550 if(pRoamId)
6551 {
6552 *pRoamId = roamId;
6553 }
6554
6555 if(HAL_STATUS_SUCCESS(status))
6556 {
6557 /*Save the WPS info*/
6558 if(NULL != pProfile)
6559 {
6560 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6561 }
6562 else
6563 {
6564 pScanFilter->bWPSAssociation = 0;
6565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006566 do
6567 {
6568 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006569 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006570 )
6571 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006572 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006573 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6574 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6575 if(!HAL_STATUS_SUCCESS(status))
6576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006577 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006578 fCallCallback = eANI_BOOLEAN_TRUE;
6579 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006580 else
6581 {
6582 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6583 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006584 break;
6585 }
6586 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006587 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 if(HAL_STATUS_SUCCESS(status))
6589 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006590 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6591 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6592 if(!HAL_STATUS_SUCCESS(status))
6593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006594 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006595 csrScanResultPurge(pMac, hBSSList);
6596 fCallCallback = eANI_BOOLEAN_TRUE;
6597 }
6598 }//Have scan result
6599 else if(NULL != pProfile)
6600 {
6601 //Check whether it is for start ibss
6602 if(CSR_IS_START_IBSS(pProfile))
6603 {
6604 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6605 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6606 if(!HAL_STATUS_SUCCESS(status))
6607 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006608 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 fCallCallback = eANI_BOOLEAN_TRUE;
6610 }
6611 }
6612 else
6613 {
6614 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006615 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006616 if(!HAL_STATUS_SUCCESS(status))
6617 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006618 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006619 fCallCallback = eANI_BOOLEAN_TRUE;
6620 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006621 else
6622 {
6623 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6624 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006625 }
6626 }
6627 else
6628 {
6629 fCallCallback = eANI_BOOLEAN_TRUE;
6630 }
6631 } while (0);
6632 if(NULL != pProfile)
6633 {
6634 //we need to free memory for filter if profile exists
6635 csrFreeScanFilter(pMac, pScanFilter);
6636 }
6637 }//Got the scan filter from profile
6638
Kiet Lam64c1b492013-07-12 13:56:44 +05306639 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006640 }//allocated memory for pScanFilter
6641 }//No Bsslist coming in
6642 //tell the caller if we fail to trigger a join request
6643 if( fCallCallback )
6644 {
6645 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6646 }
6647
6648 return (status);
6649}
Jeff Johnson295189b2012-06-20 16:38:30 -07006650eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6651 tCsrRoamModifyProfileFields modProfileFields,
6652 tANI_U32 *pRoamId)
6653{
6654 eHalStatus status = eHAL_STATUS_SUCCESS;
6655 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6656 tANI_U32 roamId = 0;
6657 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006658 if (NULL == pProfile)
6659 {
6660 smsLog(pMac, LOGP, FL("No profile specified"));
6661 return eHAL_STATUS_FAILURE;
6662 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006663 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 -07006664 csrRoamCancelRoaming(pMac, sessionId);
6665 csrScanRemoveFreshScanCommand(pMac, sessionId);
6666 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306667 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006668 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006669 if(csrIsConnStateConnected(pMac, sessionId))
6670 {
6671 if(pProfile)
6672 {
6673 if(pProfile->SSIDs.numOfSSIDs &&
6674 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6675 {
6676 fCallCallback = eANI_BOOLEAN_FALSE;
6677 }
6678 else
6679 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006680 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 }
6682 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306683 else if (!vos_mem_compare(&modProfileFields,
6684 &pSession->connectedProfile.modifyProfileFields,
6685 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006686 {
6687 fCallCallback = eANI_BOOLEAN_FALSE;
6688 }
6689 else
6690 {
6691 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006692 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006693 }
6694 }
6695 else
6696 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006697 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006698 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006699 if(!fCallCallback)
6700 {
6701 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6702 if(pRoamId)
6703 {
6704 *pRoamId = roamId;
6705 }
6706
Jeff Johnson295189b2012-06-20 16:38:30 -07006707 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6708 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006709 }
6710 else
6711 {
6712 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6713 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006715 return status;
6716}
Jeff Johnson295189b2012-06-20 16:38:30 -07006717eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6718{
6719 eHalStatus status = eHAL_STATUS_FAILURE;
6720 tScanResultHandle hBSSList = NULL;
6721 tCsrScanResultFilter *pScanFilter = NULL;
6722 tANI_U32 roamId;
6723 tCsrRoamProfile *pProfile = NULL;
6724 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006725
6726 if(!pSession)
6727 {
6728 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6729 return eHAL_STATUS_FAILURE;
6730 }
6731
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 do
6733 {
6734 if(pSession->pCurRoamProfile)
6735 {
6736 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306737 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306739 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6740 if ( NULL == pProfile )
6741 status = eHAL_STATUS_FAILURE;
6742 else
6743 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006744 if(!HAL_STATUS_SUCCESS(status))
6745 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306746 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006747 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306748 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306750 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6751 if ( NULL == pScanFilter )
6752 status = eHAL_STATUS_FAILURE;
6753 else
6754 status = eHAL_STATUS_SUCCESS;
6755
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 if(!HAL_STATUS_SUCCESS(status))
6757 {
6758 break;
6759 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306760 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006761 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6762 if(!HAL_STATUS_SUCCESS(status))
6763 {
6764 break;
6765 }
6766 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6767 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6768 if(HAL_STATUS_SUCCESS(status))
6769 {
6770 //we want to put the last connected BSS to the very beginning, if possible
6771 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6772 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6773 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6774 if(!HAL_STATUS_SUCCESS(status))
6775 {
6776 csrScanResultPurge(pMac, hBSSList);
6777 break;
6778 }
6779 }
6780 else
6781 {
6782 //Do a scan on this profile
6783 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006784 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006785 if(!HAL_STATUS_SUCCESS(status))
6786 {
6787 break;
6788 }
6789 }
6790 }//We have a profile
6791 else
6792 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006793 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006794 break;
6795 }
6796 }while(0);
6797 if(pScanFilter)
6798 {
6799 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306800 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006801 }
6802 if(NULL != pProfile)
6803 {
6804 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306805 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 return (status);
6808}
Jeff Johnson295189b2012-06-20 16:38:30 -07006809eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6810{
6811 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006812 if(csrIsConnStateConnected(pMac, sessionId))
6813 {
6814 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6815 if(HAL_STATUS_SUCCESS(status))
6816 {
6817 status = csrRoamJoinLastProfile(pMac, sessionId);
6818 }
6819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006820 return (status);
6821}
6822
Jeff Johnson295189b2012-06-20 16:38:30 -07006823eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6824{
6825 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006826 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006827 csrRoamCancelRoaming(pMac, sessionId);
6828 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6829 if(csrIsConnStateDisconnected(pMac, sessionId))
6830 {
6831 status = csrRoamJoinLastProfile(pMac, sessionId);
6832 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006833 return (status);
6834}
6835
Jeff Johnson295189b2012-06-20 16:38:30 -07006836eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6837{
6838 eHalStatus status = eHAL_STATUS_SUCCESS;
6839 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6840 eCsrRoamSubState NewSubstate;
6841 tANI_U32 sessionId = pCommand->sessionId;
6842
6843 // change state to 'Roaming'...
6844 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6845
6846 if ( csrIsConnStateIbss( pMac, sessionId ) )
6847 {
6848 // If we are in an IBSS, then stop the IBSS...
6849 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6850 fComplete = (!HAL_STATUS_SUCCESS(status));
6851 }
6852 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6853 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006854 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 -07006855 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6856 //Restore AC weight in case we change it
6857 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6858 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6859 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6860 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6861 {
6862 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6863 }
6864 if( fDisassoc )
6865 {
6866 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6867 }
6868 else
6869 {
6870 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6871 }
6872 fComplete = (!HAL_STATUS_SUCCESS(status));
6873 }
6874 else if ( csrIsConnStateWds( pMac, sessionId ) )
6875 {
6876 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6877 {
6878 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6879 fComplete = (!HAL_STATUS_SUCCESS(status));
6880 }
6881 //This has to be WDS station
6882 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6883 {
6884
6885 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6886 if( fDisassoc )
6887 {
6888 status = csrRoamIssueDisassociate( pMac, sessionId,
6889 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6890 fComplete = (!HAL_STATUS_SUCCESS(status));
6891 }
6892 }
6893 } else {
6894 // we got a dis-assoc request while not connected to any peer
6895 // just complete the command
6896 fComplete = eANI_BOOLEAN_TRUE;
6897 status = eHAL_STATUS_FAILURE;
6898 }
6899 if(fComplete)
6900 {
6901 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6902 }
6903
6904 if(HAL_STATUS_SUCCESS(status))
6905 {
6906 if ( csrIsConnStateInfra( pMac, sessionId ) )
6907 {
6908 //Set the state to disconnect here
6909 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6910 }
6911 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006912 else
6913 {
6914 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006916 return (status);
6917}
6918
Jeff Johnson295189b2012-06-20 16:38:30 -07006919/* This is been removed from latest code base */
6920/*
6921static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6922{
6923 eHalStatus status;
6924 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006925 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6926 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006927 return ( status );
6928}
6929*/
6930
Jeff Johnson295189b2012-06-20 16:38:30 -07006931eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6932{
6933 eHalStatus status = eHAL_STATUS_SUCCESS;
6934 tSmeCmd *pCommand;
6935 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006936 do
6937 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006938 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006939 pCommand = csrGetCommandBuffer( pMac );
6940 if ( !pCommand )
6941 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006942 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006943 status = eHAL_STATUS_RESOURCES;
6944 break;
6945 }
6946 //Change the substate in case it is wait-for-key
6947 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6948 {
6949 csrRoamStopWaitForKeyTimer( pMac );
6950 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6951 }
6952 pCommand->command = eSmeCommandRoam;
6953 pCommand->sessionId = (tANI_U8)sessionId;
6954 switch ( reason )
6955 {
6956 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6957 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6958 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006959 case eCSR_DISCONNECT_REASON_DEAUTH:
6960 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6961 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006962 case eCSR_DISCONNECT_REASON_HANDOFF:
6963 fHighPriority = eANI_BOOLEAN_TRUE;
6964 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6965 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006966 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6967 case eCSR_DISCONNECT_REASON_DISASSOC:
6968 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6969 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006970 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6971 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6972 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006973 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6974 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6975 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006976 default:
6977 break;
6978 }
6979 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6980 if( !HAL_STATUS_SUCCESS( status ) )
6981 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006982 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006983 csrReleaseCommandRoam( pMac, pCommand );
6984 }
6985 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006986 return( status );
6987}
6988
Jeff Johnson295189b2012-06-20 16:38:30 -07006989eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6990{
6991 eHalStatus status = eHAL_STATUS_SUCCESS;
6992 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006993 pCommand = csrGetCommandBuffer( pMac );
6994 if ( NULL != pCommand )
6995 {
6996 //Change the substate in case it is wait-for-key
6997 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6998 {
6999 csrRoamStopWaitForKeyTimer( pMac );
7000 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7001 }
7002 pCommand->command = eSmeCommandRoam;
7003 pCommand->sessionId = (tANI_U8)sessionId;
7004 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7005 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7006 if( !HAL_STATUS_SUCCESS( status ) )
7007 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007008 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 csrReleaseCommandRoam( pMac, pCommand );
7010 }
7011 }
7012 else
7013 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007014 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007015 status = eHAL_STATUS_RESOURCES;
7016 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007017 return ( status );
7018}
7019
Jeff Johnson295189b2012-06-20 16:38:30 -07007020eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7021{
7022 eHalStatus status = eHAL_STATUS_SUCCESS;
7023 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007024
7025 if(!pSession)
7026 {
7027 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7028 return eHAL_STATUS_FAILURE;
7029 }
7030
Jeff Johnson295189b2012-06-20 16:38:30 -07007031#ifdef FEATURE_WLAN_BTAMP_UT_RF
7032 //Stop te retry
7033 pSession->maxRetryCount = 0;
7034 csrRoamStopJoinRetryTimer(pMac, sessionId);
7035#endif
7036 //Not to call cancel roaming here
7037 //Only issue disconnect when necessary
7038 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7039 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7040 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7041
7042 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007043 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007044 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007046 return (status);
7047}
7048
Jeff Johnson295189b2012-06-20 16:38:30 -07007049eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7050{
7051 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007052
7053 if(!pSession)
7054 {
7055 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7056 return eHAL_STATUS_FAILURE;
7057 }
7058
Jeff Johnson295189b2012-06-20 16:38:30 -07007059 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007060 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7061
7062 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7063}
7064
Jeff Johnson295189b2012-06-20 16:38:30 -07007065eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7066 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7067{
7068 eHalStatus status = eHAL_STATUS_SUCCESS;
7069 tDot11fBeaconIEs *pIesTemp = pIes;
7070 tANI_U8 index;
7071 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7072 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007073
7074 if(!pSession)
7075 {
7076 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7077 return eHAL_STATUS_FAILURE;
7078 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007079 if(pConnectProfile->pAddIEAssoc)
7080 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307081 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007082 pConnectProfile->pAddIEAssoc = NULL;
7083 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307084 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007085 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7086 pConnectProfile->AuthInfo = pProfile->AuthType;
7087 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7088 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7089 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7090 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7091 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7092 pConnectProfile->BSSType = pProfile->BSSType;
7093 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7094 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007095 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
7096
Kiet Lam64c1b492013-07-12 13:56:44 +05307097 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007098 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7099 if(pProfile->nAddIEAssocLength)
7100 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307101 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7102 if ( NULL == pConnectProfile->pAddIEAssoc )
7103 status = eHAL_STATUS_FAILURE;
7104 else
7105 status = eHAL_STATUS_SUCCESS;
7106 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007107 {
7108 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7109 return eHAL_STATUS_FAILURE;
7110 }
7111 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307112 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7113 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007114 }
7115
Jeff Johnson295189b2012-06-20 16:38:30 -07007116 //Save bssid
7117 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7118#ifdef WLAN_FEATURE_VOWIFI_11R
7119 if (pSirBssDesc->mdiePresent)
7120 {
7121 pConnectProfile->MDID.mdiePresent = 1;
7122 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7123 }
7124#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007125 if( NULL == pIesTemp )
7126 {
7127 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007129#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007130 if ((csrIsProfileCCX(pProfile) ||
7131 ((pIesTemp->CCXVersion.present)
7132 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7133 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7134 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7135 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07007136#ifdef WLAN_FEATURE_11W
7137 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
7138#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05307139 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007140 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007141 {
7142 pConnectProfile->isCCXAssoc = 1;
7143 }
7144#endif
7145 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007146 if(HAL_STATUS_SUCCESS(status))
7147 {
7148 if(pIesTemp->SSID.present)
7149 {
7150 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307151 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7152 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 }
7154
7155 //Save the bss desc
7156 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307157
7158 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007159 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307160 //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 -07007161 pConnectProfile->qap = TRUE;
7162 }
7163 else
7164 {
7165 pConnectProfile->qap = FALSE;
7166 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007167 if ( NULL == pIes )
7168 {
7169 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307170 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007171 }
7172 }
7173 //Save Qos connection
7174 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7175
7176 if(!HAL_STATUS_SUCCESS(status))
7177 {
7178 csrFreeConnectBssDesc(pMac, sessionId);
7179 }
7180 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7181 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307182 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7183 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7184 pConnectProfile->SSID.ssId,
7185 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007186 {
7187 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7188 break;
7189 }
7190 pConnectProfile->handoffPermitted = FALSE;
7191 }
7192
7193 return (status);
7194}
7195
Jeff Johnson295189b2012-06-20 16:38:30 -07007196static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7197{
7198 tListElem *pEntry = NULL;
7199 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007200 //The head of the active list is the request we sent
7201 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7202 if(pEntry)
7203 {
7204 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7205 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007206 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7207 {
7208 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7209 {
7210#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7211 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7212#endif
7213 }
7214 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7215 }
7216 else
7217 {
7218 tANI_U32 roamId = 0;
7219 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007220 if(!pSession)
7221 {
7222 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7223 return;
7224 }
7225
Jeff Johnson295189b2012-06-20 16:38:30 -07007226
7227 //The head of the active list is the request we sent
7228 //Try to get back the same profile and roam again
7229 if(pCommand)
7230 {
7231 roamId = pCommand->u.roamCmd.roamId;
7232 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007233 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7234 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007235 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007236#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7237 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7238 if (csrRoamIsHandoffInProgress(pMac))
7239 {
7240 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7241 /* Should indicate neighbor roam algorithm about the connect failure here */
7242 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7243 }
7244#endif
7245 if (pCommand)
7246 {
7247 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7248 {
7249 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7250 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7251 csrRoamReissueRoamCommand(pMac);
7252 }
7253 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7254 {
7255 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7256 }
7257 else
7258 {
7259 csrRoam(pMac, pCommand);
7260 }
7261 }
7262 else
7263 {
7264 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7265 }
7266 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7267}
7268
Jeff Johnson295189b2012-06-20 16:38:30 -07007269eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7270 tDot11fBeaconIEs *pIes,
7271 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7272{
7273 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007274 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7275 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007276
7277 // Set the roaming substate to 'join attempt'...
7278 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007279 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007280 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007281 return (status);
7282}
7283
Jeff Johnson295189b2012-06-20 16:38:30 -07007284static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7285 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7286{
7287 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007288 // Set the roaming substate to 'join attempt'...
7289 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7290
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307291 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7292 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007293
7294 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007295 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007296}
7297
Jeff Johnson295189b2012-06-20 16:38:30 -07007298void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7299{
7300 tListElem *pEntry;
7301 tSmeCmd *pCommand;
7302 tCsrRoamInfo roamInfo;
7303 tANI_U32 sessionId;
7304 tCsrRoamSession *pSession;
7305
7306 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7307 if(pEntry)
7308 {
7309 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7310 if ( eSmeCommandRoam == pCommand->command )
7311 {
7312 sessionId = pCommand->sessionId;
7313 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007314
7315 if(!pSession)
7316 {
7317 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7318 return;
7319 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307320 /* While switching between two AP, csr will reissue roam command again
7321 to the nextbss if it was interrupted by the dissconnect req for the
7322 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7323 so reset the bRefAssocStartCnt.
7324 */
7325 if(pSession->bRefAssocStartCnt > 0)
7326 {
7327 pSession->bRefAssocStartCnt--;
7328 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007329 if( pCommand->u.roamCmd.fStopWds )
7330 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307331 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007332 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7333 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7334 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007335 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7337 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7338 eCSR_ROAM_WDS_IND,
7339 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007340 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7341 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7342 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7343 eCSR_ROAM_INFRA_IND,
7344 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7345 }
7346
Jeff Johnson295189b2012-06-20 16:38:30 -07007347
Jeff Johnson295189b2012-06-20 16:38:30 -07007348 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7349 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007350 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007351 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7352 }
7353 }
7354 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7355 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007356 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007357 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7358 }
7359 }
7360 else
7361 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007362 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007363 }
7364 }
7365 else
7366 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007367 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007368 }
7369}
7370
Jeff Johnson295189b2012-06-20 16:38:30 -07007371tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7372{
7373 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7374 tListElem *pEntry;
7375 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007376 //alwasy lock active list before locking pending list
7377 csrLLLock( &pMac->sme.smeCmdActiveList );
7378 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7379 if(pEntry)
7380 {
7381 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7382 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7383 {
7384 fRet = eANI_BOOLEAN_TRUE;
7385 }
7386 }
7387 if(eANI_BOOLEAN_FALSE == fRet)
7388 {
7389 csrLLLock(&pMac->sme.smeCmdPendingList);
7390 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7391 while(pEntry)
7392 {
7393 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7394 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7395 {
7396 fRet = eANI_BOOLEAN_TRUE;
7397 break;
7398 }
7399 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7400 }
7401 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7402 }
7403 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007404 return (fRet);
7405}
7406
Jeff Johnson295189b2012-06-20 16:38:30 -07007407tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7408{
7409 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7410 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007411 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7412 {
7413 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7414 {
7415 break;
7416 }
7417 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007418 return ( fRet );
7419}
7420
Jeff Johnson295189b2012-06-20 16:38:30 -07007421tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7422{
7423 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007424 //alwasy lock active list before locking pending list
7425 csrLLLock( &pMac->sme.smeCmdActiveList );
7426 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7427 if(eANI_BOOLEAN_FALSE == fRet)
7428 {
7429 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7430 }
7431 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007432 return (fRet);
7433}
7434
Jeff Johnson295189b2012-06-20 16:38:30 -07007435tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7436{
7437 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7438 tListElem *pEntry;
7439 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007440 //alwasy lock active list before locking pending list
7441 csrLLLock( &pMac->sme.smeCmdActiveList );
7442 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7443 if( pEntry )
7444 {
7445 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7446 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7447 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7448 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7449 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7450 {
7451 fRet = eANI_BOOLEAN_TRUE;
7452 }
7453 }
7454 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007455 return (fRet);
7456}
Jeff Johnson295189b2012-06-20 16:38:30 -07007457eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7458{
7459 eHalStatus status = eHAL_STATUS_SUCCESS;
7460 tSmeCmd *pCommand = NULL;
7461 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7462 tANI_BOOLEAN fRemoveCmd = FALSE;
7463 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007464 // Delete the old assoc command. All is setup for reassoc to be serialized
7465 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7466 if ( pEntry )
7467 {
7468 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7469 if ( !pCommand )
7470 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007471 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007472 return eHAL_STATUS_RESOURCES;
7473 }
7474 if ( eSmeCommandRoam == pCommand->command )
7475 {
7476 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7477 {
7478 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7479 }
7480 else
7481 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007482 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007483 }
7484 if (fRemoveCmd == FALSE)
7485 {
7486 // Implies we did not get the serialized assoc command we
7487 // were expecting
7488 pCommand = NULL;
7489 }
7490 }
7491 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007492 if(NULL == pCommand)
7493 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007494 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007495 return eHAL_STATUS_RESOURCES;
7496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 do
7498 {
7499 //Change the substate in case it is wait-for-key
7500 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7501 {
7502 csrRoamStopWaitForKeyTimer( pMac );
7503 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7504 }
7505 pCommand->command = eSmeCommandRoam;
7506 pCommand->sessionId = (tANI_U8)sessionId;
7507 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007508 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7509 if( !HAL_STATUS_SUCCESS( status ) )
7510 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007511 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007512 csrReleaseCommandRoam( pMac, pCommand );
7513 }
7514 } while( 0 );
7515
Jeff Johnson295189b2012-06-20 16:38:30 -07007516 return( status );
7517}
7518static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7519{
7520 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7521 tCsrScanResult *pScanResult = NULL;
7522 tSirBssDescription *pBssDesc = NULL;
7523 tSmeCmd *pCommand = NULL;
7524 tANI_U32 sessionId;
7525 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007526 if(NULL == pEntry)
7527 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307528 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007529 return;
7530 }
7531 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7532 sessionId = pCommand->sessionId;
7533 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007534
7535 if(!pSession)
7536 {
7537 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7538 return;
7539 }
7540
Jeff Johnson295189b2012-06-20 16:38:30 -07007541 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7542 {
7543 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007544 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007545 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7546 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007547 /* If the roaming has stopped, not to continue the roaming command*/
7548 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7549 {
7550 //No need to complete roaming here as it already completes
7551 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7552 pCommand->u.roamCmd.roamReason);
7553 csrSetAbortRoamingCommand( pMac, pCommand );
7554 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7555 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007556 else
7557 {
7558 if ( CCM_IS_RESULT_SUCCESS(result) )
7559 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007560 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007561 // Successfully set the configuration parameters for the new Bss. Attempt to
7562 // join the roaming Bss.
7563 if(pCommand->u.roamCmd.pRoamBssEntry)
7564 {
7565 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7566 pBssDesc = &pScanResult->Result.BssDescriptor;
7567 }
7568 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7569 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007570 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007571 )
7572 {
7573 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7574 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7575 pBssDesc, pCommand->u.roamCmd.roamId )))
7576 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307577 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007578 //We need to complete the command
7579 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7580 }
7581 }
7582 else
7583 {
7584 if (!pCommand->u.roamCmd.pRoamBssEntry)
7585 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307586 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007587 //We need to complete the command
7588 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7589 return;
7590 }
7591 // If we are roaming TO an Infrastructure BSS...
7592 VOS_ASSERT(pScanResult != NULL);
7593 if ( csrIsInfraBssDesc( pBssDesc ) )
7594 {
7595 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007596 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7597 {
7598 // ..and currently in an Infrastructure connection....
7599 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7600 {
7601 // ...and the SSIDs are equal, then we Reassoc.
7602 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7603 pIesLocal ) )
7604 // ..and currently in an infrastructure connection
7605 {
7606 // then issue a Reassoc.
7607 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7608 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7609 &pCommand->u.roamCmd.roamProfile );
7610 }
7611 else
7612 {
7613
7614 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7615 // previously associated AP.
7616 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7617 pIesLocal,
7618 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7619 {
7620 //try something else
7621 csrRoam( pMac, pCommand );
7622 }
7623 }
7624 }
7625 else
7626 {
7627 eHalStatus status = eHAL_STATUS_SUCCESS;
7628
7629 /* We need to come with other way to figure out that this is because of HO in BMP
7630 The below API will be only available for Android as it uses a different HO algorithm */
7631 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7632 * use join request */
7633#ifdef WLAN_FEATURE_VOWIFI_11R
7634 if (csrRoamIsHandoffInProgress(pMac) &&
7635 csrRoamIs11rAssoc(pMac))
7636 {
7637 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7638 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7639 }
7640 else
7641#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007642#ifdef FEATURE_WLAN_CCX
7643 if (csrRoamIsHandoffInProgress(pMac) &&
7644 csrRoamIsCCXAssoc(pMac))
7645 {
7646 // Now serialize the reassoc command.
7647 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7648 }
7649 else
7650#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007651#ifdef FEATURE_WLAN_LFR
7652 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307653 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007654 {
7655 // Now serialize the reassoc command.
7656 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7657 }
7658 else
7659#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 // else we are not connected and attempting to Join. Issue the
7661 // Join request.
7662 {
7663 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7664 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7665 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7666 }
7667 if(!HAL_STATUS_SUCCESS(status))
7668 {
7669 //try something else
7670 csrRoam( pMac, pCommand );
7671 }
7672 }
7673 if( !pScanResult->Result.pvIes )
7674 {
7675 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307676 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007677 }
7678 }
7679 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7680 else
7681 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007682 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007683 }
7684 }//else
7685 }//if ( WNI_CFG_SUCCESS == result )
7686 else
7687 {
7688 // In the event the configuration failed, for infra let the roam processor
7689 //attempt to join something else...
7690 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7691 {
7692 csrRoam(pMac, pCommand);
7693 }
7694 else
7695 {
7696 //We need to complete the command
7697 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7698 {
7699 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7700 }
7701 else
7702 {
7703 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7704 }
7705 }
7706 }
7707 }//we have active entry
7708}
7709
Jeff Johnson295189b2012-06-20 16:38:30 -07007710static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7711{
7712 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007713 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007714 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007716 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007717 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7718 // join the new one...
7719 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007720 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7721 }
7722 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007723 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007724 /***profHandleLostLinkAfterReset(pAdapter);
7725 // In the event the authenticate fails, let the roam processor attempt to join something else...
7726 roamRoam( pAdapter );***/
7727 }
7728}
7729
Jeff Johnson295189b2012-06-20 16:38:30 -07007730static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7731{
7732 eCsrRoamCompleteResult result;
7733 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7734 tCsrRoamInfo roamInfo;
7735 tANI_U32 roamId = 0;
7736
7737 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7738 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007739 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007740 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007741 /* Defeaturize this part later if needed */
7742#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7743 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7744 * we need the response contents while processing the result in csrRoamProcessResults() */
7745 if (csrRoamIsHandoffInProgress(pMac))
7746 {
7747 /* Need to dig more on indicating events to SME QoS module */
7748 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7749 csrRoamComplete( pMac, result, pSmeJoinRsp);
7750 }
7751 else
7752#endif
7753 {
7754 csrRoamComplete( pMac, result, NULL );
7755 }
7756 }
7757 /* Should we handle this similar to handling the join failure? Is it ok
7758 * to call csrRoamComplete() with state as CsrJoinFailure */
7759 else
7760 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007761 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007762 result = eCsrReassocFailure;
7763#ifdef WLAN_FEATURE_VOWIFI_11R
7764 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7765 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7766 {
7767 // Inform HDD to turn off FT flag in HDD
7768 if (pNeighborRoamInfo)
7769 {
7770 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7771 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7772 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007773 /*
7774 * Since the above callback sends a disconnect
7775 * to HDD, we should clean-up our state
7776 * machine as well to be in sync with the upper
7777 * layers. There is no need to send a disassoc
7778 * since: 1) we will never reassoc to the current
7779 * AP in LFR, and 2) there is no need to issue a
7780 * disassoc to the AP with which we were trying
7781 * to reassoc.
7782 */
7783 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7784 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007785 }
7786 }
7787#endif
7788 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7789 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7790 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7791 //The disassoc rsp message will remove the command from active list
7792 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7793 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7794 {
7795 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7796 }
7797 }
7798}
7799
Jeff Johnson295189b2012-06-20 16:38:30 -07007800static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7801{
Jeff Johnson295189b2012-06-20 16:38:30 -07007802#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7803 {
7804 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007805 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7806 if(pIbssLog)
7807 {
7808 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7809 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7810 {
7811 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7812 }
7813 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7814 }
7815 }
7816#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007817 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7818 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7819 {
7820 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7821 }
7822 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7823 {
7824 csrRoamReissueRoamCommand(pMac);
7825 }
7826}
7827
Jeff Johnson295189b2012-06-20 16:38:30 -07007828void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7829{
7830 tSirResultCodes statusCode;
7831#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7832 tScanResultHandle hBSSList;
7833 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7834 eHalStatus status;
7835 tCsrRoamInfo roamInfo;
7836 tCsrScanResultFilter *pScanFilter = NULL;
7837 tANI_U32 roamId = 0;
7838 tCsrRoamProfile *pCurRoamProfile = NULL;
7839 tListElem *pEntry = NULL;
7840 tSmeCmd *pCommand = NULL;
7841#endif
7842 tANI_U32 sessionId;
7843 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007844
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 tSirSmeDisassocRsp SmeDisassocRsp;
7846
7847 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7848 sessionId = SmeDisassocRsp.sessionId;
7849 statusCode = SmeDisassocRsp.statusCode;
7850
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007851 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007852
7853 if ( csrIsConnStateInfra( pMac, sessionId ) )
7854 {
7855 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7856 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007857 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007858
7859 if(!pSession)
7860 {
7861 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7862 return;
7863 }
7864
Jeff Johnson295189b2012-06-20 16:38:30 -07007865 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7866 {
7867 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7868 }
7869 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7870 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7871 {
7872 if ( eSIR_SME_SUCCESS == statusCode )
7873 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007874 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007875 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7876 }
7877 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007879 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7880 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307881 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
7882 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007883#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007884 /*
7885 * First ensure if the roam profile is in the scan cache.
7886 * If not, post a reassoc failure and disconnect.
7887 */
Kiet Lam64c1b492013-07-12 13:56:44 +05307888 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7889 if ( NULL == pScanFilter )
7890 status = eHAL_STATUS_FAILURE;
7891 else
7892 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007893 if(HAL_STATUS_SUCCESS(status))
7894 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307895 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007896 status = csrRoamPrepareFilterFromProfile(pMac,
7897 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7898 if(!HAL_STATUS_SUCCESS(status))
7899 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007900 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007901 __func__, status);
7902 goto POST_ROAM_FAILURE;
7903 }
7904 else
7905 {
7906 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7907 if (!HAL_STATUS_SUCCESS(status))
7908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007909 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007910 __func__, status);
7911 goto POST_ROAM_FAILURE;
7912 }
7913 }
7914 }
7915 else
7916 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007917 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007918 __func__, status);
7919 goto POST_ROAM_FAILURE;
7920 }
7921
7922 /*
7923 * After ensuring that the roam profile is in the scan result list,
7924 * dequeue the command from the active list.
7925 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007926 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7927 if ( pEntry )
7928 {
7929 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007930 /* If the head of the queue is Active and it is a ROAM command, remove
7931 * and put this on the Free queue.
7932 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007933 if ( eSmeCommandRoam == pCommand->command )
7934 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007935
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007936 /*
7937 * we need to process the result first before removing it from active list
7938 * because state changes still happening insides roamQProcessRoamResults so
7939 * no other roam command should be issued.
7940 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007941 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7942 if(pCommand->u.roamCmd.fReleaseProfile)
7943 {
7944 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7945 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7946 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007947 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007948 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007949 else
7950 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007951 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007952 __func__, pCommand->u.roamCmd.roamReason );
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: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007958 }
7959 }
7960 else
7961 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007962 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007963 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007964
7965 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007966 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7967
Kiet Lam64c1b492013-07-12 13:56:44 +05307968 vos_mem_copy(roamInfo.bssid,
7969 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7970 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007971
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007972 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7973 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007974
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007975 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05307976 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7977 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07007978 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307979 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007980 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7981 //make sure to put it at the head of the cmd queue
7982 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7983 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7984 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7985
Jeff Johnson295189b2012-06-20 16:38:30 -07007986 if(!HAL_STATUS_SUCCESS(status))
7987 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007988 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007989 __func__, status);
7990 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007991 }
7992
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007993 /* Notify sub-modules like QoS etc. that handoff happening */
7994 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007995 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307996 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007997 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307998 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007999 return;
8000 }
8001
8002POST_ROAM_FAILURE:
8003 if (pScanFilter)
8004 {
8005 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308006 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008007 }
8008 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308009 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008010
8011 /* Inform the upper layers that the reassoc failed */
8012 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8013 csrRoamCallCallback(pMac, sessionId,
8014 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8015
8016 /*
8017 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8018 * Upon success, we would re-enter this routine after receiving the disassoc
8019 * response and will fall into the reassoc fail sub-state. And, eventually
8020 * call csrRoamComplete which would remove the roam command from SME active
8021 * queue.
8022 */
8023 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8024 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8025 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008026 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008027 __func__, status);
8028 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008029 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008030#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008031
Jeff Johnson295189b2012-06-20 16:38:30 -07008032 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8033 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8034 {
8035 // Disassoc due to Reassoc failure falls into this codepath....
8036 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8037 }
8038 else
8039 {
8040 if ( eSIR_SME_SUCCESS == statusCode )
8041 {
8042 // Successfully disassociated from the 'old' Bss...
8043 //
8044 // We get Disassociate response in three conditions.
8045 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8046 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8047 // Infrastructure network.
8048 // - Third is where we are doing an Infra to Infra roam between networks with different
8049 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8050
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008051 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008052 }
8053 else
8054 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008055 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008056 }
8057 //We are not done yet. Get the data and continue roaming
8058 csrRoamReissueRoamCommand(pMac);
8059 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008060}
8061
Jeff Johnson295189b2012-06-20 16:38:30 -07008062static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8063{
8064 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008065 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008066 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008067 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008068 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008069 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8070 {
8071 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8072 }
8073 else
8074 {
8075 if ( eSIR_SME_SUCCESS == statusCode )
8076 {
8077 // Successfully deauth from the 'old' Bss...
8078 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008079 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008080 }
8081 else
8082 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008083 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008084 }
8085 //We are not done yet. Get the data and continue roaming
8086 csrRoamReissueRoamCommand(pMac);
8087 }
8088}
8089
Jeff Johnson295189b2012-06-20 16:38:30 -07008090static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8091{
8092 eCsrRoamCompleteResult result;
8093
8094 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8095 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008096 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008097 result = eCsrStartBssSuccess;
8098 }
8099 else
8100 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008101 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008102 //Let csrRoamComplete decide what to do
8103 result = eCsrStartBssFailure;
8104 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008105 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008106}
8107
Jeff Johnson295189b2012-06-20 16:38:30 -07008108/*
8109 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8110 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8111 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8112 For the messages where sender allocates memory for specific structures, then it can be
8113 cast accordingly.
8114*/
8115void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8116{
8117 tSirSmeRsp *pSmeRsp;
8118 tSmeIbssPeerInd *pIbssPeerInd;
8119 tCsrRoamInfo roamInfo;
8120 // TODO Session Id need to be acquired in this function
8121 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008122 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008123 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008124 pSmeRsp->messageType, pSmeRsp->messageType,
8125 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07008126 pSmeRsp->messageType = (pSmeRsp->messageType);
8127 pSmeRsp->length = (pSmeRsp->length);
8128 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008129 switch (pSmeRsp->messageType)
8130 {
8131
8132 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8133 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8134 {
8135 //We sent a JOIN_REQ
8136 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8137 }
8138 break;
8139
8140 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8141 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8142 {
8143 //We sent a AUTH_REQ
8144 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8145 }
8146 break;
8147
8148 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8149 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8150 {
8151 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8152 }
8153 break;
8154
8155 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8156 {
8157 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8158 }
8159 break;
8160
8161 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8162 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8163 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8164 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8165 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8166 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8167//HO
8168 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8169 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008170 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008171 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
8172 }
8173 break;
8174
8175 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8176 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8177 {
8178 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8179 }
8180 break;
8181
8182 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8183 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8184 {
8185 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8186 }
8187 break;
8188
8189 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8190 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8191 {
8192 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8193 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008194 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008195 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8196 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8197 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008198 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308199 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8200 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8202 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308203 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8204 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008205 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8206 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8207 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8208 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008209 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008210 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008211 pSmeRsp->messageType, pSmeRsp->messageType,
8212 pMac->roam.curSubState[pSmeRsp->sessionId] );
8213
8214 //If we are connected, check the link status change
8215 if(!csrIsConnStateDisconnected(pMac, sessionId))
8216 {
8217 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8218 }
8219 break;
8220 }
8221}
8222
Jeff Johnson295189b2012-06-20 16:38:30 -07008223void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8224{
8225 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008226 switch (pSirMsg->messageType)
8227 {
8228 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008229 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008230 csrRoamStatsRspProcessor( pMac, pSirMsg );
8231 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008232 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8233 {
8234 tCsrRoamSession *pSession;
8235 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8236 tCsrRoamInfo roamInfo;
8237 tCsrRoamInfo *pRoamInfo = NULL;
8238 tANI_U32 sessionId;
8239 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008240 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308241 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008242 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008243 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8244 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8245 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008246
8247 if(!pSession)
8248 {
8249 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8250 return;
8251 }
8252
Jeff Johnson295189b2012-06-20 16:38:30 -07008253 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8254 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008255 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8256 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8257 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008258 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8259 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308260 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8261 sizeof(tSirMacAddr));
8262 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8263 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008264 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008265 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8266 {
8267 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8268 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8269 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8270 }
8271 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8272 {
8273 vos_sleep( 100 );
8274 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8275 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8276 }
8277
Jeff Johnson295189b2012-06-20 16:38:30 -07008278 }
8279 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008280 default:
8281 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8282 break;
8283 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008284}
8285
Jeff Johnson295189b2012-06-20 16:38:30 -07008286eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8287 tSirBssDescription *pBssDescription,
8288 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8289 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8290 tANI_U8 keyId, tANI_U16 keyLength,
8291 tANI_U8 *pKey, tANI_U8 paeRole )
8292{
8293 eHalStatus status = eHAL_STATUS_SUCCESS;
8294 tAniEdType edType;
8295
8296 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8297 {
8298 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8299 }
8300
8301 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8302
8303 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8304 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8305 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8306 addKey )
8307 {
8308 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008309 setKey.encType = EncryptType;
8310 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308311 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008312 setKey.paeRole = paeRole; //0 for supplicant
8313 setKey.keyId = keyId; // Kye index
8314 setKey.keyLength = keyLength;
8315 if( keyLength )
8316 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308317 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008318 }
8319 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8320 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008321 return (status);
8322}
8323
Jeff Johnson295189b2012-06-20 16:38:30 -07008324static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8325 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8326{
8327 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8328 tSmeCmd *pCommand = NULL;
8329#ifdef FEATURE_WLAN_CCX
8330 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8331#endif /* FEATURE_WLAN_CCX */
8332
8333 do
8334 {
8335 pCommand = csrGetCommandBuffer(pMac);
8336 if(NULL == pCommand)
8337 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008338 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008339 status = eHAL_STATUS_RESOURCES;
8340 break;
8341 }
8342 pCommand->command = eSmeCommandSetKey;
8343 pCommand->sessionId = (tANI_U8)sessionId;
8344 // validate the key length, Adjust if too long...
8345 // for static WEP the keys are not set thru' SetContextReq
8346 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8347 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8348 {
8349 //KeyLength maybe 0 for static WEP
8350 if( pSetKey->keyLength )
8351 {
8352 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8353 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008354 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008355 break;
8356 }
8357
8358 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308359 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8360 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008361 }
8362 }
8363 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8364 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8365 {
8366 //KeyLength maybe 0 for static WEP
8367 if( pSetKey->keyLength )
8368 {
8369 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8370 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008371 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008372 break;
8373 }
8374
8375 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308376 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8377 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008378 }
8379 }
8380 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8381 {
8382 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008384 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008385 break;
8386 }
8387 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308388 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8389 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008390 }
8391 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8392 {
8393 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8394 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008395 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008396 break;
8397 }
8398 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308399 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8400 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008401 }
8402#ifdef FEATURE_WLAN_WAPI
8403 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8404 {
8405 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8406 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008407 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008408 break;
8409 }
8410 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308411 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8412 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008413 }
8414#endif /* FEATURE_WLAN_WAPI */
8415#ifdef FEATURE_WLAN_CCX
8416 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8417 {
8418 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8419 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008420 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008421 break;
8422 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308423 vos_mem_copy(pSession->ccxCckmInfo.krk, pSetKey->Key,
8424 CSR_KRK_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008425 pSession->ccxCckmInfo.reassoc_req_num=1;
8426 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8427 status = eHAL_STATUS_SUCCESS;
8428 break;
8429 }
8430#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008431
Jeff Johnson295189b2012-06-20 16:38:30 -07008432#ifdef WLAN_FEATURE_11W
8433 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008434 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008435 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008436 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008437 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008438 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 break;
8440 }
8441 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308442 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008443 }
8444#endif
8445 status = eHAL_STATUS_SUCCESS;
8446 pCommand->u.setKeyCmd.roamId = roamId;
8447 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8448 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308449 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8450 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008451 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8452 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308453 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008454 //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
8455
8456 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8457 if( !HAL_STATUS_SUCCESS( status ) )
8458 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008459 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008460 }
8461 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008462 // Free the command if there has been a failure, or it is a
8463 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008464 if ( ( NULL != pCommand ) &&
8465 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008466#ifdef FEATURE_WLAN_CCX
8467 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8468#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008469 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008470 {
8471 csrReleaseCommandSetKey( pMac, pCommand );
8472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008473 return( status );
8474}
8475
Jeff Johnson295189b2012-06-20 16:38:30 -07008476eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8477 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8478{
8479 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8480 tSmeCmd *pCommand = NULL;
8481 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008482 do
8483 {
8484 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8485 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008486 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008487 status = eHAL_STATUS_CSR_WRONG_STATE;
8488 break;
8489 }
8490 pCommand = csrGetCommandBuffer(pMac);
8491 if(NULL == pCommand)
8492 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008493 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008494 status = eHAL_STATUS_RESOURCES;
8495 break;
8496 }
8497 pCommand->command = eSmeCommandRemoveKey;
8498 pCommand->sessionId = (tANI_U8)sessionId;
8499 pCommand->u.removeKeyCmd.roamId = roamId;
8500 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308501 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8502 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008503 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8504 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8505 {
8506 //in this case, put it to the end of the Q incase there is a set key pending.
8507 fImediate = eANI_BOOLEAN_FALSE;
8508 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008509 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008510 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008511 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008512 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8513 if( !HAL_STATUS_SUCCESS( status ) )
8514 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008515 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008516 break;
8517 }
8518 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8520 {
8521 csrReleaseCommandRemoveKey( pMac, pCommand );
8522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 return (status );
8524}
8525
Jeff Johnson295189b2012-06-20 16:38:30 -07008526eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8527{
8528 eHalStatus status;
8529 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8530 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8531 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8532 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008533#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8534 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8535 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008536 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308538 vos_mem_set(&setKeyEvent,
8539 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008540 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8541 {
8542 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8543 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8544 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8545 }
8546 else
8547 {
8548 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8549 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8550 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8551 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308552 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008553 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008554 {
8555 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008556 //It has to be static WEP here
8557 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8558 {
8559 setKeyEvent.keyId = (v_U8_t)defKeyId;
8560 }
8561 }
8562 else
8563 {
8564 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8565 }
8566 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8567 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8568 }
8569#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008570 if( csrIsSetKeyAllowed(pMac, sessionId) )
8571 {
8572 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8573 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8574 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8575 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8576 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8577 pCommand->u.setKeyCmd.keyRsc);
8578 }
8579 else
8580 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008581 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008582 //Set this status so the error handling take care of the case.
8583 status = eHAL_STATUS_CSR_WRONG_STATE;
8584 }
8585 if( !HAL_STATUS_SUCCESS(status) )
8586 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008587 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008588 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008589#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008590 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008591 {
8592 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8593 {
8594 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8595 }
8596 else
8597 {
8598 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8599 }
8600 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8601 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8602 }
8603#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008605 return ( status );
8606}
8607
Jeff Johnson295189b2012-06-20 16:38:30 -07008608eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8609{
8610 eHalStatus status;
8611 tpSirSmeRemoveKeyReq pMsg = NULL;
8612 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8613 tANI_U8 *p;
8614 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008615#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8616 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8617 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05308618 vos_mem_set(&removeKeyEvent,
8619 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008620 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8621 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8622 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308623 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008624 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8625 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8626 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8627#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008628 if( csrIsSetKeyAllowed(pMac, sessionId) )
8629 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308630 pMsg = vos_mem_malloc(wMsgLen);
8631 if ( NULL == pMsg )
8632 status = eHAL_STATUS_FAILURE;
8633 else
8634 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008635 }
8636 else
8637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008638 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008639 //Set the error status so error handling kicks in below
8640 status = eHAL_STATUS_CSR_WRONG_STATE;
8641 }
8642 if( HAL_STATUS_SUCCESS( status ) )
8643 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308644 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008645 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8646 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008647 pMsg->sessionId = (tANI_U8)sessionId;
8648 pMsg->transactionId = 0;
8649 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8650 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8651 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308652 vos_mem_copy(p,
8653 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8654 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008655 p += sizeof(tSirMacAddr);
8656 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308657 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008658 p += sizeof(tSirMacAddr);
8659 // edType
8660 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8661 p++;
8662 // weptype
8663 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8664 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8665 {
8666 *p = (tANI_U8)eSIR_WEP_STATIC;
8667 }
8668 else
8669 {
8670 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8671 }
8672 p++;
8673 //keyid
8674 *p = pCommand->u.removeKeyCmd.keyId;
8675 p++;
8676 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008677 status = palSendMBMessage(pMac->hHdd, pMsg);
8678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008679 if( !HAL_STATUS_SUCCESS( status ) )
8680 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008681 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008682#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8683 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008684 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008685 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8686#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008687 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8688 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008689 return ( status );
8690}
8691
Jeff Johnson295189b2012-06-20 16:38:30 -07008692eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8693{
8694 eHalStatus status;
8695
8696 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8697 {
8698 status = eHAL_STATUS_CSR_WRONG_STATE;
8699 }
8700 else
8701 {
8702 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8703 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008704 return ( status );
8705}
8706
Jeff Johnson295189b2012-06-20 16:38:30 -07008707/*
8708 Prepare a filter base on a profile for parsing the scan results.
8709 Upon successful return, caller MUST call csrFreeScanFilter on
8710 pScanFilter when it is done with the filter.
8711*/
8712eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8713 tCsrScanResultFilter *pScanFilter)
8714{
8715 eHalStatus status = eHAL_STATUS_SUCCESS;
8716 tANI_U32 size = 0;
8717 tANI_U8 index = 0;
8718
8719 do
8720 {
8721 if(pProfile->BSSIDs.numOfBSSIDs)
8722 {
8723 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308724 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8725 if ( NULL == pScanFilter->BSSIDs.bssid )
8726 status = eHAL_STATUS_FAILURE;
8727 else
8728 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008729 if(!HAL_STATUS_SUCCESS(status))
8730 {
8731 break;
8732 }
8733 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308734 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008735 }
8736 if(pProfile->SSIDs.numOfSSIDs)
8737 {
8738 if( !CSR_IS_WDS_STA( pProfile ) )
8739 {
8740 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8741 }
8742 else
8743 {
8744 //For WDS station
8745 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8746 pScanFilter->SSIDs.numOfSSIDs = 1;
8747 }
8748 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308749 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8750 if ( NULL == pScanFilter->SSIDs.SSIDList )
8751 status = eHAL_STATUS_FAILURE;
8752 else
8753 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008754 if(!HAL_STATUS_SUCCESS(status))
8755 {
8756 break;
8757 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308758 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8759 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008760 }
8761 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8762 {
8763 pScanFilter->ChannelInfo.numOfChannels = 0;
8764 pScanFilter->ChannelInfo.ChannelList = NULL;
8765 }
8766 else if(pProfile->ChannelInfo.numOfChannels)
8767 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308768 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8769 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8770 pProfile->ChannelInfo.numOfChannels);
8771 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8772 status = eHAL_STATUS_FAILURE;
8773 else
8774 status = eHAL_STATUS_SUCCESS;
8775
Jeff Johnson295189b2012-06-20 16:38:30 -07008776 pScanFilter->ChannelInfo.numOfChannels = 0;
8777 if(HAL_STATUS_SUCCESS(status))
8778 {
8779 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8780 {
8781 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8782 {
8783 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8784 = pProfile->ChannelInfo.ChannelList[index];
8785 pScanFilter->ChannelInfo.numOfChannels++;
8786 }
8787 else
8788 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008789 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008791 }
8792 }
8793 else
8794 {
8795 break;
8796 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008797 }
8798 else
8799 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308800 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008801 status = eHAL_STATUS_FAILURE;
8802 break;
8803 }
8804 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8805 pScanFilter->authType = pProfile->AuthType;
8806 pScanFilter->EncryptionType = pProfile->EncryptionType;
8807 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8808 pScanFilter->BSSType = pProfile->BSSType;
8809 pScanFilter->phyMode = pProfile->phyMode;
8810#ifdef FEATURE_WLAN_WAPI
8811 //check if user asked for WAPI with 11n or auto mode, in that case modify
8812 //the phymode to 11g
8813 if(csrIsProfileWapi(pProfile))
8814 {
8815 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8816 {
8817 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8818 }
8819 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8820 {
8821 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8822 }
8823 if(!pScanFilter->phyMode)
8824 {
8825 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8826 }
8827 }
8828#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008829 /*Save the WPS info*/
8830 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 if( pProfile->countryCode[0] )
8832 {
8833 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05308834 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
8835 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008836 }
8837#ifdef WLAN_FEATURE_VOWIFI_11R
8838 if (pProfile->MDID.mdiePresent)
8839 {
8840 pScanFilter->MDID.mdiePresent = 1;
8841 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8842 }
8843#endif
8844
8845 }while(0);
8846
8847 if(!HAL_STATUS_SUCCESS(status))
8848 {
8849 csrFreeScanFilter(pMac, pScanFilter);
8850 }
8851
8852 return(status);
8853}
8854
Jeff Johnson295189b2012-06-20 16:38:30 -07008855tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8856 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8857{
8858 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8859 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008860 do
8861 {
8862 // Validate the type is ok...
8863 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8864 pCommand = csrGetCommandBuffer( pMac );
8865 if ( !pCommand )
8866 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008867 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008868 break;
8869 }
8870 //Change the substate in case it is waiting for key
8871 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8872 {
8873 csrRoamStopWaitForKeyTimer( pMac );
8874 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8875 }
8876 pCommand->command = eSmeCommandWmStatusChange;
8877 pCommand->sessionId = (tANI_U8)sessionId;
8878 pCommand->u.wmStatusChangeCmd.Type = Type;
8879 if ( eCsrDisassociated == Type )
8880 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308881 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
8882 pSmeRsp,
8883 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008884 }
8885 else
8886 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308887 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
8888 pSmeRsp,
8889 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008890 }
8891 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8892 {
8893 fCommandQueued = eANI_BOOLEAN_TRUE;
8894 }
8895 else
8896 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008897 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008898 csrReleaseCommandWmStatusChange( pMac, pCommand );
8899 }
8900
Jeff Johnson295189b2012-06-20 16:38:30 -07008901 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8902 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008903 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008904 return( fCommandQueued );
8905}
8906
Jeff Johnson295189b2012-06-20 16:38:30 -07008907static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8908{
8909 v_S7_t rssi = 0;
8910 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8911 if(pGetRssiReq)
8912 {
8913 if(NULL != pGetRssiReq->pVosContext)
8914 {
8915 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8916 }
8917 else
8918 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008919 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008920 return;
8921 }
8922
8923 if(NULL != pGetRssiReq->rssiCallback)
8924 {
8925 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8926 }
8927 else
8928 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008929 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 return;
8931 }
8932 }
8933 else
8934 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008935 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008936 }
8937 return;
8938}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308939
8940static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
8941{
8942 tANI_S8 snr = 0;
8943 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
8944
8945 if (pGetSnrReq)
8946 {
8947 if (VOS_STATUS_SUCCESS !=
8948 WDA_GetSnr(pGetSnrReq->staId, &snr))
8949 {
8950 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
8951 return;
8952 }
8953
8954 if (pGetSnrReq->snrCallback)
8955 {
8956 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
8957 pGetSnrReq->pDevContext);
8958 }
8959 else
8960 {
8961 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
8962 return;
8963 }
8964 }
8965 else
8966 {
8967 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
8968 }
8969 return;
8970}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008971#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8972void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8973{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008974 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8975
Jeff Johnson36d483b2013-04-08 11:08:53 -07008976 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008977 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008978 /* Get roam Rssi request is backed up and passed back to the response,
8979 Extract the request message to fetch callback */
8980 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8981 v_S7_t rssi = pRoamRssiRsp->rssi;
8982
8983 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008984 {
8985 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8986 reqBkp->rssiCallback = NULL;
8987 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08008988 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008989 }
8990 else
8991 {
8992 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8993 if (NULL != reqBkp)
8994 {
8995 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08008996 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008997 }
8998 }
8999 }
9000 else
9001 {
9002 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9003 }
9004 return;
9005}
9006#endif
9007
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009008
9009#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
9010void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9011{
9012 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9013
9014 if (NULL != pTsmStatsRsp)
9015 {
9016 /* Get roam Rssi request is backed up and passed back to the response,
9017 Extract the request message to fetch callback */
9018 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9019
9020 if (NULL != reqBkp)
9021 {
9022 if (NULL != reqBkp->tsmStatsCallback)
9023 {
9024 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9025 pTsmStatsRsp->staId, reqBkp->pDevContext);
9026 reqBkp->tsmStatsCallback = NULL;
9027 }
9028 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009029 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009030 }
9031 else
9032 {
9033 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9034 if (NULL != reqBkp)
9035 {
9036 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009037 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009038 }
9039 }
9040 }
9041 else
9042 {
9043 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9044 }
9045 return;
9046}
9047
9048void csrSendCcxAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
9049{
9050 tANI_U32 roamTS2 = 0;
9051 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009052 tpPESession pSessionEntry = NULL;
9053 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009054
9055 if (NULL == pSession)
9056 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009057 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009058 return;
9059 }
9060
9061 roamTS2 = vos_timer_get_system_time();
9062 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009063 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9064 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009065 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009066
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009067 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9068 if (NULL == pSessionEntry)
9069 {
9070 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9071 return;
9072 }
9073 pSessionEntry->ccxContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009074 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
9075 0, eCSR_ROAM_CCX_ADJ_AP_REPORT_IND, 0);
9076}
9077#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
9078
Jeff Johnsone7245742012-09-05 17:12:55 -07009079static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9080{
9081 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9082 if(pTlRssiInd)
9083 {
9084 if(NULL != pTlRssiInd->tlCallback)
9085 {
9086 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009087 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009088 }
9089 else
9090 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009091 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009092 }
9093 }
9094 else
9095 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009096 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009097 }
9098 return;
9099}
Jeff Johnson295189b2012-06-20 16:38:30 -07009100
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309101eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9102{
9103 tpSirResetAPCapsChange pMsg;
9104 tANI_U16 len;
9105 eHalStatus status = eHAL_STATUS_SUCCESS;
9106
9107 /* Create the message and send to lim */
9108 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309109 pMsg = vos_mem_malloc(len);
9110 if ( NULL == pMsg )
9111 status = eHAL_STATUS_FAILURE;
9112 else
9113 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309114 if (HAL_STATUS_SUCCESS(status))
9115 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309116 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309117 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9118 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309119 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009120 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9121 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309122 status = palSendMBMessage(pMac->hHdd, pMsg);
9123 }
9124 else
9125 {
9126 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9127 }
9128 return status;
9129}
9130
Jeff Johnson295189b2012-06-20 16:38:30 -07009131void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9132{
9133 tSirSmeAssocInd *pAssocInd;
9134 tSirSmeDisassocInd *pDisassocInd;
9135 tSirSmeDeauthInd *pDeauthInd;
9136 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9137 tSirSmeNewBssInfo *pNewBss;
9138 tSmeIbssPeerInd *pIbssPeerInd;
9139 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9140 tSirSmeApNewCaps *pApNewCaps;
9141 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9142 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9143 tCsrRoamInfo *pRoamInfo = NULL;
9144 tCsrRoamInfo roamInfo;
9145 eHalStatus status;
9146 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9147 tCsrRoamSession *pSession = NULL;
9148 tpSirSmeSwitchChannelInd pSwitchChnInd;
9149 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309150 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009151
9152
9153 if (NULL == pSirMsg)
9154 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9155 return;
9156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009157 switch( pSirMsg->messageType )
9158 {
9159 case eWNI_SME_ASSOC_IND:
9160 {
9161 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009162 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009163 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9164 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9165 if( HAL_STATUS_SUCCESS( status ) )
9166 {
9167 pSession = CSR_GET_SESSION(pMac, sessionId);
9168
Jeff Johnson32d95a32012-09-10 13:15:23 -07009169 if(!pSession)
9170 {
9171 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9172 return;
9173 }
9174
Jeff Johnson295189b2012-06-20 16:38:30 -07009175 pRoamInfo = &roamInfo;
9176
9177 // Required for indicating the frames to upper layer
9178 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9179 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9180
9181 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9182 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9183 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9184 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9185
9186 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9187 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9188 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9189
9190 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9191 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309192 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9193 sizeof(tSirMacAddr));
9194 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9195 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009196 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9197 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009198 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009199 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9200 {
9201 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9202 {
9203 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9204 pSession->pConnectBssDesc,
9205 &(pRoamInfo->peerMac),
9206 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9207 pRoamInfo->fAuthRequired = FALSE;
9208 }
9209 else
9210 {
9211 pRoamInfo->fAuthRequired = TRUE;
9212 }
9213 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9214 if (!HAL_STATUS_SUCCESS(status))
9215 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009217 /* Send Association completion message to PE */
9218 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9219
9220 /* send a message to CSR itself just to avoid the EAPOL frames going
9221 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009222 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9223 {
9224 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009226 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9227 {
9228 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9229 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9230 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009232 }
9233 }
9234 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009235 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009236 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309237 // Check if AP dis-associated us because of MIC failure. If so,
9238 // then we need to take action immediately and not wait till the
9239 // the WmStatusChange requests is pushed and processed
9240 tSmeCmd *pCommand;
9241
9242 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9243 status = csrRoamGetSessionIdFromBSSID( pMac,
9244 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9245 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009246 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309247 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9248 " for session %d "), sessionId);
9249 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9250 MAC_ADDRESS_STR " "
9251 " reason = %d status = %d "),
9252 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9253 pDisassocInd->reasonCode,
9254 pDisassocInd->statusCode);
9255 // If we are in neighbor preauth done state then on receiving
9256 // disassoc or deauth we dont roam instead we just disassoc
9257 // from current ap and then go to disconnected state
9258 // This happens for CCX and 11r FT connections ONLY.
9259#ifdef WLAN_FEATURE_VOWIFI_11R
9260 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9261 {
9262 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9263 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009264#endif
9265#ifdef FEATURE_WLAN_CCX
Agarwal Ashish4f616132013-12-30 23:32:50 +05309266 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9267 {
9268 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009270#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009271#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309272 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9273 {
9274 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9275 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009276#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309277 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009278
Agarwal Ashish4f616132013-12-30 23:32:50 +05309279 if (!pSession)
9280 {
9281 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9282 return;
9283 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009284
Agarwal Ashish4f616132013-12-30 23:32:50 +05309285 if ( csrIsConnStateInfra( pMac, sessionId ) )
9286 {
9287 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9288 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009289#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309290 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009291#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309292 csrRoamLinkDown(pMac, sessionId);
9293 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9294 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9295 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009296
Agarwal Ashish4f616132013-12-30 23:32:50 +05309297 pCommand = csrGetCommandBuffer(pMac);
9298 if (NULL == pCommand)
9299 {
9300 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9301 status = eHAL_STATUS_RESOURCES;
9302 }
9303 pRoamInfo = &roamInfo;
9304 pRoamInfo->statusCode = pDisassocInd->statusCode;
9305 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9306 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009307
Agarwal Ashish4f616132013-12-30 23:32:50 +05309308 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9309 sizeof(tSirMacAddr));
9310 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9311 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009312
Agarwal Ashish4f616132013-12-30 23:32:50 +05309313 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9314 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009315
Agarwal Ashish4f616132013-12-30 23:32:50 +05309316 /*
9317 * STA/P2P client got disassociated so remove any pending deauth
9318 * commands in sme pending list
9319 */
9320 pCommand->command = eSmeCommandRoam;
9321 pCommand->sessionId = (tANI_U8)sessionId;
9322 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9323 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9324 pDisassocInd->peerMacAddr,
9325 sizeof(tSirMacAddr));
9326 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9327 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009328
Agarwal Ashish4f616132013-12-30 23:32:50 +05309329 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009330 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309331 else
9332 {
9333 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9334 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9335 }
Kiet Lam82004c62013-11-11 13:24:28 +05309336 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009337 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009338 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009339 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009340 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9341 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9342 if( HAL_STATUS_SUCCESS( status ) )
9343 {
9344 // If we are in neighbor preauth done state then on receiving
9345 // disassoc or deauth we dont roam instead we just disassoc
9346 // from current ap and then go to disconnected state
9347 // This happens for CCX and 11r FT connections ONLY.
9348#ifdef WLAN_FEATURE_VOWIFI_11R
9349 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9350 {
9351 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9352 }
9353#endif
9354#ifdef FEATURE_WLAN_CCX
9355 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9356 {
9357 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9358 }
9359#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009360#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309361 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009362 {
9363 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9364 }
9365#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009366 pSession = CSR_GET_SESSION( pMac, sessionId );
9367
Jeff Johnson32d95a32012-09-10 13:15:23 -07009368 if(!pSession)
9369 {
9370 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9371 return;
9372 }
9373
Jeff Johnson295189b2012-06-20 16:38:30 -07009374 if ( csrIsConnStateInfra( pMac, sessionId ) )
9375 {
9376 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009378#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9379 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9380#endif
9381 csrRoamLinkDown(pMac, sessionId);
9382 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009383 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9384 {
9385
9386 pRoamInfo = &roamInfo;
9387
9388 pRoamInfo->statusCode = pDeauthInd->statusCode;
9389 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9390
9391 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9392
Kiet Lam64c1b492013-07-12 13:56:44 +05309393 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9394 sizeof(tSirMacAddr));
9395 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9396 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009397
9398 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009400 }
9401 break;
9402
9403 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 -08009404 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009405 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9406 //Update with the new channel id.
9407 //The channel id is hidden in the statusCode.
9408 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9409 if( HAL_STATUS_SUCCESS( status ) )
9410 {
9411 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009412 if(!pSession)
9413 {
9414 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9415 return;
9416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009417 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9418 if(pSession->pConnectBssDesc)
9419 {
9420 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9421 }
9422 }
9423 break;
9424
9425 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009426 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009427 {
9428 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9429 sessionId = pDeauthRsp->sessionId;
9430 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9431 {
9432 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009433 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9434 {
9435 pRoamInfo = &roamInfo;
9436 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309437 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9438 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009439 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9440 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9441 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9442 }
9443 }
9444 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009445 break;
9446
9447 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009448 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009449 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009450 {
9451 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9452 sessionId = pDisassocRsp->sessionId;
9453 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9454 {
9455 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009456 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9457 {
9458 pRoamInfo = &roamInfo;
9459 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309460 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9461 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009462 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9463 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9464 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9465 }
9466 }
9467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009468 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009469 case eWNI_SME_MIC_FAILURE_IND:
9470 {
9471 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9472 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9473 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009474
9475 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9476 if( HAL_STATUS_SUCCESS( status ) )
9477 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309478 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009479 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9480 pRoamInfo = &roamInfo;
9481 if(pMicInd->info.multicast)
9482 {
9483 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9484 }
9485 else
9486 {
9487 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9488 }
9489 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9490 }
9491
Jeff Johnson295189b2012-06-20 16:38:30 -07009492#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9493 {
lukez3c809222013-05-03 10:23:02 -07009494 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009495 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009496 if(!pSession)
9497 {
9498 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9499 return;
9500 }
lukez3c809222013-05-03 10:23:02 -07009501
Kiet Lam64c1b492013-07-12 13:56:44 +05309502 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009503 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9504 secEvent.encryptionModeMulticast =
9505 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9506 secEvent.encryptionModeUnicast =
9507 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9508 secEvent.authMode =
9509 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309510 vos_mem_copy(secEvent.bssid,
9511 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009512 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9513 }
9514#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009515 }
9516 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009517 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9518 {
9519 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9520 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009521 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009522
9523 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9524 if( HAL_STATUS_SUCCESS( status ) )
9525 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309526 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009527 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9528 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9529 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9530 }
9531 }
9532 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009533
Jeff Johnson295189b2012-06-20 16:38:30 -07009534 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9535 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9536 switch( pStatusChangeMsg->statusChangeCode )
9537 {
9538 case eSIR_SME_IBSS_ACTIVE:
9539 sessionId = csrFindIbssSession( pMac );
9540 if( CSR_SESSION_ID_INVALID != sessionId )
9541 {
9542 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009543 if(!pSession)
9544 {
9545 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9546 return;
9547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009548 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9549 if(pSession->pConnectBssDesc)
9550 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309551 vos_mem_copy(&roamInfo.bssid,
9552 pSession->pConnectBssDesc->bssId,
9553 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9555 pRoamInfo = &roamInfo;
9556 }
9557 else
9558 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009559 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009560 }
9561 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9562 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9563 }
9564 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009565 case eSIR_SME_IBSS_INACTIVE:
9566 sessionId = csrFindIbssSession( pMac );
9567 if( CSR_SESSION_ID_INVALID != sessionId )
9568 {
9569 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009570 if(!pSession)
9571 {
9572 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9573 return;
9574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009575 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9576 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9577 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9578 }
9579 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009580 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9581 sessionId = csrFindIbssSession( pMac );
9582 if( CSR_SESSION_ID_INVALID != sessionId )
9583 {
9584 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009585 if(!pSession)
9586 {
9587 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9588 return;
9589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009590 // update the connection state information
9591 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009592#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9593 {
9594 vos_log_ibss_pkt_type *pIbssLog;
9595 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009596 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9597 if(pIbssLog)
9598 {
9599 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9600 if(pNewBss)
9601 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309602 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009603 if(pNewBss->ssId.length)
9604 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309605 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9606 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009607 }
9608 pIbssLog->operatingChannel = pNewBss->channelNumber;
9609 }
9610 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9611 {
9612 //***U8 is not enough for beacon interval
9613 pIbssLog->beaconInterval = (v_U8_t)bi;
9614 }
9615 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9616 }
9617 }
9618#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009619 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009620
9621 if ((eCSR_ENCRYPT_TYPE_NONE ==
9622 pSession->connectedProfile.EncryptionType ))
9623 {
9624 csrRoamIssueSetContextReq( pMac, sessionId,
9625 pSession->connectedProfile.EncryptionType,
9626 pSession->pConnectBssDesc,
9627 &Broadcastaddr,
9628 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009630 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9631 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309632 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9633 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009634 pRoamInfo = &roamInfo;
9635 //This BSSID is th ereal BSSID, let's save it
9636 if(pSession->pConnectBssDesc)
9637 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309638 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9639 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009640 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009641 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009642 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009644 // detection by LIM that the capabilities of the associated AP have changed.
9645 case eSIR_SME_AP_CAPS_CHANGED:
9646 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009647 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9649 if( HAL_STATUS_SUCCESS( status ) )
9650 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009651 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9652 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309653 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009654 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9655 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9656 )
9657 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309658 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9659 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009660 }
9661 else
9662 {
9663 smsLog(pMac, LOGW,
9664 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009665 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009666 pMac->roam.curState[sessionId],
9667 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309668 /* We ignore the caps change event if CSR is not in full connected state.
9669 * Send one event to PE to reset limSentCapsChangeNtf
9670 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9671 * otherwise lim cannot send any CAPS change events to SME */
9672 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009673 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009674 }
9675 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309676
Jeff Johnson295189b2012-06-20 16:38:30 -07009677 default:
9678 roamStatus = eCSR_ROAM_FAILED;
9679 result = eCSR_ROAM_RESULT_NONE;
9680 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009681 } // end switch on statusChangeCode
9682 if(eCSR_ROAM_RESULT_NONE != result)
9683 {
9684 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9685 }
9686 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 case eWNI_SME_IBSS_NEW_PEER_IND:
9688 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009689#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9690 {
9691 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009692 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9693 if(pIbssLog)
9694 {
9695 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309696 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009697 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9698 }
9699 }
9700#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009701 sessionId = csrFindIbssSession( pMac );
9702 if( CSR_SESSION_ID_INVALID != sessionId )
9703 {
9704 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009705
9706 if(!pSession)
9707 {
9708 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9709 return;
9710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009711 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9712 if(pSession->pConnectBssDesc)
9713 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309714 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9715 sizeof(tCsrBssid));
9716 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9717 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009718 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9719 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309720 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9721 - sizeof(tSmeIbssPeerInd)));
9722 if ( NULL == roamInfo.pbFrames )
9723 status = eHAL_STATUS_FAILURE;
9724 else
9725 status = eHAL_STATUS_SUCCESS;
9726 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009727 {
9728 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309729 vos_mem_copy(roamInfo.pbFrames,
9730 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9731 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009732 }
9733 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9734 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9735 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309736 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9737 if ( NULL == roamInfo.pBssDesc )
9738 status = eHAL_STATUS_FAILURE;
9739 else
9740 status = eHAL_STATUS_SUCCESS;
9741 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009742 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309743 vos_mem_copy(roamInfo.pBssDesc,
9744 pSession->pConnectBssDesc,
9745 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009746 }
9747 if(HAL_STATUS_SUCCESS(status))
9748 {
9749 pRoamInfo = &roamInfo;
9750 }
9751 else
9752 {
9753 if(roamInfo.pbFrames)
9754 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309755 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009756 }
9757 if(roamInfo.pBssDesc)
9758 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309759 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009760 }
9761 }
9762 }
9763 else
9764 {
9765 pRoamInfo = &roamInfo;
9766 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009767 if ((eCSR_ENCRYPT_TYPE_NONE ==
9768 pSession->connectedProfile.EncryptionType ))
9769 {
9770 csrRoamIssueSetContextReq( pMac, sessionId,
9771 pSession->connectedProfile.EncryptionType,
9772 pSession->pConnectBssDesc,
9773 &(pIbssPeerInd->peerAddr),
9774 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9775 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009776 }
9777 else
9778 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009779 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009780 }
9781 //send up the sec type for the new peer
9782 if (pRoamInfo)
9783 {
9784 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9785 }
9786 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9787 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9788 if(pRoamInfo)
9789 {
9790 if(roamInfo.pbFrames)
9791 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309792 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009793 }
9794 if(roamInfo.pBssDesc)
9795 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309796 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009797 }
9798 }
9799 }
9800 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009801 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9802 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9803 sessionId = csrFindIbssSession( pMac );
9804 if( CSR_SESSION_ID_INVALID != sessionId )
9805 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009806#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9807 {
9808 vos_log_ibss_pkt_type *pIbssLog;
9809
9810 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9811 if(pIbssLog)
9812 {
9813 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9814 if(pIbssPeerInd)
9815 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309816 vos_mem_copy(pIbssLog->peerMacAddr,
9817 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009818 }
9819 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9820 }
9821 }
9822#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009823 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009824 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9825 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9826 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309827 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9828 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009829 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9830 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9831 }
9832 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009833 case eWNI_SME_SETCONTEXT_RSP:
9834 {
9835 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9836 tListElem *pEntry;
9837 tSmeCmd *pCommand;
9838
9839 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9840 if ( pEntry )
9841 {
9842 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9843 if ( eSmeCommandSetKey == pCommand->command )
9844 {
9845 sessionId = pCommand->sessionId;
9846 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009847
9848 if(!pSession)
9849 {
9850 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9851 return;
9852 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009853
9854#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9855 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9856 {
9857 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309858 vos_mem_set(&setKeyEvent,
9859 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009860 if( pRsp->peerMacAddr[0] & 0x01 )
9861 {
9862 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9863 }
9864 else
9865 {
9866 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9867 }
9868 setKeyEvent.encryptionModeMulticast =
9869 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9870 setKeyEvent.encryptionModeUnicast =
9871 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309872 vos_mem_copy(setKeyEvent.bssid,
9873 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009874 setKeyEvent.authMode =
9875 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009876 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009877 {
9878 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9879 }
9880 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9881 }
9882#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9883 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9884 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009885 csrRoamStopWaitForKeyTimer( pMac );
9886
Jeff Johnson295189b2012-06-20 16:38:30 -07009887 //We are done with authentication, whethere succeed or not
9888 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009889 //We do it here because this linkup function is not called after association
9890 //when a key needs to be set.
9891 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9892 {
9893 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9894 }
9895 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009896 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009897 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309898 vos_mem_copy(&roamInfo.peerMac,
9899 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07009900 //Make sure we install the GTK before indicating to HDD as authenticated
9901 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +05309902 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
9903 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009904 {
Yathish9f22e662012-12-10 14:21:35 -08009905#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9906 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9907 {
9908 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +05309909 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -08009910 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9911 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9912 pMsg->seesionId = sessionId;
9913 status = palSendMBMessage(pMac->hHdd, pMsg );
9914 }
9915#endif
9916 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009917 }
9918 else
9919 {
9920 result = eCSR_ROAM_RESULT_NONE;
9921 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009922 pRoamInfo = &roamInfo;
9923 }
9924 else
9925 {
9926 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009927 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
9928 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
9929 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009930 }
9931 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9932 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009933 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9934 // can go ahead and initiate the TSPEC if any are pending
9935 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009936#ifdef FEATURE_WLAN_CCX
9937 //Send Adjacent AP repot to new AP.
9938 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9939 pSession->isPrevApInfoValid &&
9940 pSession->connectedProfile.isCCXAssoc)
9941 {
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009942#ifdef FEATURE_WLAN_CCX_UPLOAD
9943 csrSendCcxAdjacentApRepInd(pMac, pSession);
9944#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009945 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9946#endif
9947 pSession->isPrevApInfoValid = FALSE;
9948 }
9949#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009950 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9951 {
9952 csrReleaseCommandSetKey( pMac, pCommand );
9953 }
9954 }
9955 else
9956 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009957 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009958 }
9959 }
9960 else
9961 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009962 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009964 smeProcessPendingQueue( pMac );
9965 }
9966 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009967 case eWNI_SME_REMOVEKEY_RSP:
9968 {
9969 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9970 tListElem *pEntry;
9971 tSmeCmd *pCommand;
9972
9973 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9974 if ( pEntry )
9975 {
9976 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9977 if ( eSmeCommandRemoveKey == pCommand->command )
9978 {
9979 sessionId = pCommand->sessionId;
9980 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009981
9982 if(!pSession)
9983 {
9984 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9985 return;
9986 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009987#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9988 {
9989 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309990 vos_mem_set(&removeKeyEvent,
9991 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009992 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9993 removeKeyEvent.encryptionModeMulticast =
9994 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9995 removeKeyEvent.encryptionModeUnicast =
9996 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309997 vos_mem_copy( removeKeyEvent.bssid,
9998 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009999 removeKeyEvent.authMode =
10000 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010001 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010002 {
10003 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10004 }
10005 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10006 }
10007#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010008 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010009 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010010 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10011 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010012 result = eCSR_ROAM_RESULT_NONE;
10013 pRoamInfo = &roamInfo;
10014 }
10015 else
10016 {
10017 result = eCSR_ROAM_RESULT_FAILURE;
10018 }
10019 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10020 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10021 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10022 {
10023 csrReleaseCommandRemoveKey( pMac, pCommand );
10024 }
10025 }
10026 else
10027 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010028 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010029 }
10030 }
10031 else
10032 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010033 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010034 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010035 smeProcessPendingQueue( pMac );
10036 }
10037 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010038 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010039 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010040 csrRoamStatsRspProcessor( pMac, pSirMsg );
10041 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010042#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
10043 case eWNI_SME_GET_ROAM_RSSI_RSP:
10044 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10045 csrRoamRssiRspProcessor( pMac, pSirMsg );
10046 break;
10047#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010048#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
10049 case eWNI_SME_GET_TSM_STATS_RSP:
10050 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10051 csrTsmStatsRspProcessor( pMac, pSirMsg );
10052 break;
10053#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010054 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010055 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010056 csrUpdateRssi( pMac, pSirMsg );
10057 break;
10058
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010059 case eWNI_SME_GET_SNR_REQ:
10060 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10061 csrUpdateSnr(pMac, pSirMsg);
10062 break;
10063
Jeff Johnson295189b2012-06-20 16:38:30 -070010064#ifdef WLAN_FEATURE_VOWIFI_11R
10065 case eWNI_SME_FT_PRE_AUTH_RSP:
10066 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10067 break;
10068#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010069 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10070 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010071 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 -070010072 sessionId = pSmeMaxAssocInd->sessionId;
10073 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010074 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10075 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010076 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10077 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10078 break;
10079
10080 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010081 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010082 btampEstablishLogLinkHdlr( pSirMsg );
10083 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010084 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010085 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010086 csrRoamRssiIndHdlr( pMac, pSirMsg );
10087 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010088#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10089 case eWNI_SME_CANDIDATE_FOUND_IND:
10090 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10091 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10092 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010093 case eWNI_SME_HANDOFF_REQ:
10094 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10095 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10096 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010097#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010098
10099 default:
10100 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010101 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010102}
10103
Jeff Johnson295189b2012-06-20 16:38:30 -070010104void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10105 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10106{
10107 if(pSession)
10108 {
10109 if(pSession->bRefAssocStartCnt)
10110 {
10111 pSession->bRefAssocStartCnt--;
10112 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10113 //Need to call association_completion because there is an assoc_start pending.
10114 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10115 eCSR_ROAM_ASSOCIATION_COMPLETION,
10116 eCSR_ROAM_RESULT_FAILURE);
10117 }
10118 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10119 }
10120 else
10121 {
10122 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10123 }
10124}
10125
10126
10127eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10128{
10129 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010130 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10131 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10132 {
10133 status = csrScanRequestLostLink1( pMac, sessionId );
10134 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010135 return(status);
10136}
10137
Jeff Johnson295189b2012-06-20 16:38:30 -070010138//return a boolean to indicate whether roaming completed or continue.
10139tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10140 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10141{
10142 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10143 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10144 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10145 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010146 if(!pSession)
10147 {
10148 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10149 return eANI_BOOLEAN_FALSE;
10150 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010151 //Check whether time is up
10152 if(pSession->fCancelRoaming || fForce ||
10153 ((curTime - pSession->roamingStartTime) > roamTime) ||
10154 eCsrReassocRoaming == pSession->roamingReason ||
10155 eCsrDynamicRoaming == pSession->roamingReason)
10156 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010157 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010158 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10159 {
10160 //roaming is cancelled, tell HDD to indicate disconnect
10161 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10162 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10163 //to be eSIR_BEACON_MISSED
10164 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10165 {
10166 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10167 }
10168 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10169 {
10170 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10171 }
10172 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10173 {
10174 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10175 }
10176 else
10177 {
10178 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10179 }
10180 }
10181 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10182 pSession->roamingReason = eCsrNotRoaming;
10183 }
10184 else
10185 {
10186 pSession->roamResult = roamResult;
10187 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10188 {
10189 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10190 pSession->roamingReason = eCsrNotRoaming;
10191 }
10192 else
10193 {
10194 fCompleted = eANI_BOOLEAN_FALSE;
10195 }
10196 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010197 return(fCompleted);
10198}
10199
Jeff Johnson295189b2012-06-20 16:38:30 -070010200void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10201{
10202 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010203
10204 if(!pSession)
10205 {
10206 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10207 return;
10208 }
10209
Jeff Johnson295189b2012-06-20 16:38:30 -070010210 if(CSR_IS_ROAMING(pSession))
10211 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010212 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010213 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10214 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10215 {
10216 //No need to do anything in here because the handler takes care of it
10217 }
10218 else
10219 {
10220 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10221 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10222 //Roaming is stopped after here
10223 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10224 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +053010225 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010226 csrRoamStopRoamingTimer(pMac, sessionId);
10227 }
10228 }
10229}
10230
Jeff Johnson295189b2012-06-20 16:38:30 -070010231void csrRoamRoamingTimerHandler(void *pv)
10232{
10233 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10234 tpAniSirGlobal pMac = pInfo->pMac;
10235 tANI_U32 sessionId = pInfo->sessionId;
10236 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010237
10238 if(!pSession)
10239 {
10240 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10241 return;
10242 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010243
10244 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10245 {
10246 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10247 {
10248 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10249 pSession->roamingReason = eCsrNotRoaming;
10250 }
10251 }
10252}
10253
Jeff Johnson295189b2012-06-20 16:38:30 -070010254eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10255{
10256 eHalStatus status;
10257 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010258
10259 if(!pSession)
10260 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010261 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010262 return eHAL_STATUS_FAILURE;
10263 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010264
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010265 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010266 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010267 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010268
10269 return (status);
10270}
10271
Jeff Johnson295189b2012-06-20 16:38:30 -070010272eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10273{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010274 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010275}
10276
Jeff Johnson295189b2012-06-20 16:38:30 -070010277void csrRoamWaitForKeyTimeOutHandler(void *pv)
10278{
10279 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10280 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010281 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010282 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010283
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010284 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010285 pMac->roam.neighborRoamInfo.neighborRoamState,
10286 pMac->roam.curSubState[pInfo->sessionId]);
10287
Jeff Johnson295189b2012-06-20 16:38:30 -070010288 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10289 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010290#ifdef FEATURE_WLAN_LFR
10291 if (csrNeighborRoamIsHandoffInProgress(pMac))
10292 {
10293 /*
10294 * Enable heartbeat timer when hand-off is in progress
10295 * and Key Wait timer expired.
10296 */
10297 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010298 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010299 pMac->roam.configParam.HeartbeatThresh24);
10300 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10301 pMac->roam.configParam.HeartbeatThresh24,
10302 NULL, eANI_BOOLEAN_FALSE);
10303 }
10304#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010305 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010306
Jeff Johnson295189b2012-06-20 16:38:30 -070010307 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010308 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10309 {
10310 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10311 pInfo->sessionId);
10312 }
10313
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010314 if (pSession)
10315 {
10316 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10317 {
10318 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10319 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010320 if( (pSession->connectedProfile.AuthType ==
10321 eCSR_AUTH_TYPE_SHARED_KEY) &&
10322 ( (pSession->connectedProfile.EncryptionType ==
10323 eCSR_ENCRYPT_TYPE_WEP40) ||
10324 (pSession->connectedProfile.EncryptionType ==
10325 eCSR_ENCRYPT_TYPE_WEP104) ))
10326 {
10327 status = sme_AcquireGlobalLock( &pMac->sme );
10328 if ( HAL_STATUS_SUCCESS( status ) )
10329 {
10330 csrRoamDisconnect( pMac, pInfo->sessionId,
10331 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10332 sme_ReleaseGlobalLock( &pMac->sme );
10333 }
10334 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010335 }
10336 else
10337 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010338 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010339 __func__);
10340 }
10341 }
10342 else
10343 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010344 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010345 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010346 }
10347
10348}
10349
Jeff Johnson295189b2012-06-20 16:38:30 -070010350eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10351{
10352 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010353#ifdef FEATURE_WLAN_LFR
10354 if (csrNeighborRoamIsHandoffInProgress(pMac))
10355 {
10356 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010357 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010358 __func__,
10359 pMac->roam.neighborRoamInfo.neighborRoamState,
10360 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10361 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10362 }
10363#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010364 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010365 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010366
10367 return (status);
10368}
10369
Jeff Johnson295189b2012-06-20 16:38:30 -070010370eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10371{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010372 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010373 pMac->roam.neighborRoamInfo.neighborRoamState,
10374 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10375#ifdef FEATURE_WLAN_LFR
10376 if (csrNeighborRoamIsHandoffInProgress(pMac))
10377 {
10378 /*
10379 * Enable heartbeat timer when hand-off is in progress
10380 * and Key Wait timer got stopped for some reason
10381 */
10382 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010383 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010384 pMac->roam.configParam.HeartbeatThresh24);
10385 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10386 pMac->roam.configParam.HeartbeatThresh24,
10387 NULL, eANI_BOOLEAN_FALSE);
10388 }
10389#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010390 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010391}
10392
Jeff Johnson295189b2012-06-20 16:38:30 -070010393void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10394 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10395{
10396 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10397 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010398 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10399 /* To silence the KW tool Null chaeck is added */
10400 if(!pSession)
10401 {
10402 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10403 return;
10404 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010405
10406 if(pCommand)
10407 {
10408 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010409 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010410 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010411 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10412 {
10413 //if success, force roaming completion
10414 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10415 }
10416 else
10417 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010418 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010419 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010420 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10421 }
10422}
10423
Jeff Johnson295189b2012-06-20 16:38:30 -070010424eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10425{
10426 eHalStatus status = eHAL_STATUS_SUCCESS;
10427 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10428 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10429 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10430 tCsrRoamInfo *pRoamInfo = NULL;
10431 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010432 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010433 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010434 /* To silence the KW tool Null chaeck is added */
10435 if(!pSession)
10436 {
10437 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10438 return eHAL_STATUS_FAILURE;
10439 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010440 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010441 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010442 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10443 if ( eWNI_SME_DISASSOC_IND == type )
10444 {
10445 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10446 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10447 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010448 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010449 }
10450 else if ( eWNI_SME_DEAUTH_IND == type )
10451 {
10452 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10453 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10454 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010455 /* Convert into proper reason code */
10456 pSession->joinFailStatusCode.reasonCode =
10457 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010458 0 : pDeauthIndMsg->reasonCode;
10459 /* cfg layer expects 0 as reason code if
10460 the driver dosent know the reason code
10461 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010462 }
10463 else
10464 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010465 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010466 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010467 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010468 }
10469
10470 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010471 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010472 {
10473 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10474 }
10475
10476 if ( eWNI_SME_DISASSOC_IND == type )
10477 {
10478 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10479 }
10480 else if ( eWNI_SME_DEAUTH_IND == type )
10481 {
10482 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10483 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010484 if(!HAL_STATUS_SUCCESS(status))
10485 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010486 //If fail to send confirmation to PE, not to trigger roaming
10487 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010488 }
10489
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010490 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010491 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010492 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10493 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010494 if( eWNI_SME_DISASSOC_IND == type)
10495 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010496 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010497 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10498 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010499 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10500 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010501 else if( eWNI_SME_DEAUTH_IND == type )
10502 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010503 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010504 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10505 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010506 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10507 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010508 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010509
10510 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10511 that we are roaming. But if we cannot possibly roam, or if we are unable to
10512 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010513 if(fToRoam)
10514 {
10515 //Only remove the connected BSS in infrastructure mode
10516 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10517 //Not to do anying for lostlink with WDS
10518 if( pMac->roam.configParam.nRoamingTime )
10519 {
10520 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10521 ( eWNI_SME_DEAUTH_IND == type ) ?
10522 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10523 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010524 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010525 //For IBSS, we need to give some more info to HDD
10526 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10527 {
10528 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10529 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10530 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10531 }
10532 else
10533 {
10534 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10535 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010536 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010537 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10538 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10539 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10540 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10541 }
10542 else
10543 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010544 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010545 fToRoam = eANI_BOOLEAN_FALSE;
10546 }
10547 }
10548 else
10549 {
10550 //We are told not to roam, indicate lostlink
10551 fToRoam = eANI_BOOLEAN_FALSE;
10552 }
10553 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010554 if(!fToRoam)
10555 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010556 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010557 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010558 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010559 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10560 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10561 * csrRoamCheckForLinkStatusChange API.
10562 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010563 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10564 }
10565
10566 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010567 Still enable idle scan for polling in case concurrent sessions are running */
10568 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10569 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010570 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010571 }
10572 }
10573
10574 return (status);
10575}
10576
Jeff Johnson295189b2012-06-20 16:38:30 -070010577eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10578{
10579 eHalStatus status = eHAL_STATUS_SUCCESS;
10580 tListElem *pEntry = NULL;
10581 tSmeCmd *pCommand = NULL;
10582 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010583
10584 if(!pSession)
10585 {
10586 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10587 return eHAL_STATUS_FAILURE;
10588 }
10589
Jeff Johnson295189b2012-06-20 16:38:30 -070010590 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010591 //Only remove the connected BSS in infrastructure mode
10592 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10593 if(pMac->roam.configParam.nRoamingTime)
10594 {
10595 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10596 {
10597 //before starting the lost link logic release the roam command for handoff
10598 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10599 if(pEntry)
10600 {
10601 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10602 }
10603 if(pCommand)
10604 {
10605 if (( eSmeCommandRoam == pCommand->command ) &&
10606 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10607 {
10608 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10609 {
10610 csrReleaseCommandRoam( pMac, pCommand );
10611 }
10612 }
10613 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010614 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010615 }
10616 }
10617 else
10618 {
10619 //We are told not to roam, indicate lostlink
10620 status = eHAL_STATUS_FAILURE;
10621 }
10622
10623 return (status);
10624}
Jeff Johnson295189b2012-06-20 16:38:30 -070010625void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10626{
10627 tListElem *pEntry;
10628 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010629 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10630 if ( pEntry )
10631 {
10632 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10633 if ( eSmeCommandWmStatusChange == pCommand->command )
10634 {
10635 // Nothing to process in a Lost Link completion.... It just kicks off a
10636 // roaming sequence.
10637 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10638 {
10639 csrReleaseCommandWmStatusChange( pMac, pCommand );
10640 }
10641 else
10642 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010643 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010644 }
10645
10646 }
10647 else
10648 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010649 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010650 }
10651 }
10652 else
10653 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010654 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010655 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010656 smeProcessPendingQueue( pMac );
10657}
10658
Jeff Johnson295189b2012-06-20 16:38:30 -070010659void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10660{
10661 eHalStatus status = eHAL_STATUS_FAILURE;
10662 tSirSmeRsp *pSirSmeMsg;
10663 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010664
10665 if(!pSession)
10666 {
10667 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10668 return;
10669 }
10670
Jeff Johnson295189b2012-06-20 16:38:30 -070010671 switch ( pCommand->u.wmStatusChangeCmd.Type )
10672 {
10673 case eCsrDisassociated:
10674 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10675 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10676 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010677 case eCsrDeauthenticated:
10678 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10679 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10680 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010681 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010682 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010683 break;
10684 }
10685 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10686 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10687 {
10688 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10689 {
10690 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010691 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010692 }
10693 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010694 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10695 // command here since there is nothing else to do.
10696 csrRoamWmStatusChangeComplete( pMac );
10697}
10698
Jeff Johnson295189b2012-06-20 16:38:30 -070010699//This function returns band and mode information.
10700//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10701//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010702static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10703 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010704{
Jeff Johnson295189b2012-06-20 16:38:30 -070010705 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10706 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10707 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010708 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010709
Jeff Johnson295189b2012-06-20 16:38:30 -070010710 //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 -070010711 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10712 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10713 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10714 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010715 {
10716 switch( pMac->roam.configParam.uCfgDot11Mode )
10717 {
10718 case eCSR_CFG_DOT11_MODE_11A:
10719 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10720 eBand = eCSR_BAND_5G;
10721 break;
10722 case eCSR_CFG_DOT11_MODE_11B:
10723 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10724 eBand = eCSR_BAND_24;
10725 break;
10726 case eCSR_CFG_DOT11_MODE_11G:
10727 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10728 eBand = eCSR_BAND_24;
10729 break;
10730 case eCSR_CFG_DOT11_MODE_11N:
10731 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010732 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10733 break;
10734#ifdef WLAN_FEATURE_11AC
10735 case eCSR_CFG_DOT11_MODE_11AC:
10736 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10737 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010738 /* If the operating channel is in 2.4 GHz band, check for
10739 * INI item to disable VHT operation in 2.4 GHz band
10740 */
10741 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10742 !pMac->roam.configParam.enableVhtFor24GHz)
10743 {
10744 /* Disable 11AC operation */
10745 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10746 }
10747 else
10748 {
10749 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10750 }
10751 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010752 }
10753 else
10754 {
10755 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10756 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10757 }
10758 break;
10759 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10760 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10761 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010762 /* If the operating channel is in 2.4 GHz band, check for
10763 * INI item to disable VHT operation in 2.4 GHz band
10764 */
10765 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10766 !pMac->roam.configParam.enableVhtFor24GHz)
10767 {
10768 /* Disable 11AC operation */
10769 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10770 }
10771 else
10772 {
10773 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10774 }
10775 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010776 }
10777 else
10778 {
10779 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10780 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10781 }
10782 break;
10783#endif
10784 case eCSR_CFG_DOT11_MODE_AUTO:
10785 eBand = pMac->roam.configParam.eBand;
10786 if (eCSR_BAND_24 == eBand)
10787 {
10788 // WiFi tests require IBSS networks to start in 11b mode
10789 // without any change to the default parameter settings
10790 // on the adapter. We use ACU to start an IBSS through
10791 // creation of a startIBSS profile. This startIBSS profile
10792 // has Auto MACProtocol and the adapter property setting
10793 // for dot11Mode is also AUTO. So in this case, let's
10794 // start the IBSS network in 11b mode instead of 11g mode.
10795 // So this is for Auto=profile->MacProtocol && Auto=Global.
10796 // dot11Mode && profile->channel is < 14, then start the IBSS
10797 // in b mode.
10798 //
10799 // Note: we used to have this start as an 11g IBSS for best
10800 // performance... now to specify that the user will have to
10801 // set the do11Mode in the property page to 11g to force it.
10802 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10803 }
10804 else
10805 {
10806#ifdef WLAN_FEATURE_11AC
10807 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10808 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010809 /* If the operating channel is in 2.4 GHz band, check for
10810 * INI item to disable VHT operation in 2.4 GHz band
10811 */
10812 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10813 !pMac->roam.configParam.enableVhtFor24GHz)
10814 {
10815 /* Disable 11AC operation */
10816 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10817 }
10818 else
10819 {
10820 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10821 }
10822 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010823 }
10824 else
10825 {
10826 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10827 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10828 }
10829#else
10830 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10831 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10832#endif
10833 }
10834 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010835 default:
10836 // Global dot11 Mode setting is 11a/b/g.
10837 // use the channel number to determine the Mode setting.
10838 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10839 {
10840 eBand = pMac->roam.configParam.eBand;
10841 if(eCSR_BAND_24 == eBand)
10842 {
10843 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10844 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10845 }
10846 else
10847 {
10848 //prefer 5GHz
10849 eBand = eCSR_BAND_5G;
10850 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10851 }
10852 }
10853 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10854 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010855 // WiFi tests require IBSS networks to start in 11b mode
10856 // without any change to the default parameter settings
10857 // on the adapter. We use ACU to start an IBSS through
10858 // creation of a startIBSS profile. This startIBSS profile
10859 // has Auto MACProtocol and the adapter property setting
10860 // for dot11Mode is also AUTO. So in this case, let's
10861 // start the IBSS network in 11b mode instead of 11g mode.
10862 // So this is for Auto=profile->MacProtocol && Auto=Global.
10863 // dot11Mode && profile->channel is < 14, then start the IBSS
10864 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010865 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010866 // Note: we used to have this start as an 11g IBSS for best
10867 // performance... now to specify that the user will have to
10868 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010869 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10870 eBand = eCSR_BAND_24;
10871 }
10872 else
10873 {
10874 // else, it's a 5.0GHz channel. Set mode to 11a.
10875 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10876 eBand = eCSR_BAND_5G;
10877 }
10878 break;
10879 }//switch
10880 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10881 else
10882 {
10883 //dot11 mode is set, lets pick the band
10884 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10885 {
10886 // channel is Auto also.
10887 eBand = pMac->roam.configParam.eBand;
10888 if(eCSR_BAND_ALL == eBand)
10889 {
10890 //prefer 5GHz
10891 eBand = eCSR_BAND_5G;
10892 }
10893 }
10894 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10895 {
10896 eBand = eCSR_BAND_24;
10897 }
10898 else
10899 {
10900 eBand = eCSR_BAND_5G;
10901 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010902 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010903 if(pBand)
10904 {
10905 *pBand = eBand;
10906 }
10907
10908 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010909 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010910 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10911 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010912
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010913 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10914 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 -070010915 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010916#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010917 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010918#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010919 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10920 {
10921 //We cannot do 11n here
10922 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10923 {
10924 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10925 }
10926 else
10927 {
10928 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10929 }
10930 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010931 return( cfgDot11Mode );
10932}
10933
Jeff Johnson295189b2012-06-20 16:38:30 -070010934eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10935{
10936 eHalStatus status;
10937 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010938
10939 if(!pSession)
10940 {
10941 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10942 return eHAL_STATUS_FAILURE;
10943 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010944
10945#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10946 {
10947 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010948 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10949 if(pIbssLog)
10950 {
10951 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10952 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10953 }
10954 }
10955#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010956 // Set the roaming substate to 'stop Bss request'...
10957 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10958
10959 // attempt to stop the Bss (reason code is ignored...)
10960 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010961 if(!HAL_STATUS_SUCCESS(status))
10962 {
10963 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10964 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010965 return (status);
10966}
10967
Jeff Johnson295189b2012-06-20 16:38:30 -070010968//pNumChan is a caller allocated space with the sizeof pChannels
10969eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10970{
10971
10972 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10973 (tANI_U8 *)pChannels,
10974 pNumChan));
10975}
10976
Kiran4a17ebe2013-01-31 10:43:43 -080010977tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10978{
10979 tANI_U32 cfgLength = 0;
10980 tANI_U16 cfgId = 0;
10981 tPowerdBm maxTxPwr = 0;
10982 tANI_U8 *pCountryInfo = NULL;
10983 eHalStatus status;
10984 tANI_U8 count = 0;
10985 tANI_U8 firstChannel;
10986 tANI_U8 maxChannels;
10987
10988 if (CSR_IS_CHANNEL_5GHZ(channel))
10989 {
10990 cfgId = WNI_CFG_MAX_TX_POWER_5;
10991 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10992 }
10993 else if (CSR_IS_CHANNEL_24GHZ(channel))
10994 {
10995 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10996 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10997 }
10998 else
10999 return maxTxPwr;
11000
Kiet Lam64c1b492013-07-12 13:56:44 +053011001 pCountryInfo = vos_mem_malloc(cfgLength);
11002 if ( NULL == pCountryInfo )
11003 status = eHAL_STATUS_FAILURE;
11004 else
11005 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011006 if (status != eHAL_STATUS_SUCCESS)
11007 {
11008 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011009 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011010 __FUNCTION__, status);
11011 goto error;
11012 }
11013 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11014 if (status != eHAL_STATUS_SUCCESS)
11015 {
11016 goto error;
11017 }
11018 /* Identify the channel and maxtxpower */
11019 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11020 {
11021 firstChannel = pCountryInfo[count++];
11022 maxChannels = pCountryInfo[count++];
11023 maxTxPwr = pCountryInfo[count++];
11024
11025 if ((channel >= firstChannel) &&
11026 (channel < (firstChannel + maxChannels)))
11027 {
11028 break;
11029 }
11030 }
11031
11032error:
11033 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011034 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011035
11036 return maxTxPwr;
11037}
11038
11039
Jeff Johnson295189b2012-06-20 16:38:30 -070011040tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11041{
11042 tANI_BOOLEAN fValid = FALSE;
11043 tANI_U32 idxValidChannels;
11044 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11045
11046 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11047 {
11048 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11049 {
11050 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11051 {
11052 fValid = TRUE;
11053 break;
11054 }
11055 }
11056 }
11057 pMac->roam.numValidChannels = len;
11058 return fValid;
11059}
11060
Jeff Johnson295189b2012-06-20 16:38:30 -070011061tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11062{
11063 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11064 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011065 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11066 {
11067 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11068 {
11069 fValid = eANI_BOOLEAN_TRUE;
11070 break;
11071 }
11072 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011073 return (fValid);
11074}
11075
Jeff Johnson295189b2012-06-20 16:38:30 -070011076//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011077 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011078{
Jeff Johnsone7245742012-09-05 17:12:55 -070011079 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011080 tANI_U8 centerChn;
11081 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011082 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11083 {
11084 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11085 }
11086 else
11087 {
11088 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11089 }
11090 //Figure what the other side's CB mode
11091 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11092 {
11093 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11094 {
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011095 // Check set as TKIP or not.
Praveen Kumar Sirisilla548cf372014-01-16 18:28:59 -080011096 if ((NULL != &(pIes->RSN.pwise_cipher_suites[0][0]) &&
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011097 !memcmp( &(pIes->RSN.pwise_cipher_suites[0][0]),
11098 "\x00\x0f\xac\x02" ,4))
Praveen Kumar Sirisilla548cf372014-01-16 18:28:59 -080011099 || (((NULL != &(pIes->WPA)) &&
11100 (pIes->WPA.unicast_cipher_count == 1))
11101 && ((NULL != &(pIes->WPA.unicast_ciphers[0]))
11102 && memcmp(&(pIes->WPA.unicast_ciphers[0]),
11103 "\x00\x0f\xac\x02", 4))))
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011104 {
11105 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11106 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11107 }
11108
11109 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011110 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011111 /* This is called during INFRA STA/CLIENT and should use the merged value of
11112 * supported channel width and recommended tx width as per standard
11113 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011114 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011115 pIes->HTCaps.supportedChannelWidthSet,
11116 pIes->HTInfo.recommendedTxWidthSet,
11117 pIes->HTInfo.secondaryChannelOffset);
11118
11119 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11120 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011121 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011122 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11123 switch (eRet) {
11124 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11125 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11126 break;
11127 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11128 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11129 break;
11130 case PHY_SINGLE_CHANNEL_CENTERED:
11131 default:
11132 centerChn = primaryChn;
11133 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011134 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011135 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011136 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011137 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070011138 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011139 }
11140 }
11141 }
11142 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011143 return eRet;
11144}
Jeff Johnson295189b2012-06-20 16:38:30 -070011145tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11146{
11147 tANI_BOOLEAN fFound = FALSE;
11148 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011149 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11150 {
11151 if( pCipherList->encryptionType[idx] == encryptionType )
11152 {
11153 fFound = TRUE;
11154 break;
11155 }
11156 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011157 return fFound;
11158}
Jeff Johnson295189b2012-06-20 16:38:30 -070011159tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11160{
11161 tANI_BOOLEAN fFound = FALSE;
11162 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011163 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11164 {
11165 if( pAuthList->authType[idx] == authType )
11166 {
11167 fFound = TRUE;
11168 break;
11169 }
11170 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011171 return fFound;
11172}
Jeff Johnson295189b2012-06-20 16:38:30 -070011173tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11174{
11175 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11176 tCsrScanResultFilter *pScanFilter = NULL;
11177 eHalStatus status = eHAL_STATUS_SUCCESS;
11178
11179 if(pProfile1 && pProfile2)
11180 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011181 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11182 if ( NULL == pScanFilter )
11183 status = eHAL_STATUS_FAILURE;
11184 else
11185 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011186 if(HAL_STATUS_SUCCESS(status))
11187 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011188 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011189 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11190 if(HAL_STATUS_SUCCESS(status))
11191 {
11192 fCheck = eANI_BOOLEAN_FALSE;
11193 do
11194 {
11195 tANI_U32 i;
11196 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11197 {
11198 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11199 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11200 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11201 if ( fCheck ) break;
11202 }
11203 if(!fCheck)
11204 {
11205 break;
11206 }
11207 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11208 || pProfile2->BSSType != pProfile1->BSSType
11209 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11210 )
11211 {
11212 fCheck = eANI_BOOLEAN_FALSE;
11213 break;
11214 }
11215#ifdef WLAN_FEATURE_VOWIFI_11R
11216 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11217 {
11218 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11219 {
11220 fCheck = eANI_BOOLEAN_FALSE;
11221 break;
11222 }
11223 }
11224#endif
11225 //Match found
11226 fCheck = eANI_BOOLEAN_TRUE;
11227 }while(0);
11228 csrFreeScanFilter(pMac, pScanFilter);
11229 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011230 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011231 }
11232 }
11233
11234 return (fCheck);
11235}
11236
Jeff Johnson295189b2012-06-20 16:38:30 -070011237tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11238{
11239 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11240 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011241 do
11242 {
11243 //Only check for static WEP
11244 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11245 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11246 {
11247 fCheck = eANI_BOOLEAN_TRUE;
11248 break;
11249 }
11250 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11251 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11252 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11253 {
11254 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011255 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11256 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011257 {
11258 break;
11259 }
11260 }
11261 if( i == CSR_MAX_NUM_KEY)
11262 {
11263 fCheck = eANI_BOOLEAN_TRUE;
11264 }
11265 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011266 return (fCheck);
11267}
11268
Jeff Johnson295189b2012-06-20 16:38:30 -070011269//IBSS
11270
Jeff Johnson295189b2012-06-20 16:38:30 -070011271tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11272{
11273 tANI_U8 channel = 0;
11274 tANI_U32 idx;
11275 tANI_U32 idxValidChannels;
11276 tANI_BOOLEAN fFound = FALSE;
11277 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11278
11279 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11280 {
11281 channel = pMac->roam.configParam.AdHocChannel5G;
11282 if(!csrRoamIsChannelValid(pMac, channel))
11283 {
11284 channel = 0;
11285 }
11286 }
11287 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11288 {
11289 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11290 {
11291 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11292 {
11293 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11294 {
11295 fFound = TRUE;
11296 channel = csrStartIbssChannels50[ idx ];
11297 }
11298 }
11299 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011300 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11301 if (!fFound)
11302 {
11303 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11304 {
11305 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11306 {
11307 channel = csrStartIbssChannels50[ idx ];
11308 break;
11309 }
11310 }
11311 }
11312 }//if
11313
11314 return( channel );
11315}
11316
Jeff Johnson295189b2012-06-20 16:38:30 -070011317tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11318{
11319 tANI_U8 channel = 1;
11320 tANI_U32 idx;
11321 tANI_U32 idxValidChannels;
11322 tANI_BOOLEAN fFound = FALSE;
11323 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11324
11325 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11326 {
11327 channel = pMac->roam.configParam.AdHocChannel24;
11328 if(!csrRoamIsChannelValid(pMac, channel))
11329 {
11330 channel = 0;
11331 }
11332 }
11333
11334 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11335 {
11336 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11337 {
11338 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11339 {
11340 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11341 {
11342 fFound = TRUE;
11343 channel = csrStartIbssChannels24[ idx ];
11344 }
11345 }
11346 }
11347 }
11348
11349 return( channel );
11350}
11351
Jeff Johnson295189b2012-06-20 16:38:30 -070011352static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11353 tCsrRoamStartBssParams *pParam )
11354{
11355 eCsrCfgDot11Mode cfgDot11Mode;
11356 eCsrBand eBand;
11357 tANI_U8 channel = 0;
11358 tSirNwType nwType;
11359 tANI_U8 operationChannel = 0;
11360
11361 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11362 {
11363 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11364 }
11365
Jeff Johnson295189b2012-06-20 16:38:30 -070011366 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011367
Jeff Johnson295189b2012-06-20 16:38:30 -070011368 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11369 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11370 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11371 )
11372 {
11373 /* This should never happen */
11374 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011375 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011376 pProfile->csrPersona);
11377 VOS_ASSERT(0);
11378 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011379 switch( cfgDot11Mode )
11380 {
11381 case eCSR_CFG_DOT11_MODE_11G:
11382 nwType = eSIR_11G_NW_TYPE;
11383 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011384 case eCSR_CFG_DOT11_MODE_11B:
11385 nwType = eSIR_11B_NW_TYPE;
11386 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011387 case eCSR_CFG_DOT11_MODE_11A:
11388 nwType = eSIR_11A_NW_TYPE;
11389 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011390 default:
11391 case eCSR_CFG_DOT11_MODE_11N:
11392 case eCSR_CFG_DOT11_MODE_TAURUS:
11393 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11394 if(eCSR_BAND_24 == eBand)
11395 {
11396 nwType = eSIR_11G_NW_TYPE;
11397 }
11398 else
11399 {
11400 nwType = eSIR_11A_NW_TYPE;
11401 }
11402 break;
11403 }
11404
11405 pParam->extendedRateSet.numRates = 0;
11406
11407 switch ( nwType )
11408 {
11409 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011410 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011411 case eSIR_11A_NW_TYPE:
11412
11413 pParam->operationalRateSet.numRates = 8;
11414
11415 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11416 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11417 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11418 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11419 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11420 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11421 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11422 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11423
11424 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11425 {
11426 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11427 if( 0 == channel &&
11428 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11429 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11430 )
11431 {
11432 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11433 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11434 nwType = eSIR_11B_NW_TYPE;
11435 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11436 pParam->operationalRateSet.numRates = 4;
11437 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11438 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11439 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11440 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11441 }
11442 }
11443 else
11444 {
11445 channel = operationChannel;
11446 }
11447 break;
11448
11449 case eSIR_11B_NW_TYPE:
11450 pParam->operationalRateSet.numRates = 4;
11451 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11452 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11453 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11454 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011455 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11456 {
11457 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11458 }
11459 else
11460 {
11461 channel = operationChannel;
11462 }
11463
11464 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011465 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011466 /* For P2P Client and P2P GO, disable 11b rates */
11467 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11468 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11469 )
11470 {
11471 pParam->operationalRateSet.numRates = 8;
11472
11473 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11474 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11475 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11476 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11477 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11478 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11479 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11480 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11481 }
11482 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011483 {
11484 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011485 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11486 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11487 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11488 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11489
11490 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011491 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11492 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11493 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11494 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11495 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11496 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11497 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11498 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11499 }
11500
11501 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11502 {
11503 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11504 }
11505 else
11506 {
11507 channel = operationChannel;
11508 }
11509
11510 break;
11511 }
11512 pParam->operationChn = channel;
11513 pParam->sirNwType = nwType;
11514}
11515
Jeff Johnson295189b2012-06-20 16:38:30 -070011516static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11517 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11518{
11519
11520 if( pParam )
11521 {
11522 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011523 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011524 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011525 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011526
11527 if( pIes )
11528 {
11529 if(pIes->SuppRates.present)
11530 {
11531 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11532 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11533 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011534 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 -070011535 pIes->SuppRates.num_rates);
11536 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11537 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011538 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11539 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011540 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011541 if (pIes->ExtSuppRates.present)
11542 {
11543 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
11544 if(pIes->ExtSuppRates.num_rates > SIR_MAC_EXTENDED_RATE_EID_MAX)
11545 {
11546 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11547 SIR_MAC_RATESET_EID_MAX, resetting to \
11548 SIR_MAC_RATESET_EID_MAX"),
11549 pIes->ExtSuppRates.num_rates);
11550 pIes->ExtSuppRates.num_rates = SIR_MAC_EXTENDED_RATE_EID_MAX;
11551 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011552 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011553 pIes->ExtSuppRates.rates,
11554 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11555 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011556 if( pIes->SSID.present )
11557 {
11558 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011559 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11560 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011561 }
11562 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011563 }
11564 else
11565 {
11566 pParam->ssId.length = 0;
11567 pParam->operationalRateSet.numRates = 0;
11568 }
11569 }
11570}
11571
Jeff Johnson295189b2012-06-20 16:38:30 -070011572static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11573{
11574 tANI_U8 MaxRate = 0;
11575 tANI_U32 i;
11576 tANI_U8 *pRate;
11577
11578 pRate = pSirRateSet->rate;
11579 for ( i = 0; i < pSirRateSet->numRates; i++ )
11580 {
11581 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11582 }
11583
11584 // Save the max rate in the connected state information...
11585
11586 // modify LastRates variable as well
11587
11588 return;
11589}
11590
Jeff Johnson295189b2012-06-20 16:38:30 -070011591eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11592 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11593{
11594 eHalStatus status = eHAL_STATUS_SUCCESS;
11595 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011596 // Set the roaming substate to 'Start BSS attempt'...
11597 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011598#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11599 //Need to figure out whether we need to log WDS???
11600 if( CSR_IS_IBSS( pProfile ) )
11601 {
11602 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011603 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11604 if(pIbssLog)
11605 {
11606 if(pBssDesc)
11607 {
11608 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011609 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011610 }
11611 else
11612 {
11613 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11614 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011615 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011616 if(pProfile->ChannelInfo.numOfChannels == 0)
11617 {
11618 pIbssLog->channelSetting = AUTO_PICK;
11619 }
11620 else
11621 {
11622 pIbssLog->channelSetting = SPECIFIED;
11623 }
11624 pIbssLog->operatingChannel = pParam->operationChn;
11625 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11626 }
11627 }
11628#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11629 //Put RSN information in for Starting BSS
11630 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11631 pParam->pRSNIE = pProfile->pRSNReqIE;
11632
Jeff Johnson295189b2012-06-20 16:38:30 -070011633 pParam->privacy = pProfile->privacy;
11634 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11635 pParam->authType = pProfile->csr80211AuthType;
11636 pParam->beaconInterval = pProfile->beaconInterval;
11637 pParam->dtimPeriod = pProfile->dtimPeriod;
11638 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11639 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11640 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11641 {
11642 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11643 {
11644 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11645 }
11646 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011647 pParam->protEnabled = pProfile->protEnabled;
11648 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11649 pParam->ht_protection = pProfile->cfg_protection;
11650 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011651
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11653 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011654 pParam->bssPersona = pProfile->csrPersona;
11655 // When starting an IBSS, start on the channel from the Profile.
11656 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011657 return (status);
11658}
11659
Jeff Johnson295189b2012-06-20 16:38:30 -070011660static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011661 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011662{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011663 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011664 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011665 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011666
11667 if(!pSession)
11668 {
11669 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11670 return;
11671 }
11672
Jeff Johnson295189b2012-06-20 16:38:30 -070011673 if( pBssDesc )
11674 {
11675 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11676 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11677 //The following code has to be do after that.
11678 //For WDS station, use selfMac as the self BSSID
11679 if( CSR_IS_WDS_STA( pProfile ) )
11680 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011681 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11682 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011683 }
11684 }
11685 else
11686 {
11687 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011688 //Use the first SSID
11689 if(pProfile->SSIDs.numOfSSIDs)
11690 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011691 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11692 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011693 }
11694 //For WDS station, use selfMac as the self BSSID
11695 if( CSR_IS_WDS_STA( pProfile ) )
11696 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011697 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11698 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011699 }
11700 //Use the first BSSID
11701 else if( pProfile->BSSIDs.numOfBSSIDs )
11702 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011703 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11704 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011705 }
11706 else
11707 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011708 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011709 }
11710 }
11711 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011712 //Set operating channel in pProfile which will be used
11713 //in csrRoamSetBssConfigCfg() to determine channel bonding
11714 //mode and will be configured in CFG later
11715 pProfile->operationChannel = Channel;
11716
11717 if(Channel == 0)
11718 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053011719 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011720 }
11721 else
11722 {
11723
11724 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011725 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011726 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011727 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011728 {
11729 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11730 }
11731 else
11732 {
11733 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11734 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011735 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011736 pBssConfig->cbMode = cbMode;
11737 pSession->bssParams.cbMode = cbMode;
11738 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011739 }
11740}
11741
Jeff Johnson295189b2012-06-20 16:38:30 -070011742static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11743 tANI_BOOLEAN *pfSameIbss )
11744{
11745 eHalStatus status = eHAL_STATUS_SUCCESS;
11746 tANI_BOOLEAN fSameIbss = FALSE;
11747
11748 if ( csrIsConnStateIbss( pMac, sessionId ) )
11749 {
11750 // Check if any profile parameter has changed ? If any profile parameter
11751 // has changed then stop old BSS and start a new one with new parameters
11752 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11753 {
11754 fSameIbss = TRUE;
11755 }
11756 else
11757 {
11758 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11759 }
11760 }
11761 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11762 {
11763 // Disassociate from the connected Infrastructure network...
11764 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11765 }
11766 else
11767 {
11768 tBssConfigParam *pBssConfig;
11769
Kiet Lam64c1b492013-07-12 13:56:44 +053011770 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11771 if ( NULL == pBssConfig )
11772 status = eHAL_STATUS_FAILURE;
11773 else
11774 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011775 if(HAL_STATUS_SUCCESS(status))
11776 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011777 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011778 // there is no Bss description before we start an IBSS so we need to adopt
11779 // all Bss configuration parameters from the Profile.
11780 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11781 if(HAL_STATUS_SUCCESS(status))
11782 {
11783 //save dotMode
11784 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11785 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011786 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011787 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11788 NULL, pBssConfig,
11789 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011790 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011791
11792 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011793 }//Allocate memory
11794 }
11795
11796 if(pfSameIbss)
11797 {
11798 *pfSameIbss = fSameIbss;
11799 }
11800 return( status );
11801}
11802
Jeff Johnson295189b2012-06-20 16:38:30 -070011803static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11804 tSirSmeNewBssInfo *pNewBss )
11805{
11806 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011807
11808 if(!pSession)
11809 {
11810 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11811 return;
11812 }
11813
Jeff Johnson295189b2012-06-20 16:38:30 -070011814 if( pNewBss )
11815 {
11816 // Set the operating channel.
11817 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11818 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011819 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11820 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011821 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011822 return;
11823}
11824
Jeff Johnson295189b2012-06-20 16:38:30 -070011825#ifdef FEATURE_WLAN_WAPI
11826eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11827 tANI_U32 numItems )
11828{
11829 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11830 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011831 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11832 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011833 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011834 return status;
11835 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011836 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011837 pSession = CSR_GET_SESSION( pMac, sessionId );
11838 if(numItems <= CSR_MAX_BKID_ALLOWED)
11839 {
11840 status = eHAL_STATUS_SUCCESS;
11841 //numItems may be 0 to clear the cache
11842 pSession->NumBkidCache = (tANI_U16)numItems;
11843 if(numItems && pBKIDCache)
11844 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011845 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
11846 sizeof(tBkidCacheInfo) * numItems);
11847 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011848 }
11849 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011850 return (status);
11851}
Jeff Johnson295189b2012-06-20 16:38:30 -070011852eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11853 tBkidCacheInfo *pBkidCache)
11854{
11855 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11856 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011857 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11858 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011859 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011860 return status;
11861 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011862 pSession = CSR_GET_SESSION( pMac, sessionId );
11863 if(pNum && pBkidCache)
11864 {
11865 if(pSession->NumBkidCache == 0)
11866 {
11867 *pNum = 0;
11868 status = eHAL_STATUS_SUCCESS;
11869 }
11870 else if(*pNum >= pSession->NumBkidCache)
11871 {
11872 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11873 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011874 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 -070011875 pSession->NumBkidCache);
11876 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11877 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011878 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
11879 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011880 *pNum = pSession->NumBkidCache;
11881 status = eHAL_STATUS_SUCCESS;
11882 }
11883 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011884 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011885}
Jeff Johnson295189b2012-06-20 16:38:30 -070011886tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11887{
11888 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011889}
11890#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011891eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11892 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11893{
11894 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11895 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011896
11897 if(!pSession)
11898 {
11899 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11900 return eHAL_STATUS_FAILURE;
11901 }
11902
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011903 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011904 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11905 {
11906#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11907 {
11908 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053011909 vos_mem_set(&secEvent,
11910 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011911 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11912 secEvent.encryptionModeMulticast =
11913 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11914 secEvent.encryptionModeUnicast =
11915 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053011916 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011917 secEvent.authMode =
11918 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11919 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11920 }
11921#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011922 status = eHAL_STATUS_SUCCESS;
11923 //numItems may be 0 to clear the cache
11924 pSession->NumPmkidCache = (tANI_U16)numItems;
11925 if(numItems && pPMKIDCache)
11926 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011927 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
11928 sizeof(tPmkidCacheInfo) * numItems);
11929 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011930 }
11931 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011932 return (status);
11933}
11934
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011935eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11936 tANI_U8 *pBSSId )
11937{
11938 eHalStatus status = eHAL_STATUS_FAILURE;
11939 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11940 tANI_BOOLEAN fMatchFound = FALSE;
11941 tANI_U32 Index;
11942 if(!pSession)
11943 {
11944 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11945 return eHAL_STATUS_FAILURE;
11946 }
11947 do
11948 {
11949 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
11950 {
Arif Hussaina7c8e412013-11-20 11:06:42 -080011951 smsLog(pMac, LOGW, "Delete PMKID for "
11952 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Kiet Lamf2f201e2013-11-16 21:24:16 +053011953 if( vos_mem_compare( pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011954 {
11955 fMatchFound = TRUE;
11956 break;
11957 }
11958 }
11959 if( !fMatchFound ) break;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053011960 vos_mem_set(pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid), 0);
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011961 status = eHAL_STATUS_SUCCESS;
11962 }
11963 while( 0 );
11964 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
11965 fMatchFound, status);
11966 return status;
11967}
Jeff Johnson295189b2012-06-20 16:38:30 -070011968tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11969{
11970 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11971}
11972
Jeff Johnson295189b2012-06-20 16:38:30 -070011973eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
11974{
11975 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11976 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011977
11978 if(!pSession)
11979 {
11980 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11981 return eHAL_STATUS_FAILURE;
11982 }
11983
Jeff Johnson295189b2012-06-20 16:38:30 -070011984 if(pNum && pPmkidCache)
11985 {
11986 if(pSession->NumPmkidCache == 0)
11987 {
11988 *pNum = 0;
11989 status = eHAL_STATUS_SUCCESS;
11990 }
11991 else if(*pNum >= pSession->NumPmkidCache)
11992 {
11993 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11994 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011995 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 -070011996 pSession->NumPmkidCache);
11997 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11998 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011999 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
12000 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012001 *pNum = pSession->NumPmkidCache;
12002 status = eHAL_STATUS_SUCCESS;
12003 }
12004 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012005 return (status);
12006}
12007
Jeff Johnson295189b2012-06-20 16:38:30 -070012008eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12009{
12010 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12011 tANI_U32 len;
12012 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012013
12014 if(!pSession)
12015 {
12016 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12017 return eHAL_STATUS_FAILURE;
12018 }
12019
Jeff Johnson295189b2012-06-20 16:38:30 -070012020 if(pLen)
12021 {
12022 len = *pLen;
12023 *pLen = pSession->nWpaRsnReqIeLength;
12024 if(pBuf)
12025 {
12026 if(len >= pSession->nWpaRsnReqIeLength)
12027 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012028 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12029 pSession->nWpaRsnReqIeLength);
12030 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012031 }
12032 }
12033 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012034 return (status);
12035}
12036
Jeff Johnson295189b2012-06-20 16:38:30 -070012037eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12038{
12039 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12040 tANI_U32 len;
12041 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012042
12043 if(!pSession)
12044 {
12045 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12046 return eHAL_STATUS_FAILURE;
12047 }
12048
Jeff Johnson295189b2012-06-20 16:38:30 -070012049 if(pLen)
12050 {
12051 len = *pLen;
12052 *pLen = pSession->nWpaRsnRspIeLength;
12053 if(pBuf)
12054 {
12055 if(len >= pSession->nWpaRsnRspIeLength)
12056 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012057 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12058 pSession->nWpaRsnRspIeLength);
12059 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012060 }
12061 }
12062 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012063 return (status);
12064}
Jeff Johnson295189b2012-06-20 16:38:30 -070012065#ifdef FEATURE_WLAN_WAPI
12066eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12067{
12068 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12069 tANI_U32 len;
12070 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012071
12072 if(!pSession)
12073 {
12074 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12075 return eHAL_STATUS_FAILURE;
12076 }
12077
Jeff Johnson295189b2012-06-20 16:38:30 -070012078 if(pLen)
12079 {
12080 len = *pLen;
12081 *pLen = pSession->nWapiReqIeLength;
12082 if(pBuf)
12083 {
12084 if(len >= pSession->nWapiReqIeLength)
12085 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012086 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12087 pSession->nWapiReqIeLength);
12088 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012089 }
12090 }
12091 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012092 return (status);
12093}
Jeff Johnson295189b2012-06-20 16:38:30 -070012094eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12095{
12096 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12097 tANI_U32 len;
12098 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012099
12100 if(!pSession)
12101 {
12102 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12103 return eHAL_STATUS_FAILURE;
12104 }
12105
Jeff Johnson295189b2012-06-20 16:38:30 -070012106 if(pLen)
12107 {
12108 len = *pLen;
12109 *pLen = pSession->nWapiRspIeLength;
12110 if(pBuf)
12111 {
12112 if(len >= pSession->nWapiRspIeLength)
12113 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012114 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12115 pSession->nWapiRspIeLength);
12116 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012117 }
12118 }
12119 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012120 return (status);
12121}
12122#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012123eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12124{
12125 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12126 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012127
12128 if(!pSession)
12129 {
12130 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12131 return (retStatus);
12132 }
12133
Jeff Johnson295189b2012-06-20 16:38:30 -070012134 if(CSR_IS_ROAMING(pSession))
12135 {
12136 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12137 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12138 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012139 return (retStatus);
12140}
12141
Jeff Johnson295189b2012-06-20 16:38:30 -070012142//This function remove the connected BSS from te cached scan result
12143eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12144 tCsrRoamConnectedProfile *pConnProfile)
12145{
12146 eHalStatus status = eHAL_STATUS_FAILURE;
12147 tCsrScanResultFilter *pScanFilter = NULL;
12148 tListElem *pEntry;
12149 tCsrScanResult *pResult;
12150 tDot11fBeaconIEs *pIes;
12151 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012152 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12153 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12154 {
12155 do
12156 {
12157 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012158 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12159 if ( NULL == pScanFilter )
12160 status = eHAL_STATUS_FAILURE;
12161 else
12162 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012163 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012164 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12165 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12166 if ( NULL == pScanFilter->BSSIDs.bssid )
12167 status = eHAL_STATUS_FAILURE;
12168 else
12169 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012170 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012171 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12172 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012173 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12174 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12175 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012176 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12177 if ( NULL == pScanFilter->SSIDs.SSIDList )
12178 status = eHAL_STATUS_FAILURE;
12179 else
12180 status = eHAL_STATUS_SUCCESS;
12181 if (!HAL_STATUS_SUCCESS(status)) break;
12182 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12183 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012184 }
12185 pScanFilter->authType.numEntries = 1;
12186 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12187 pScanFilter->BSSType = pConnProfile->BSSType;
12188 pScanFilter->EncryptionType.numEntries = 1;
12189 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12190 pScanFilter->mcEncryptionType.numEntries = 1;
12191 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12192 //We ignore the channel for now, BSSID should be enough
12193 pScanFilter->ChannelInfo.numOfChannels = 0;
12194 //Also ignore the following fields
12195 pScanFilter->uapsd_mask = 0;
12196 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
12197 pScanFilter->countryCode[0] = 0;
12198 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012199 csrLLLock(&pMac->scan.scanResultList);
12200 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12201 while( pEntry )
12202 {
12203 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12204 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12205 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12206 pScanFilter, NULL, NULL, NULL, &pIes);
12207 //Release the IEs allocated by csrMatchBSS is needed
12208 if( !pResult->Result.pvIes )
12209 {
12210 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012211 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012212 }
12213 if(fMatch)
12214 {
12215 //We found the one
12216 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12217 {
12218 //Free the memory
12219 csrFreeScanResultEntry( pMac, pResult );
12220 }
12221 break;
12222 }
12223 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12224 }//while
12225 csrLLUnlock(&pMac->scan.scanResultList);
12226 }while(0);
12227 if(pScanFilter)
12228 {
12229 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012230 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012231 }
12232 }
12233 return (status);
12234}
12235
Jeff Johnson295189b2012-06-20 16:38:30 -070012236//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012237eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12238{
12239 eHalStatus status = eHAL_STATUS_SUCCESS;
12240 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012241 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12242 {
12243 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12244 {
12245 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12246 {
12247 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012248 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012249 status = eHAL_STATUS_CSR_WRONG_STATE;
12250 break;
12251 }
12252 if( csrIsConnStateInfra( pMac, sessionId ) )
12253 {
12254 if( chnId &&
12255 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12256 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012257 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012258 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12259 status = eHAL_STATUS_CSR_WRONG_STATE;
12260 break;
12261 }
12262 }
12263 }
12264 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012265 return ( status );
12266}
12267
Jeff Johnson295189b2012-06-20 16:38:30 -070012268static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12269{
12270 eHalStatus status = eHAL_STATUS_SUCCESS;
12271 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12272 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012273
12274 if(!pSession)
12275 {
12276 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12277 return eHAL_STATUS_FAILURE;
12278 }
12279
Jeff Johnson295189b2012-06-20 16:38:30 -070012280 if ( csrIsConnStateIbss( pMac, sessionId ) )
12281 {
12282 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12283 }
12284 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12285 {
12286 // Disassociate from the connected Infrastructure network...
12287 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12288 }
12289 else
12290 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012291 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12292 //Otherwise we need to add code to handle the
12293 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12294 //send stop_bss to PE, before we can continue.
12295 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012296 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012297 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012298 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12299 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012300 // there is no Bss description before we start an WDS so we need
12301 // to adopt all Bss configuration parameters from the Profile.
12302 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12303 if(HAL_STATUS_SUCCESS(status))
12304 {
12305 //Save profile for late use
12306 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012307 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12308 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012309 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012310 vos_mem_set(pSession->pCurRoamProfile,
12311 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012312 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12313 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012314 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012315 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012316 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12317 NULL, &bssConfig,
12318 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012319 }
12320 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012321
Jeff Johnson295189b2012-06-20 16:38:30 -070012322 return( status );
12323}
12324
Jeff Johnson295189b2012-06-20 16:38:30 -070012325////////////////////Mail box
12326
Jeff Johnson295189b2012-06-20 16:38:30 -070012327//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12328//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012329static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12330 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012331 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12332{
12333 tCsrChannelSet channelGroup;
12334 tSirMacCapabilityInfo *pAP_capabilityInfo;
12335 tAniBool fTmp;
12336 tANI_BOOLEAN found = FALSE;
12337 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012338 tANI_S8 pwrLimit = 0;
12339 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012340 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12341 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12342 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12343 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012344 // 802.11h
12345 //We can do this because it is in HOST CPU order for now.
12346 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012347 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12348 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12349 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012350 fTmp = (tAniBool)pal_cpu_to_be32(1);
12351 }
12352 else
12353 fTmp = (tAniBool)0;
12354
12355 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012356 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012357 pBuf += sizeof(tAniBool);
12358 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012359 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012360 // This is required for 11k test VoWiFi Ent: Test 2.
12361 // We need the power capabilities for Assoc Req.
12362 // This macro is provided by the halPhyCfg.h. We pick our
12363 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012364 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12365 if (0 != pwrLimit)
12366 {
12367 *pBuf++ = pwrLimit;
12368 }
12369 else
12370 {
12371 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12372 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012373 size = sizeof(pMac->roam.validChannelList);
12374 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12375 {
12376 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12377 for ( i = 0; i < size; i++)
12378 {
12379 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12380
12381 }
12382 }
12383 else
12384 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012385 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012386 *pBuf++ = 0; //tSirSupChnl->numChnl
12387 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012388 //Check whether it is ok to enter UAPSD
12389#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12390 if( btcIsReadyForUapsd(pMac) )
12391#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12392 {
12393 *pBuf++ = uapsdMask;
12394 }
12395#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12396 else
12397 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012398 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012399 *pBuf++ = 0;
12400 }
12401#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12402
Jeff Johnson295189b2012-06-20 16:38:30 -070012403 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012404 vos_mem_copy(pBuf, pBssDescription,
12405 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012406 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12407}
12408
Jeff Johnson295189b2012-06-20 16:38:30 -070012409/*
12410 * The communication between HDD and LIM is thru mailbox (MB).
12411 * Both sides will access the data structure "tSirSmeJoinReq".
12412 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12413 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12414 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12415 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12416 */
12417eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012418 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012419{
12420 eHalStatus status = eHAL_STATUS_SUCCESS;
12421 tSirSmeJoinReq *pMsg;
12422 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012423 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012424 tANI_U16 msgLen, wTmp, ieLen;
12425 tSirMacRateSet OpRateSet;
12426 tSirMacRateSet ExRateSet;
12427 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12428 tANI_U32 dwTmp;
12429 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012430 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012431
12432 if(!pSession)
12433 {
12434 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12435 return eHAL_STATUS_FAILURE;
12436 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012437 /* To satisfy klockworks */
12438 if (NULL == pBssDescription)
12439 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012440 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012441 return eHAL_STATUS_FAILURE;
12442 }
12443
Jeff Johnson295189b2012-06-20 16:38:30 -070012444 do {
12445 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12446 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012447 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012448 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12449 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12450 // IE fields, but the length field in the bssDescription needs to be interpreted to
12451 // determine length of the IE fields.
12452 //
12453 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12454 // add in the length from the bssDescription (then add the size of the 'length' field
12455 // itself because that is NOT included in the length field).
12456 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12457 pBssDescription->length + sizeof( pBssDescription->length ) +
12458 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 +053012459 pMsg = vos_mem_malloc(msgLen);
12460 if (NULL == pMsg)
12461 status = eHAL_STATUS_FAILURE;
12462 else
12463 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012464 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012465 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012466 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012467 pMsg->length = pal_cpu_to_be16(msgLen);
12468 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012469 // sessionId
12470 *pBuf = (tANI_U8)sessionId;
12471 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012472 // transactionId
12473 *pBuf = 0;
12474 *( pBuf + 1 ) = 0;
12475 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012476 // ssId
12477 if( pIes->SSID.present && pIes->SSID.num_ssid )
12478 {
12479 // ssId len
12480 *pBuf = pIes->SSID.num_ssid;
12481 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012482 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012483 pBuf += pIes->SSID.num_ssid;
12484 }
12485 else
12486 {
12487 *pBuf = 0;
12488 pBuf++;
12489 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012490 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012491 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12492 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012493 pBuf += sizeof(tSirMacAddr);
12494 // bsstype
12495 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12496 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012497 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012498 pBuf += sizeof(tSirBssType);
12499 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012500 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12501 if (pBssDescription->channelId <= 14 &&
12502 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12503 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12504 {
12505 //Need to disable VHT operation in 2.4 GHz band
12506 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12507 }
12508 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012509 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012510 //Persona
12511 *pBuf = (tANI_U8)pProfile->csrPersona;
12512 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012513 //CBMode
12514 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12515 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012516
12517 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012518 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12519
Jeff Johnson295189b2012-06-20 16:38:30 -070012520 // uapsdPerAcBitmask
12521 *pBuf = pProfile->uapsd_mask;
12522 pBuf++;
12523
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012524
12525
Jeff Johnson295189b2012-06-20 16:38:30 -070012526 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012527 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012528 {
12529 // OperationalRateSet
12530 if (OpRateSet.numRates) {
12531 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012532 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012533 pBuf += OpRateSet.numRates;
12534 } else *pBuf++ = 0;
12535 // ExtendedRateSet
12536 if (ExRateSet.numRates) {
12537 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012538 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012539 pBuf += ExRateSet.numRates;
12540 } else *pBuf++ = 0;
12541 }
12542 else
12543 {
12544 *pBuf++ = 0;
12545 *pBuf++ = 0;
12546 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012547 // rsnIE
12548 if ( csrIsProfileWpa( pProfile ) )
12549 {
12550 // Insert the Wpa IE into the join request
12551 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12552 (tCsrWpaIe *)( wpaRsnIE ) );
12553 }
12554 else if( csrIsProfileRSN( pProfile ) )
12555 {
12556 // Insert the RSN IE into the join request
12557 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12558 (tCsrRSNIe *)( wpaRsnIE ) );
12559 }
12560#ifdef FEATURE_WLAN_WAPI
12561 else if( csrIsProfileWapi( pProfile ) )
12562 {
12563 // Insert the WAPI IE into the join request
12564 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12565 (tCsrWapiIe *)( wpaRsnIE ) );
12566 }
12567#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012568 else
12569 {
12570 ieLen = 0;
12571 }
12572 //remember the IE for future use
12573 if( ieLen )
12574 {
12575 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012577 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 -070012578 ieLen = DOT11F_IE_RSN_MAX_LEN;
12579 }
12580#ifdef FEATURE_WLAN_WAPI
12581 if( csrIsProfileWapi( pProfile ) )
12582 {
12583 //Check whether we need to allocate more memory
12584 if(ieLen > pSession->nWapiReqIeLength)
12585 {
12586 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12587 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012588 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012589 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012590 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12591 if (NULL == pSession->pWapiReqIE)
12592 status = eHAL_STATUS_FAILURE;
12593 else
12594 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012595 if(!HAL_STATUS_SUCCESS(status)) break;
12596 }
12597 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012598 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012599 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012600 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012601 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012602 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012603 pBuf += ieLen;
12604 }
12605 else//should be WPA/WPA2 otherwise
12606#endif /* FEATURE_WLAN_WAPI */
12607 {
12608 //Check whether we need to allocate more memory
12609 if(ieLen > pSession->nWpaRsnReqIeLength)
12610 {
12611 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12612 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012613 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012614 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012615 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12616 if (NULL == pSession->pWpaRsnReqIE)
12617 status = eHAL_STATUS_FAILURE;
12618 else
12619 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012620 if(!HAL_STATUS_SUCCESS(status)) break;
12621 }
12622 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012623 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012624 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012625 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012626 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012627 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012628 pBuf += ieLen;
12629 }
12630 }
12631 else
12632 {
12633 //free whatever old info
12634 pSession->nWpaRsnReqIeLength = 0;
12635 if(pSession->pWpaRsnReqIE)
12636 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012637 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012638 pSession->pWpaRsnReqIE = NULL;
12639 }
12640#ifdef FEATURE_WLAN_WAPI
12641 pSession->nWapiReqIeLength = 0;
12642 if(pSession->pWapiReqIE)
12643 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012644 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012645 pSession->pWapiReqIE = NULL;
12646 }
12647#endif /* FEATURE_WLAN_WAPI */
12648 //length is two bytes
12649 *pBuf = 0;
12650 *(pBuf + 1) = 0;
12651 pBuf += 2;
12652 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012653#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012654 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012655 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012656 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012657 //length is two bytes
12658 *pBuf = 0;
12659 *(pBuf + 1) = 0;
12660 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012661 }
12662 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012663 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012664 // cckmIE
12665 if( csrIsProfileCCX( pProfile ) )
12666 {
12667 // Insert the CCKM IE into the join request
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012668#ifdef FEATURE_WLAN_CCX_UPLOAD
12669 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080012670 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012671 pSession->suppCckmIeInfo.cckmIe, ieLen);
12672#else
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012673 ieLen = csrConstructCcxCckmIe( pMac,
12674 pSession,
12675 pProfile,
12676 pBssDescription,
12677 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012678 pSession->nWpaRsnReqIeLength,
12679 (void *)( wpaRsnIE ) );
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012680#endif /* FEATURE_WLAN_CCX_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012681 }
12682 else
12683 {
12684 ieLen = 0;
12685 }
12686 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12687 if( ieLen )
12688 {
12689 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12690 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012691 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012692 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012693 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012694 pBuf += ieLen;
12695 }
12696 else
12697 {
12698 //Indicate you have no CCKM IE
12699 //length is two bytes
12700 *pBuf = 0;
12701 *(pBuf + 1) = 0;
12702 pBuf += 2;
12703 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012704 }
12705#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012706 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053012707 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070012708 {
12709 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012710 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012711 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012712 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012713 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012714 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012715 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053012716 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012717 pBuf += ieLen;
12718 }
12719 else
12720 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053012721 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012722 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012723 *pBuf = 0;
12724 *(pBuf + 1) = 0;
12725 pBuf += 2;
12726 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012727 // addIEAssoc
12728 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12729 {
12730 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012731 if(ieLen > pSession->nAddIEAssocLength)
12732 {
12733 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012734 {
12735 vos_mem_free(pSession->pAddIEAssoc);
12736 }
12737 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12738 if (NULL == pSession->pAddIEAssoc)
12739 status = eHAL_STATUS_FAILURE;
12740 else
12741 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012742 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012743 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012744 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012745 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012746 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012747 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012748 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012749 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012750 pBuf += ieLen;
12751 }
12752 else
12753 {
12754 pSession->nAddIEAssocLength = 0;
12755 if(pSession->pAddIEAssoc)
12756 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012757 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012758 pSession->pAddIEAssoc = NULL;
12759 }
12760 *pBuf = 0;
12761 *(pBuf + 1) = 0;
12762 pBuf += 2;
12763 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012764
12765 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012766 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012767 //Unmask any AC in reassoc that is ACM-set
12768 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12769 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012771 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12772 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012773#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012774 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012775#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012776 uapsd_mask &= ~(acm_mask);
12777 }
12778 else
12779 {
12780 uapsd_mask = 0;
12781 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012782 }
12783 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012784
Jeff Johnson295189b2012-06-20 16:38:30 -070012785 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012786 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012787 pBuf += sizeof(tANI_U32);
12788
Jeff Johnson295189b2012-06-20 16:38:30 -070012789 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012790 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012791 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012792#ifdef WLAN_FEATURE_11W
12793 //MgmtEncryption
12794 if (pProfile->MFPEnabled)
12795 {
12796 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12797 }
12798 else
12799 {
12800 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12801 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012802 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012803 pBuf += sizeof(tANI_U32);
12804#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012805#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012806 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012807 if (csrIsProfile11r( pProfile )
12808#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012809 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12810 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012811#endif
12812 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012813 {
12814 // is11Rconnection;
12815 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012816 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012817 pBuf += sizeof(tAniBool);
12818 }
12819 else
12820 {
12821 // is11Rconnection;
12822 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012823 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012824 pBuf += sizeof(tAniBool);
12825 }
12826#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012827#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012828
12829 // isCCXFeatureIniEnabled
12830 if (TRUE == pMac->roam.configParam.isCcxIniFeatureEnabled)
12831 {
12832 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012833 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012834 pBuf += sizeof(tAniBool);
12835 }
12836 else
12837 {
12838 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080012839 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012840 pBuf += sizeof(tAniBool);
12841 }
12842
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012843 /* A profile can not be both CCX and 11R. But an 802.11R AP
12844 * may be advertising support for CCX as well. So if we are
12845 * associating Open or explicitly CCX then we will get CCX.
12846 * If we are associating explictly 11R only then we will get
12847 * 11R.
12848 */
12849 if ((csrIsProfileCCX(pProfile) ||
12850 ((pIes->CCXVersion.present)
12851 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012852 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12853 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12854 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012855#ifdef WLAN_FEATURE_11W
12856 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12857#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012858 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012859 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12860 {
12861 // isCCXconnection;
12862 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012863 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012864 pBuf += sizeof(tAniBool);
12865 }
12866 else
12867 {
12868 //isCCXconnection;
12869 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012870 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012871 pBuf += sizeof(tAniBool);
12872 }
12873
12874 if (eWNI_SME_JOIN_REQ == messageType)
12875 {
12876 tCCXTspecInfo ccxTspec;
12877 // CCX-Tspec IEs in the ASSOC request is presently not supported
12878 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012879 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12880 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012881 pBuf += sizeof(tCCXTspecInfo);
12882 }
12883 else if (eWNI_SME_REASSOC_REQ == messageType)
12884 {
12885 if ((csrIsProfileCCX(pProfile) ||
12886 ((pIes->CCXVersion.present)
12887 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012888 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12889 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12890 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012891#ifdef WLAN_FEATURE_11W
12892 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12893#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012894 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012895 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012896 {
12897 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012898 // CCX Tspec information
Kiet Lam64c1b492013-07-12 13:56:44 +053012899 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012900 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12901 *pBuf = ccxTspec.numTspecs;
12902 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012903 // Copy the TSPEC information only if present
12904 if (ccxTspec.numTspecs) {
Kiet Lam64c1b492013-07-12 13:56:44 +053012905 vos_mem_copy(pBuf, (void*)&ccxTspec.tspec[0],
12906 (ccxTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070012907 }
12908 pBuf += sizeof(ccxTspec.tspec);
12909 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012910 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012911 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012912 tCCXTspecInfo ccxTspec;
12913 // CCX-Tspec IEs in the ASSOC request is presently not supported
12914 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012915 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12916 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070012917 pBuf += sizeof(tCCXTspecInfo);
12918 }
12919 }
12920#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012921#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012922 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012923 if (pMac->roam.configParam.isFastTransitionEnabled
12924#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012925 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012926#endif
12927 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012928 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012929 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012930 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012931 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012932 }
12933 else
12934 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012935 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012936 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012937 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012938 }
12939#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012940#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012941 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012942 {
12943 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012944 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012945 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012946 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012947 }
12948 else
12949 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012950 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012951 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012952 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012953 }
12954#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012955
12956 // txLdpcIniFeatureEnabled
12957 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12958 pBuf++;
12959
Kiran4a17ebe2013-01-31 10:43:43 -080012960 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12961 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12962 {
12963 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12964 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12965 csrApplyPower2Current(pMac);
12966 }
12967
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012968#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012969 // txBFIniFeatureEnabled
12970 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12971 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012972
12973 // txBFCsnValue
12974 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12975 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012976#endif
krunal soni5afa96c2013-09-06 22:19:02 -070012977 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
12978 pBuf++;
12979
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053012980 // WME
12981 if(pMac->roam.roamSession[sessionId].fWMMConnection)
12982 {
12983 //WME enabled
12984 dwTmp = pal_cpu_to_be32(TRUE);
12985 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
12986 pBuf += sizeof(tAniBool);
12987 }
12988 else
12989 {
12990 dwTmp = pal_cpu_to_be32(FALSE);
12991 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
12992 pBuf += sizeof(tAniBool);
12993 }
12994
12995 // QOS
12996 if(pMac->roam.roamSession[sessionId].fQOSConnection)
12997 {
12998 //QOS enabled
12999 dwTmp = pal_cpu_to_be32(TRUE);
13000 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13001 pBuf += sizeof(tAniBool);
13002 }
13003 else
13004 {
13005 dwTmp = pal_cpu_to_be32(FALSE);
13006 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13007 pBuf += sizeof(tAniBool);
13008 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013009 //BssDesc
13010 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13011 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013012
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013013 status = palSendMBMessage(pMac->hHdd, pMsg );
13014 if(!HAL_STATUS_SUCCESS(status))
13015 {
13016 break;
13017 }
13018 else
13019 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013020#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013021 if (eWNI_SME_JOIN_REQ == messageType)
13022 {
13023 //Tush-QoS: notify QoS module that join happening
13024 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13025 }
13026 else if (eWNI_SME_REASSOC_REQ == messageType)
13027 {
13028 //Tush-QoS: notify QoS module that reassoc happening
13029 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13030 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013031#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013032 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013033 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013034 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013035}
13036
Jeff Johnson295189b2012-06-20 16:38:30 -070013037//
13038eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13039{
13040 eHalStatus status = eHAL_STATUS_SUCCESS;
13041 tSirSmeDisassocReq *pMsg;
13042 tANI_U8 *pBuf;
13043 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013044 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13045 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13046 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013047 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013048 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13049 if (NULL == pMsg)
13050 status = eHAL_STATUS_FAILURE;
13051 else
13052 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013053 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013054 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013055 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13056 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013057 pBuf = &pMsg->sessionId;
13058 // sessionId
13059 *pBuf++ = (tANI_U8)sessionId;
13060 // transactionId
13061 *pBuf = 0;
13062 *( pBuf + 1 ) = 0;
13063 pBuf += sizeof(tANI_U16);
13064
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013065 if ( (pSession->pCurRoamProfile != NULL) &&
13066 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13067 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013068 {
13069 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013070 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13071 sizeof( tSirMacAddr ));
13072 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013073 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013074 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013075 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13076 //perMacAddr is passed as bssId for softAP
13077 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013078 pBuf = pBuf + sizeof ( tSirMacAddr );
13079 }
13080 else
13081 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013082 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013083 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13084 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013085 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013086 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13087 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013088 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013089 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013090 if(!HAL_STATUS_SUCCESS(status))
13091 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013092 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013093 break;
13094 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013095 // reasonCode
13096 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013097 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13098 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013099 if(!HAL_STATUS_SUCCESS(status))
13100 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013101 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013102 break;
13103 }
13104 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013105 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13106 Here we should not send the disassoc over the air to the AP */
13107 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13108#ifdef WLAN_FEATURE_VOWIFI_11R
13109 && csrRoamIs11rAssoc(pMac)
13110#endif
13111 )
13112 {
13113 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13114 }
13115 pBuf += sizeof(tANI_U8);
13116 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013117 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013118 return( status );
13119}
Jeff Johnson295189b2012-06-20 16:38:30 -070013120eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13121{
13122 eHalStatus status = eHAL_STATUS_SUCCESS;
13123 tSirSmeTkipCntrMeasReq *pMsg;
13124 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013125 do
13126 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013127 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13128 if ( NULL == pMsg )
13129 status = eHAL_STATUS_FAILURE;
13130 else
13131 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013132 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013133 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013134 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13135 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013136 pBuf = &pMsg->sessionId;
13137 // sessionId
13138 *pBuf++ = (tANI_U8)sessionId;
13139 // transactionId
13140 *pBuf = 0;
13141 *( pBuf + 1 ) = 0;
13142 pBuf += sizeof(tANI_U16);
13143 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013144 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13145 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013146 pBuf = pBuf + sizeof ( tSirMacAddr );
13147 // bEnable
13148 *pBuf = (tANI_BOOLEAN)bEnable;
13149 if(!HAL_STATUS_SUCCESS(status))
13150 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013151 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013152 break;
13153 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013154 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013155 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 return( status );
13157}
Jeff Johnson295189b2012-06-20 16:38:30 -070013158eHalStatus
13159csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13160 VOS_MODULE_ID modId, tSirMacAddr bssId,
13161 void *pUsrContext, void *pfnSapEventCallback,
13162 tANI_U8 *pAssocStasBuf )
13163{
13164 eHalStatus status = eHAL_STATUS_SUCCESS;
13165 tSirSmeGetAssocSTAsReq *pMsg;
13166 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13167 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013168 do
13169 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013170 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13171 if ( NULL == pMsg )
13172 status = eHAL_STATUS_FAILURE;
13173 else
13174 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013175 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013176 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013177 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013178 pBuf = (tANI_U8 *)&pMsg->bssId;
13179 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013180 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013181 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013182 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013183 // modId
13184 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013185 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013186 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013187 // pUsrContext
13188 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013189 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013190 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013191 // pfnSapEventCallback
13192 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013193 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013194 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013195 // pAssocStasBuf
13196 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
Kiet Lam64c1b492013-07-12 13:56:44 +053013197 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013198 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013199 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013200 status = palSendMBMessage( pMac->hHdd, pMsg );
13201 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013202 return( status );
13203 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013204eHalStatus
13205csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13206 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13207 {
13208 eHalStatus status = eHAL_STATUS_SUCCESS;
13209 tSirSmeGetWPSPBCSessionsReq *pMsg;
13210 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13211 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013212 do
13213 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013214 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13215 if ( NULL == pMsg )
13216 status = eHAL_STATUS_FAILURE;
13217 else
13218 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013219 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013220 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013221 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013223 VOS_ASSERT(pBuf);
13224
Jeff Johnson295189b2012-06-20 16:38:30 -070013225 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013226 // pUsrContext
13227 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013228 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013229 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 // pSapEventCallback
13231 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013232 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013233 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013234 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013235 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013236 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013238 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013239 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013240 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013241 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013242 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013243 return( status );
13244}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013245
13246eHalStatus
13247csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13248{
13249 tpSirChangeBIParams pMsg;
13250 tANI_U16 len = 0;
13251 eHalStatus status = eHAL_STATUS_SUCCESS;
13252 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13253
13254 if(!pSession)
13255 {
13256 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13257 return eHAL_STATUS_FAILURE;
13258 }
13259
13260 //NO need to update the Beacon Params if update beacon parameter flag is not set
13261 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13262 return eHAL_STATUS_SUCCESS;
13263
13264 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13265
13266 /* Create the message and send to lim */
13267 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013268 pMsg = vos_mem_malloc(len);
13269 if ( NULL == pMsg )
13270 status = eHAL_STATUS_FAILURE;
13271 else
13272 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013273 if(HAL_STATUS_SUCCESS(status))
13274 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013275 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013276 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13277 pMsg->length = len;
13278
13279 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013280 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13281 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013282 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13283 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013284 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013285 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013286 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13287 status = palSendMBMessage(pMac->hHdd, pMsg);
13288 }
13289 return status;
13290}
13291
Jeff Johnson295189b2012-06-20 16:38:30 -070013292eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13293{
13294 eHalStatus status = eHAL_STATUS_SUCCESS;
13295 tSirSmeDeauthReq *pMsg;
13296 tANI_U8 *pBuf;
13297 tANI_U16 wTmp;
13298 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13299 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13300 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013301 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013302 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13303 if ( NULL == pMsg )
13304 status = eHAL_STATUS_FAILURE;
13305 else
13306 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013307 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013308 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013309 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13310 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13311 //sessionId
13312 pBuf = &pMsg->sessionId;
13313 *pBuf++ = (tANI_U8)sessionId;
13314
13315 //tansactionId
13316 *pBuf = 0;
13317 *(pBuf + 1 ) = 0;
13318 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013319 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013320 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013321 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13322 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013323 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13324 sizeof( pMsg->peerMacAddr ) );
13325 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013326 pBuf = pBuf + sizeof(tSirMacAddr);
13327 }
13328 else
13329 {
13330 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013331 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13332 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013333 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013334 }
13335 if(!HAL_STATUS_SUCCESS(status))
13336 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013337 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 break;
13339 }
13340 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013341 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13342 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013343 pBuf = pBuf + sizeof(tSirMacAddr);
13344 if(!HAL_STATUS_SUCCESS(status))
13345 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013346 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013347 break;
13348 }
13349 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013350 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13351 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013352 if(!HAL_STATUS_SUCCESS(status))
13353 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013354 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013355 break;
13356 }
13357 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013358 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013359 return( status );
13360}
13361
Jeff Johnson295189b2012-06-20 16:38:30 -070013362eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13363{
13364 eHalStatus status = eHAL_STATUS_SUCCESS;
13365 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013366 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013367 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13368 if ( NULL == pMsg )
13369 status = eHAL_STATUS_FAILURE;
13370 else
13371 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013372 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013373 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013374 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13375 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13376 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013377 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13378 sizeof(pMsg->peerMacAddr));
13379 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013380 if(!HAL_STATUS_SUCCESS(status))
13381 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013382 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013383 break;
13384 }
13385//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013386 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13387 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013388 if(!HAL_STATUS_SUCCESS(status))
13389 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013390 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013391 break;
13392 }
13393//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013394 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013395 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013396 return( status );
13397}
13398
Jeff Johnson295189b2012-06-20 16:38:30 -070013399eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13400{
13401 eHalStatus status = eHAL_STATUS_SUCCESS;
13402 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013403 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013404 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13405 if ( NULL == pMsg )
13406 status = eHAL_STATUS_FAILURE;
13407 else
13408 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013409 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013410 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013411 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13412 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13413 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013414 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13415 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013416 if(!HAL_STATUS_SUCCESS(status))
13417 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013418 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013419 break;
13420 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013421 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13422 sizeof(pMsg->peerMacAddr));
13423 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013424 if(!HAL_STATUS_SUCCESS(status))
13425 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013426 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013427 break;
13428 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013429 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013430 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013431 return( status );
13432}
Jeff Johnson295189b2012-06-20 16:38:30 -070013433eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13434{
13435 eHalStatus status = eHAL_STATUS_SUCCESS;
13436 tSirSmeAssocCnf *pMsg;
13437 tANI_U8 *pBuf;
13438 tSirResultCodes statusCode;
13439 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013440 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013441 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13442 if ( NULL == pMsg )
13443 status = eHAL_STATUS_FAILURE;
13444 else
13445 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013446 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013447 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013448 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13449 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013450 pBuf = (tANI_U8 *)&pMsg->statusCode;
13451 if(HAL_STATUS_SUCCESS(Halstatus))
13452 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13453 else
13454 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013455 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013456 pBuf += sizeof(tSirResultCodes);
13457 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013458 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13459 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013460 pBuf += sizeof (tSirMacAddr);
13461 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013462 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13463 sizeof(tSirMacAddr));
13464 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013465 pBuf += sizeof (tSirMacAddr);
13466 // aid
13467 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013468 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013469 pBuf += sizeof (tANI_U16);
13470 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013471 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13472 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013473 pBuf += sizeof (tSirMacAddr);
13474 // alternateChannelId
13475 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013476 status = palSendMBMessage( pMac->hHdd, pMsg );
13477 if(!HAL_STATUS_SUCCESS(status))
13478 {
13479 //pMsg is freed by palSendMBMessage
13480 break;
13481 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013482 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013483 return( status );
13484}
Jeff Johnson295189b2012-06-20 16:38:30 -070013485eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13486 tpSirSmeAssocInd pAssocInd,
13487 eHalStatus Halstatus,
13488 tANI_U8 sessionId)
13489{
13490 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013491 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13492 tANI_U8 *pBuf;
13493 tSirResultCodes statusCode;
13494 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013496 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13497 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13498 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013499
Jeff Johnson295189b2012-06-20 16:38:30 -070013500 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13501 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13502
13503 pMsg->sessionId = sessionId;
13504
13505 pBuf = (tANI_U8 *)&pMsg->statusCode;
13506 if(HAL_STATUS_SUCCESS(Halstatus))
13507 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13508 else
13509 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013510 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013511 pBuf += sizeof(tSirResultCodes);
13512 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013513 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013514 pBuf += sizeof (tSirMacAddr);
13515 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013516 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13517 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013518 pBuf += sizeof (tSirMacAddr);
13519 // StaId
13520 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013521 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013522 pBuf += sizeof (tANI_U16);
13523 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013524 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013525 pBuf += sizeof (tSirMacAddr);
13526 // alternateChannelId
13527 *pBuf = 11;
13528 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013529 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013530 //Wmm
13531 *pBuf = pAssocInd->wmmEnabledSta;
13532 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013533 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013534 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013535 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013536 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013537 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013539 //reassocReq
13540 *pBuf = pAssocInd->reassocReq;
13541 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013542 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13543 msgQ.bodyptr = pMsg;
13544 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013545 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013547 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013548}
Jeff Johnson295189b2012-06-20 16:38:30 -070013549
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013550eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013551 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13552 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13553 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13554 tANI_U8 *pKeyRsc )
13555{
13556 tSirSmeSetContextReq *pMsg;
13557 tANI_U16 msgLen;
13558 eHalStatus status = eHAL_STATUS_FAILURE;
13559 tAniEdType tmpEdType;
13560 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013561 tANI_U8 *pBuf = NULL;
13562 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013563 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013564 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013565 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013566 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13567 // key set. Since we only support upto one key, we always allocate memory for 1 key
13568 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13569 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13570 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13571 ( sizeof( pMsg->keyMaterial.key ) );
13572
Kiet Lam64c1b492013-07-12 13:56:44 +053013573 pMsg = vos_mem_malloc(msgLen);
13574 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13575 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013576 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13577 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013578 //sessionId
13579 pBuf = &pMsg->sessionId;
13580 *pBuf = (tANI_U8)sessionId;
13581 pBuf++;
13582 // transactionId
13583 *pBuf = 0;
13584 *(pBuf + 1) = 0;
13585 pBuf += sizeof(tANI_U16);
13586 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013587 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013588
13589 pBuf += sizeof(tSirMacAddr);
13590
13591 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013592 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13593 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013594
13595 pBuf += sizeof(tSirMacAddr);
13596
13597 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013598 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13599 // in the tSirKeyMaterial keyMaterial; field).
13600 //
13601 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13602 // shorter than this max size. Is LIM interpreting this ok ?
13603 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 -070013604 // set pMsg->keyMaterial.edType
13605 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013606 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013607 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013608 // set the pMsg->keyMaterial.numKeys field
13609 *p = numKeys;
13610 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013611 // set pSirKey->keyId = keyId;
13612 *p = keyId;
13613 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013614 // set pSirKey->unicast = (tANI_U8)fUnicast;
13615 *p = (tANI_U8)fUnicast;
13616 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013617 // set pSirKey->keyDirection = aniKeyDirection;
13618 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013619 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 p += sizeof(tAniKeyDirection);
13621 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013622 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013623 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013624 // set pSirKey->paeRole
13625 *p = paeRole; // 0 is Supplicant
13626 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013627 // set pSirKey->keyLength = keyLength;
13628 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013629 if ( keyLength && pKey )
13630 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013631 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013632 if(keyLength == 16)
13633 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013634 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 -070013635 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13636 pKey[5], pKey[6], pKey[7], pKey[8],
13637 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13638 }
13639 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013640 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013641 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013642 return( status );
13643}
13644
Jeff Johnson295189b2012-06-20 16:38:30 -070013645eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13646 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13647{
13648 eHalStatus status;
13649 tSirSmeStartBssReq *pMsg;
13650 tANI_U8 *pBuf = NULL;
13651 tANI_U8 *wTmpBuf = NULL;
13652 tANI_U16 msgLen, wTmp;
13653 tANI_U32 dwTmp;
13654 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013655 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013656 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013657 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013658
13659 if(!pSession)
13660 {
13661 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13662 return eHAL_STATUS_FAILURE;
13663 }
13664
Jeff Johnson295189b2012-06-20 16:38:30 -070013665 do {
13666 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13667 pSession->joinFailStatusCode.reasonCode = 0;
13668 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013669 pMsg = vos_mem_malloc(msgLen);
13670 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13671 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013672 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013674 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013675 //sessionId
13676 *pBuf = (tANI_U8)sessionId;
13677 pBuf++;
13678 // transactionId
13679 *pBuf = 0;
13680 *(pBuf + 1) = 0;
13681 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013682 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013683 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013684 pBuf += sizeof(tSirMacAddr);
13685 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013686 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 pBuf += sizeof(tSirMacAddr);
13688 // beaconInterval
13689 if( pBssDesc && pBssDesc->beaconInterval )
13690 {
13691 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13692 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013693 else if(pParam->beaconInterval)
13694 {
13695 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13696 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013697 else
13698 {
13699 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13700 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013701 if(csrIsconcurrentsessionValid (pMac, sessionId,
13702 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013703 == eHAL_STATUS_SUCCESS )
13704 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013705 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013706 pParam->bssPersona);
13707 //Update the beacon Interval
13708 pParam->beaconInterval = wTmp;
13709 }
13710 else
13711 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013712 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013713 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013714 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013715 return status;
13716 }
13717
Kiet Lam64c1b492013-07-12 13:56:44 +053013718 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013719 pBuf += sizeof(tANI_U16);
13720 // dot11mode
13721 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13722 pBuf += 1;
13723 // bssType
13724 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013725 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013726 pBuf += sizeof(tSirBssType);
13727 // ssId
13728 if( pParam->ssId.length )
13729 {
13730 // ssId len
13731 *pBuf = pParam->ssId.length;
13732 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013733 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013734 pBuf += pParam->ssId.length;
13735 }
13736 else
13737 {
13738 *pBuf = 0;
13739 pBuf++;
13740 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013741 // set the channel Id
13742 *pBuf = pParam->operationChn;
13743 pBuf++;
13744 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013745 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013746 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013747 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013748
Jeff Johnson295189b2012-06-20 16:38:30 -070013749 // Set privacy
13750 *pBuf = pParam->privacy;
13751 pBuf++;
13752
13753 //Set Uapsd
13754 *pBuf = pParam->ApUapsdEnable;
13755 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013756 //Set SSID hidden
13757 *pBuf = pParam->ssidHidden;
13758 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013759 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13760 pBuf++;
13761
13762 //Ht protection Enable/Disable
13763 *pBuf = (tANI_U8)pParam->protEnabled;
13764 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013765 //Enable Beacons to Receive for OBSS protection Enable/Disable
13766 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13767 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013768 //set cfg related to protection
13769 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013770 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013771 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 // Set Auth type
13773 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013774 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013775 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013776 // Set DTIM
13777 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013778 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013779 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013780 // Set wps_state
13781 *pBuf = pParam->wps_state;
13782 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080013783 // set isCoalesingInIBSSAllowed
13784 *pBuf = pMac->isCoalesingInIBSSAllowed;
13785 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013786 //Persona
13787 *pBuf = (tANI_U8)pParam->bssPersona;
13788 pBuf++;
13789
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013790 //txLdpcIniFeatureEnabled
13791 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13792 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013793
krunal soni4f087d22013-07-29 16:32:26 -070013794 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013795 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13796 {
13797 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013798 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013799 break;
13800 }
13801 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013802 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013803 pBuf += sizeof(tANI_U16);
13804 if( wTmp )
13805 {
13806 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013807 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013808 pBuf += wTmp;
13809 }
13810 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013811 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013812 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013813 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13814 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013815 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13816 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013817 pBuf += pParam->operationalRateSet.numRates ;
13818 *pBuf++ = pParam->extendedRateSet.numRates;
13819 if(0 != pParam->extendedRateSet.numRates)
13820 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013821 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13822 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013823 pBuf += pParam->extendedRateSet.numRates;
13824 }
krunal sonie9002db2013-11-25 14:24:17 -080013825
Jeff Johnson295189b2012-06-20 16:38:30 -070013826 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13827 pMsg->length = pal_cpu_to_be16(msgLen);
13828
13829 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013830 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013831 return( status );
13832}
13833
Jeff Johnson295189b2012-06-20 16:38:30 -070013834eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13835{
13836 eHalStatus status = eHAL_STATUS_FAILURE;
13837 tSirSmeStopBssReq *pMsg;
13838 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13839 tANI_U8 *pBuf;
13840 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013841
13842 if(!pSession)
13843 {
13844 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13845 return eHAL_STATUS_FAILURE;
13846 }
13847
Jeff Johnson295189b2012-06-20 16:38:30 -070013848 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013849 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13850 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13851 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013852 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13853 pBuf = &pMsg->sessionId;
13854 //sessionId
13855 *pBuf = (tANI_U8)sessionId;
13856 pBuf++;
13857 // transactionId
13858 *pBuf = 0;
13859 pBuf += sizeof(tANI_U16);
13860 //reason code
13861 *pBuf = 0;
13862 pBuf += sizeof(tSirResultCodes);
13863 // bssid
13864 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13865 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13866 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013867 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
13868 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013869 }
13870 else
13871 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013872 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13873 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013874 }
13875 pBuf += sizeof(tSirMacAddr);
13876 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13877 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013878 status = palSendMBMessage( pMac->hHdd, pMsg );
13879#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053013880 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13881 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13882 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013883 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13884 pMsg->reasonCode = 0;
13885 // bssid
13886 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13887 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13888 {
13889 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13890 }
13891 else
13892 {
13893 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13894 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013895 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013896 pMsg->transactionId = 0;
13897 pMsg->sessionId = (tANI_U8)sessionId;
13898 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13899 status = palSendMBMessage( pMac->hHdd, pMsg );
13900#endif
13901 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013902 return( status );
13903}
13904
Jeff Johnson295189b2012-06-20 16:38:30 -070013905eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13906 tCsrRoamModifyProfileFields *pModProfileFields,
13907 tANI_U32 *pRoamId, v_BOOL_t fForce)
13908{
Jeff Johnson295189b2012-06-20 16:38:30 -070013909 eHalStatus status = eHAL_STATUS_FAILURE;
13910 tANI_U32 roamId = 0;
13911 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013912 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053013913 (fForce || (!vos_mem_compare( &pModProfileFields,
13914 &pSession->connectedProfile.modifyProfileFields,
13915 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013916 {
13917 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13918 if(pRoamId)
13919 {
13920 *pRoamId = roamId;
13921 }
13922
Jeff Johnson295189b2012-06-20 16:38:30 -070013923 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13924 eCsrSmeIssuedReassocToSameAP, roamId,
13925 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013926 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013927 return status;
13928}
Jeff Johnson295189b2012-06-20 16:38:30 -070013929static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13930{
13931 eHalStatus status = eHAL_STATUS_SUCCESS;
13932 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053013933 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013934 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13935 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13936 return (status);
13937}
Jeff Johnson295189b2012-06-20 16:38:30 -070013938eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13939{
13940 eHalStatus status = eHAL_STATUS_SUCCESS;
13941 tListElem *pEntry = NULL;
13942 tSmeCmd *pCommand = NULL;
13943 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013944 do
13945 {
13946 if(pMsg == NULL)
13947 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013948 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013949 status = eHAL_STATUS_FAILURE;
13950 break;
13951 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013952 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13953 if(pEntry)
13954 {
13955 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13956 if(eSmeCommandAddStaSession == pCommand->command)
13957 {
13958 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013959 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013960 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013961 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013962 //Remove this command out of the active list
13963 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13964 {
13965 //Now put this command back on the avilable command list
13966 csrReleaseCommand(pMac, pCommand);
13967 }
13968 smeProcessPendingQueue( pMac );
13969 }
13970 else
13971 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013972 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 -070013973 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013974 status = eHAL_STATUS_FAILURE;
13975 break;
13976 }
13977 }
13978 else
13979 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013980 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 -070013981 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013982 status = eHAL_STATUS_FAILURE;
13983 break;
13984 }
13985 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013986 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013987}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013988eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
13989 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070013990{
13991 tSirSmeAddStaSelfReq *pMsg;
13992 tANI_U16 msgLen;
13993 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013994 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013995 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013996 pMsg = vos_mem_malloc(msgLen);
13997 if ( NULL == pMsg ) break;
13998 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013999 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14000 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014001 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014002 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014003 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14004
14005 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14006
Arif Hussain24bafea2013-11-15 15:10:03 -080014007 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14008 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014009 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014010 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014011 return( status );
14012}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014013eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14014 tANI_U32 sessionId,
14015 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014016{
14017 eHalStatus status = eHAL_STATUS_SUCCESS;
14018 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 pCommand = csrGetCommandBuffer(pMac);
14020 if(NULL == pCommand)
14021 {
14022 status = eHAL_STATUS_RESOURCES;
14023 }
14024 else
14025 {
14026 pCommand->command = eSmeCommandAddStaSession;
14027 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014028 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14029 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014030 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014031 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14032 if( !HAL_STATUS_SUCCESS( status ) )
14033 {
14034 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014035 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014036 }
14037 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014038 return (status);
14039}
Jeff Johnson295189b2012-06-20 16:38:30 -070014040eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14041{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014042 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014043}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014044eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14045 csrRoamCompleteCallback callback,
14046 void *pContext, tANI_U8 *pSelfMacAddr,
14047 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014048{
14049 eHalStatus status = eHAL_STATUS_SUCCESS;
14050 tANI_U32 i;
14051 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014052 *pbSessionId = CSR_SESSION_ID_INVALID;
14053 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14054 {
14055 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14056 {
14057 pSession = CSR_GET_SESSION( pMac, i );
14058 status = eHAL_STATUS_SUCCESS;
14059 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14060 pSession->sessionId = (tANI_U8)i;
14061 pSession->callback = callback;
14062 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014063 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014064 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014065 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14066 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014067 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014068 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014069 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014070 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014071 break;
14072 }
14073#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014074 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14075 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014076 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014077 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014078 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014079 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014080 break;
14081 }
14082#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014083 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014084 break;
14085 }
14086 }
14087 if( CSR_ROAM_SESSION_MAX == i )
14088 {
14089 //No session is available
14090 status = eHAL_STATUS_RESOURCES;
14091 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014092 return ( status );
14093}
Jeff Johnson295189b2012-06-20 16:38:30 -070014094eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14095{
14096 eHalStatus status = eHAL_STATUS_SUCCESS;
14097 tListElem *pEntry = NULL;
14098 tSmeCmd *pCommand = NULL;
14099 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 do
14101 {
14102 if(pMsg == NULL)
14103 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014104 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014105 status = eHAL_STATUS_FAILURE;
14106 break;
14107 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014108 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14109 if(pEntry)
14110 {
14111 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14112 if(eSmeCommandDelStaSession == pCommand->command)
14113 {
14114 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014115 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014116 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014117 //This session is done.
14118 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014119 if(pCommand->u.delStaSessionCmd.callback)
14120 {
14121
14122 status = sme_ReleaseGlobalLock( &pMac->sme );
14123 if ( HAL_STATUS_SUCCESS( status ) )
14124 {
14125 pCommand->u.delStaSessionCmd.callback(
14126 pCommand->u.delStaSessionCmd.pContext);
14127 status = sme_AcquireGlobalLock( &pMac->sme );
14128 if (! HAL_STATUS_SUCCESS( status ) )
14129 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014130 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014131 return status;
14132 }
14133 }
14134 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014135 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014136 }
14137 }
14138
14139 //Remove this command out of the active list
14140 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14141 {
14142 //Now put this command back on the avilable command list
14143 csrReleaseCommand(pMac, pCommand);
14144 }
14145 smeProcessPendingQueue( pMac );
14146 }
14147 else
14148 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014149 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 -070014150 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014151 status = eHAL_STATUS_FAILURE;
14152 break;
14153 }
14154 }
14155 else
14156 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014157 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 -070014158 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014159 status = eHAL_STATUS_FAILURE;
14160 break;
14161 }
14162 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014163 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014164}
Jeff Johnson295189b2012-06-20 16:38:30 -070014165eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14166{
14167 tSirSmeDelStaSelfReq *pMsg;
14168 tANI_U16 msgLen;
14169 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014170 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014171 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14172 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014173 pMsg = vos_mem_malloc(msgLen);
14174 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14175 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014176 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14177 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014178 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014179 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14180 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014181 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014182 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014183 return( status );
14184}
Jeff Johnson295189b2012-06-20 16:38:30 -070014185eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14186 tSirMacAddr sessionMacAddr,
14187 csrRoamSessionCloseCallback callback,
14188 void *pContext)
14189{
14190 eHalStatus status = eHAL_STATUS_SUCCESS;
14191 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014192 pCommand = csrGetCommandBuffer(pMac);
14193 if(NULL == pCommand)
14194 {
14195 status = eHAL_STATUS_RESOURCES;
14196 }
14197 else
14198 {
14199 pCommand->command = eSmeCommandDelStaSession;
14200 pCommand->sessionId = (tANI_U8)sessionId;
14201 pCommand->u.delStaSessionCmd.callback = callback;
14202 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014203 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14204 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014205 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14206 if( !HAL_STATUS_SUCCESS( status ) )
14207 {
14208 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014209 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014210 }
14211 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014212 return (status);
14213}
Jeff Johnson295189b2012-06-20 16:38:30 -070014214eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14215{
14216 return csrSendMBDelSelfStaReqMsg( pMac,
14217 pCommand->u.delStaSessionCmd.selfMacAddr );
14218}
Jeff Johnson295189b2012-06-20 16:38:30 -070014219static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14220{
14221 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14222 tListElem *pEntry, *pNext;
14223 tSmeCmd *pCommand;
14224 tDblLinkList localList;
14225
14226 vos_mem_zero(&localList, sizeof(tDblLinkList));
14227 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14228 {
14229 smsLog(pMac, LOGE, FL(" failed to open list"));
14230 return;
14231 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014232 csrLLLock(pList);
14233 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14234 while(pEntry != NULL)
14235 {
14236 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14237 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14238 if(pCommand->sessionId == sessionId)
14239 {
14240 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14241 {
14242 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14243 }
14244 }
14245 pEntry = pNext;
14246 }
14247 csrLLUnlock(pList);
14248
14249 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14250 {
14251 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14252 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14253 }
14254 csrLLClose(&localList);
14255}
14256
Jeff Johnson295189b2012-06-20 16:38:30 -070014257void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14258{
14259 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14260 {
14261 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014262 csrRoamStop(pMac, sessionId);
14263 csrFreeConnectBssDesc(pMac, sessionId);
14264 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14265 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014266 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014267#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014268 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014269#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014270 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14271 if (pMac->fScanOffload)
14272 {
14273 purgeSmeSessionCmdList(pMac, sessionId,
14274 &pMac->sme.smeScanCmdPendingList);
14275 }
14276
Jeff Johnson295189b2012-06-20 16:38:30 -070014277 purgeCsrSessionCmdList(pMac, sessionId);
14278 csrInitSession(pMac, sessionId);
14279 }
14280}
14281
Jeff Johnson295189b2012-06-20 16:38:30 -070014282eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14283 tANI_BOOLEAN fSync,
14284 csrRoamSessionCloseCallback callback,
14285 void *pContext )
14286{
14287 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014288 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14289 {
14290 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14291 if(fSync)
14292 {
14293 csrCleanupSession(pMac, sessionId);
14294 }
14295 else
14296 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014297 purgeSmeSessionCmdList(pMac, sessionId,
14298 &pMac->sme.smeCmdPendingList);
14299 if (pMac->fScanOffload)
14300 {
14301 purgeSmeSessionCmdList(pMac, sessionId,
14302 &pMac->sme.smeScanCmdPendingList);
14303 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014304 purgeCsrSessionCmdList(pMac, sessionId);
14305 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14306 pSession->selfMacAddr, callback, pContext);
14307 }
14308 }
14309 else
14310 {
14311 status = eHAL_STATUS_INVALID_PARAMETER;
14312 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014313 return ( status );
14314}
14315
Jeff Johnson295189b2012-06-20 16:38:30 -070014316static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14317{
14318 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014319
14320 if(!pSession)
14321 {
14322 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14323 return;
14324 }
14325
Jeff Johnson295189b2012-06-20 16:38:30 -070014326 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14327 pSession->sessionId = CSR_SESSION_ID_INVALID;
14328 pSession->callback = NULL;
14329 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014330 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14331 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14332 csrFreeRoamProfile( pMac, sessionId );
14333 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14334 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14335 csrFreeConnectBssDesc(pMac, sessionId);
14336 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014337 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14338 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014339 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014340 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014341 pSession->pWpaRsnReqIE = NULL;
14342 }
14343 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014344 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014345 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014346 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014347 pSession->pWpaRsnRspIE = NULL;
14348 }
14349 pSession->nWpaRsnRspIeLength = 0;
14350#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014351 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014352 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014353 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014354 pSession->pWapiReqIE = NULL;
14355 }
14356 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014357 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014358 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014359 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014360 pSession->pWapiRspIE = NULL;
14361 }
14362 pSession->nWapiRspIeLength = 0;
14363#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014364 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014365 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014366 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014367 }
14368 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014369
Kiet Lam64c1b492013-07-12 13:56:44 +053014370 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014371 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014372 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014373 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014374 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014375 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014376}
14377
Jeff Johnson295189b2012-06-20 16:38:30 -070014378eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14379{
14380 eHalStatus status = eHAL_STATUS_FAILURE;
14381 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014382 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14383 {
14384 if( CSR_IS_SESSION_VALID( pMac, i ) )
14385 {
14386 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14387 {
14388 //Found it
14389 status = eHAL_STATUS_SUCCESS;
14390 *pSessionId = i;
14391 break;
14392 }
14393 }
14394 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014395 return( status );
14396}
14397
Jeff Johnson295189b2012-06-20 16:38:30 -070014398//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14399//session because for IBSS, the bssid changes.
14400static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14401{
14402 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14403 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014404 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14405 {
14406 if( CSR_IS_SESSION_VALID( pMac, i ) )
14407 {
14408 pSession = CSR_GET_SESSION( pMac, i );
14409 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14410 {
14411 //Found it
14412 nRet = i;
14413 break;
14414 }
14415 }
14416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014417 return (nRet);
14418}
Jeff Johnson295189b2012-06-20 16:38:30 -070014419static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14420{
14421 /* Update the current BSS info in ho control block based on connected
14422 profile info from pmac global structure */
14423
Arif Hussain24bafea2013-11-15 15:10:03 -080014424 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14425 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014426 /* Check for user misconfig of RSSI trigger threshold */
14427 pMac->roam.configParam.vccRssiThreshold =
14428 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14429 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14430 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014431 /* Check for user misconfig of UL MAC Loss trigger threshold */
14432 pMac->roam.configParam.vccUlMacLossThreshold =
14433 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14434 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014435#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14436 {
14437 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014438 /* Indicate the neighbor roal algorithm about the connect indication */
14439 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14440 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14441 }
14442#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014443}
14444
Jeff Johnson295189b2012-06-20 16:38:30 -070014445static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14446{
14447 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014448
14449 if(!pSession)
14450 {
14451 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14452 return;
14453 }
14454
Jeff Johnson295189b2012-06-20 16:38:30 -070014455 //Only to handle the case for Handover on infra link
14456 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14457 {
14458 return;
14459 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014460 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14461 csrRoamDeregStatisticsReq(pMac);
14462 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14463#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14464 /* Indicate the neighbor roal algorithm about the disconnect indication */
14465 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14466#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014467
14468 //Remove this code once SLM_Sessionization is supported
14469 //BMPS_WORKAROUND_NOT_NEEDED
14470 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014471 csrIsInfraApStarted( pMac ) &&
14472 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014473 {
14474 pMac->roam.configParam.doBMPSWorkaround = 0;
14475 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014476}
14477
Jeff Johnson295189b2012-06-20 16:38:30 -070014478void csrRoamTlStatsTimerHandler(void *pv)
14479{
14480 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14481 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014482 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14483
Jeff Johnsone7245742012-09-05 17:12:55 -070014484 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14485
Jeff Johnson295189b2012-06-20 16:38:30 -070014486#if 0
14487 // TODO Persession .???
14488 //req TL for stats
14489 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14490 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014491 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014492 }
14493 else
14494 {
14495 //save in SME
14496 csrRoamSaveStatsFromTl(pMac, tlStats);
14497 }
14498#endif
14499 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14500 {
14501 if(pMac->roam.tlStatsReqInfo.periodicity)
14502 {
14503 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014504 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14505 pMac->roam.tlStatsReqInfo.periodicity);
14506 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014507 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014508 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014509 return;
14510 }
14511 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14512 }
14513 }
14514}
Jeff Johnson295189b2012-06-20 16:38:30 -070014515void csrRoamPeStatsTimerHandler(void *pv)
14516{
14517 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14518 eHalStatus status;
14519 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14520 VOS_STATUS vosStatus;
14521 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014522 pPeStatsReqListEntry->timerRunning = FALSE;
14523 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14524 {
14525 // If we entered here, meaning the timer could not be successfully
14526 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14527
14528 /* Destroy the timer */
14529 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14530 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14531 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014532 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014533 }
14534
14535 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014536 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014537 pPeStatsReqListEntry = NULL;
14538 }
14539 else
14540 {
14541 if(!pPeStatsReqListEntry->rspPending)
14542 {
14543 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14544 pPeStatsReqListEntry->staId);
14545 if(!HAL_STATUS_SUCCESS(status))
14546 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014547 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014548 }
14549 else
14550 {
14551 pPeStatsReqListEntry->rspPending = TRUE;
14552 }
14553 }
14554
14555 //send down a req
14556 if(pPeStatsReqListEntry->periodicity &&
14557 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14558 {
14559 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14560 if(ePMC_FULL_POWER == powerState)
14561 {
14562 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14563 {
14564 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14565 }
14566 }
14567 else
14568 {
14569 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14570 {
14571 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14572 }
14573 }
14574 //start timer
14575 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14576 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14577 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014578 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014579 return;
14580 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014581 pPeStatsReqListEntry->timerRunning = TRUE;
14582
14583 }
14584
14585 }
14586}
Jeff Johnson295189b2012-06-20 16:38:30 -070014587void csrRoamStatsClientTimerHandler(void *pv)
14588{
14589 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014590 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14591 {
14592#if 0
14593 // TODO Stats fix for multisession
14594 //start the timer
14595 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14596
14597 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14598 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014599 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014600 }
14601#endif
14602 }
14603#if 0
14604 //send up the stats report
14605 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14606 pStaEntry->staId, pStaEntry->pContext);
14607#endif
14608}
14609
14610
14611
Jeff Johnson295189b2012-06-20 16:38:30 -070014612eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14613{
14614 tAniGetPEStatsReq *pMsg;
14615 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014616 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14617 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014618 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014619 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053014620 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014621 }
14622 // need to initiate a stats request to PE
14623 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14624 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14625 pMsg->staId = staId;
14626 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014627 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014628 if(!HAL_STATUS_SUCCESS(status))
14629 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014630 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070014631 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014632 return status;
14633}
Jeff Johnson295189b2012-06-20 16:38:30 -070014634void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14635{
14636 tAniGetPEStatsRsp *pSmeStatsRsp;
14637 eHalStatus status = eHAL_STATUS_FAILURE;
14638 tListElem *pEntry = NULL;
14639 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14640 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14641 tANI_U32 tempMask = 0;
14642 tANI_U8 counter = 0;
14643 tANI_U8 *pStats = NULL;
14644 tANI_U32 length = 0;
14645 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014646 v_S7_t rssi = 0, snr = 0;
14647 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014648 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014649 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14650 if(pSmeStatsRsp->rc)
14651 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014652 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014653 goto post_update;
14654 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014655 tempMask = pSmeStatsRsp->statsMask;
14656 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014657 /* subtract all statistics from this length, and after processing the entire
14658 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14659 * in this 'stats' message.
14660 */
14661 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014662 //new stats info from PE, fill up the stats strucutres in PMAC
14663 while(tempMask)
14664 {
14665 if(tempMask & 1)
14666 {
14667 switch(counter)
14668 {
14669 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014670 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014671 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14672 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014673 pStats += sizeof(tCsrSummaryStatsInfo);
14674 length -= sizeof(tCsrSummaryStatsInfo);
14675 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014676 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014677 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014678 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14679 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014680 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14681 length -= sizeof(tCsrGlobalClassAStatsInfo);
14682 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014683 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014684 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014685 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14686 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014687 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14688 length -= sizeof(tCsrGlobalClassBStatsInfo);
14689 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014690 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014691 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014692 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14693 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014694 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14695 length -= sizeof(tCsrGlobalClassCStatsInfo);
14696 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014697 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014698 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014699 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14700 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014701 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14702 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014703 }
14704 else
14705 {
14706 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014707 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014708 VOS_ASSERT( 0 );
14709 }
14710 if(!HAL_STATUS_SUCCESS(status))
14711 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014712 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014713 }
14714 pStats += sizeof(tCsrPerStaStatsInfo);
14715 length -= sizeof(tCsrPerStaStatsInfo);
14716 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014717 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014718 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014719 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014720 }
14721 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014722 tempMask >>=1;
14723 counter++;
14724 }
14725 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14726 if (length != 0)
14727 {
14728 pRssi = (tANI_U32*)pStats;
14729 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014730 pStats += sizeof(tANI_U32);
14731 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014732 }
14733 else
14734 {
14735 /* If riva is not sending rssi, continue to use the hack */
14736 rssi = RSSI_HACK_BMPS;
14737 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014738
Jeff Johnson295189b2012-06-20 16:38:30 -070014739 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014740
14741 if (length != 0)
14742 {
14743 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014744 pStats += sizeof(tANI_U32);
14745 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014746 }
14747 else
14748 {
14749 linkCapacity = 0;
14750 }
14751
14752 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014753
14754 if (length != 0)
14755 {
14756 pSnr = (tANI_U32*)pStats;
14757 snr = (v_S7_t)*pSnr;
14758 }
14759 else
14760 {
14761 snr = SNR_HACK_BMPS;
14762 }
14763
14764 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014765post_update:
14766 //make sure to update the pe stats req list
14767 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14768 if(pEntry)
14769 {
14770 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14771 pPeStaEntry->rspPending = FALSE;
14772
14773 }
14774 //check the one timer cases
14775 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14776 if(pEntry)
14777 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014778 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014779 if(pTempStaEntry->timerExpired)
14780 {
14781 //send up the stats report
14782 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14783 pTempStaEntry->staId, pTempStaEntry->pContext);
14784 //also remove from the client list
14785 csrRoamRemoveStatListEntry(pMac, pEntry);
14786 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014787 }
14788 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014789}
Jeff Johnson295189b2012-06-20 16:38:30 -070014790tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14791{
14792 tListElem *pEntry = NULL;
14793 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014794 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014795 if(!pEntry)
14796 {
14797 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014798 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014799 return NULL;
14800 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014801 while( pEntry )
14802 {
14803 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014804 if(pTempStaEntry->statsMask == statsMask)
14805 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014806 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014807 break;
14808 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014809 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14810 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014811 return pEntry;
14812}
14813
Jeff Johnson295189b2012-06-20 16:38:30 -070014814tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14815 tANI_BOOLEAN update)
14816{
14817 tListElem *pEntry;
14818 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014819 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014820 if(!pEntry)
14821 {
14822 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014823 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014824 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014825 return NULL;
14826 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014827 while( pEntry )
14828 {
14829 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014830 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14831 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14832 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014833 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014834 if(update)
14835 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014836 pTempStaEntry->periodicity = pStaEntry->periodicity;
14837 pTempStaEntry->callback = pStaEntry->callback;
14838 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014839 }
14840 break;
14841 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014842 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14843 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014844 return pEntry;
14845}
Jeff Johnson295189b2012-06-20 16:38:30 -070014846tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14847{
14848 tListElem *pEntry;
14849 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014850 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014851 if(!pEntry)
14852 {
14853 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014854 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014855 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014856 return NULL;
14857 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014858 while( pEntry )
14859 {
14860 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014861 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14862 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014863 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014864 break;
14865 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014866 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14867 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014868 return pEntry;
14869}
Jeff Johnson295189b2012-06-20 16:38:30 -070014870eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14871 csrRoamLinkQualityIndCallback callback,
14872 void *pContext)
14873{
14874 pMac->roam.linkQualityIndInfo.callback = callback;
14875 pMac->roam.linkQualityIndInfo.context = pContext;
14876 if( NULL == callback )
14877 {
14878 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14879 }
14880 else
14881 {
14882 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014883 /* do we need to invoke the callback to notify client of initial value ?? */
14884 }
14885 return eHAL_STATUS_SUCCESS;
14886}
Jeff Johnson295189b2012-06-20 16:38:30 -070014887void csrRoamVccTrigger(tpAniSirGlobal pMac)
14888{
14889 eCsrRoamLinkQualityInd newVccLinkQuality;
14890 tANI_U32 ul_mac_loss = 0;
14891 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014892 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14893 /*-------------------------------------------------------------------------
14894 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014895 Check for a change in link quality and notify client if necessary
14896 -------------------------------------------------------------------------*/
14897 ul_mac_loss_trigger_threshold =
14898 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014899 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014900 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014901 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014902 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14903 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014904 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014905 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14906 }
14907 else
14908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014909 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014910 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14911 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014912 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14913 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014914 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14915 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014916 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014917 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14918 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014919 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014920 newVccLinkQuality );
14921
14922 /* we now invoke the callback once to notify client of initial value */
14923 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14924 pMac->roam.linkQualityIndInfo.context );
14925 //event: EVENT_WLAN_VCC
14926 }
14927 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014928 pMac->roam.vccLinkQuality = newVccLinkQuality;
14929
Jeff Johnson295189b2012-06-20 16:38:30 -070014930}
Jeff Johnson295189b2012-06-20 16:38:30 -070014931VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14932 v_U8_t rssiNotification,
14933 void * context)
14934{
14935 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14936 eCsrRoamLinkQualityInd newVccLinkQuality;
14937 // TODO : Session info unavailable
14938 tANI_U32 sessionId = 0;
14939 VOS_STATUS status = VOS_STATUS_SUCCESS;
14940 /*-------------------------------------------------------------------------
14941 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014942 Check for a change in link quality and notify client if necessary
14943 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014944 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014945 pMac->roam.configParam.vccRssiThreshold);
14946 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14947 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014948 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014949 return VOS_STATUS_SUCCESS;
14950 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014951 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14952 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014953 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014954 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14955 }
14956 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14957 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014958 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014959 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14960 }
14961 else
14962 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014963 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014964 //Set to this so the code below won't do anything
14965 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014966 VOS_ASSERT(0);
14967 }
14968
Jeff Johnson295189b2012-06-20 16:38:30 -070014969 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14970 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014971 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014972 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014974 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014975 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014976 /* we now invoke the callback once to notify client of initial value */
14977 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14978 pMac->roam.linkQualityIndInfo.context );
14979 //event: EVENT_WLAN_VCC
14980 }
14981 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014982 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014983 return status;
14984}
Jeff Johnson295189b2012-06-20 16:38:30 -070014985tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14986 tDblLinkList *pStaList,
14987 tCsrStatsClientReqInfo *pStaEntry)
14988{
14989 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014990 //if same entity requested for same set of stats with different periodicity &
14991 // callback update it
14992 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14993 {
14994
Kiet Lam64c1b492013-07-12 13:56:44 +053014995 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
14996 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014997 {
14998 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014999 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015000 return NULL;
15001 }
15002
Jeff Johnson295189b2012-06-20 16:38:30 -070015003 pNewStaEntry->callback = pStaEntry->callback;
15004 pNewStaEntry->pContext = pStaEntry->pContext;
15005 pNewStaEntry->periodicity = pStaEntry->periodicity;
15006 pNewStaEntry->requesterId = pStaEntry->requesterId;
15007 pNewStaEntry->statsMask = pStaEntry->statsMask;
15008 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15009 pNewStaEntry->pMac = pStaEntry->pMac;
15010 pNewStaEntry->staId = pStaEntry->staId;
15011 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15012
15013 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15014 }
15015 return pNewStaEntry;
15016}
15017
Jeff Johnson295189b2012-06-20 16:38:30 -070015018tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15019 tDblLinkList *pStaList,
15020 tCsrPeStatsReqInfo *pStaEntry)
15021{
15022 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015023 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15024 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015025 {
15026 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015027 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015028 return NULL;
15029 }
15030
Jeff Johnson295189b2012-06-20 16:38:30 -070015031 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15032 pNewStaEntry->numClient = pStaEntry->numClient;
15033 pNewStaEntry->periodicity = pStaEntry->periodicity;
15034 pNewStaEntry->statsMask = pStaEntry->statsMask;
15035 pNewStaEntry->pMac = pStaEntry->pMac;
15036 pNewStaEntry->staId = pStaEntry->staId;
15037 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15038 pNewStaEntry->rspPending = pStaEntry->rspPending;
15039
15040 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015041 return pNewStaEntry;
15042}
Jeff Johnson295189b2012-06-20 16:38:30 -070015043eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15044 tCsrRssiCallback callback,
15045 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15046{
15047 eHalStatus status = eHAL_STATUS_SUCCESS;
15048 vos_msg_t msg;
15049 tANI_U32 sessionId;
15050
15051 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015052 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015053 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15054 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015055 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015056 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015057 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015058 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015059 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15060
15061 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15062 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15063 pMsg->sessionId = sessionId;
15064 pMsg->staId = staId;
15065 pMsg->rssiCallback = callback;
15066 pMsg->pDevContext = pContext;
15067 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015068 msg.type = eWNI_SME_GET_RSSI_REQ;
15069 msg.bodyptr = pMsg;
15070 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015071 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15072 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015073 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015074 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015075 status = eHAL_STATUS_FAILURE;
15076 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015077 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015078 return status;
15079}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015080
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015081eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15082 tCsrSnrCallback callback,
15083 tANI_U8 staId, tCsrBssid bssId,
15084 void *pContext)
15085{
15086 eHalStatus status = eHAL_STATUS_SUCCESS;
15087 vos_msg_t msg;
15088 tANI_U32 sessionId;
15089
15090 tAniGetSnrReq *pMsg;
15091
15092 smsLog(pMac, LOG2, FL("called"));
15093
15094 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15095 if (NULL == pMsg )
15096 {
15097 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15098 return status;
15099 }
15100
15101 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15102
15103 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15104 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15105 pMsg->sessionId = sessionId;
15106 pMsg->staId = staId;
15107 pMsg->snrCallback = callback;
15108 pMsg->pDevContext = pContext;
15109 msg.type = eWNI_SME_GET_SNR_REQ;
15110 msg.bodyptr = pMsg;
15111 msg.reserved = 0;
15112
15113 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15114 {
15115 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15116 vos_mem_free((v_VOID_t *)pMsg);
15117 status = eHAL_STATUS_FAILURE;
15118 }
15119
15120 smsLog(pMac, LOG2, FL("returned"));
15121 return status;
15122}
15123
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015124#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
15125eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15126 tCsrRssiCallback callback,
15127 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15128{
15129 eHalStatus status = eHAL_STATUS_SUCCESS;
15130 tAniGetRssiReq *pMsg;
15131
Kiet Lam64c1b492013-07-12 13:56:44 +053015132 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15133 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015134 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015135 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015136 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015137 }
15138 // need to initiate a stats request to PE
15139 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15140 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15141 pMsg->staId = staId;
15142 pMsg->rssiCallback = callback;
15143 pMsg->pDevContext = pContext;
15144 pMsg->pVosContext = pVosContext;
15145 status = palSendMBMessage(pMac->hHdd, pMsg );
15146 if(!HAL_STATUS_SUCCESS(status))
15147 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015148 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015149 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015150 status = eHAL_STATUS_FAILURE;
15151 }
15152 return status;
15153}
15154#endif
15155
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015156
15157
15158#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
15159eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15160 tCsrTsmStatsCallback callback,
15161 tANI_U8 staId,
15162 tCsrBssid bssId,
15163 void *pContext,
15164 void* pVosContext,
15165 tANI_U8 tid)
15166{
15167 eHalStatus status = eHAL_STATUS_SUCCESS;
15168 tAniGetTsmStatsReq *pMsg = NULL;
15169
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015170 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15171 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015172 {
15173 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015174 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015175 }
15176 // need to initiate a stats request to PE
15177 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15178 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15179 pMsg->staId = staId;
15180 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015181 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015182 pMsg->tsmStatsCallback = callback;
15183 pMsg->pDevContext = pContext;
15184 pMsg->pVosContext = pVosContext;
15185 status = palSendMBMessage(pMac->hHdd, pMsg );
15186 if(!HAL_STATUS_SUCCESS(status))
15187 {
15188 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15189 //pMsg is freed by palSendMBMessage
15190 status = eHAL_STATUS_FAILURE;
15191 }
15192 return status;
15193}
15194#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
15195
15196
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015197/* ---------------------------------------------------------------------------
15198 \fn csrGetTLSTAState
15199 \helper function to get teh TL STA State whenever the function is called.
15200
15201 \param staId - The staID to be passed to the TL
15202 to get the relevant TL STA State
15203 \return the state as tANI_U16
15204 ---------------------------------------------------------------------------*/
15205tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15206{
15207 WLANTL_STAStateType tlSTAState;
15208 tlSTAState = WLANTL_STA_INIT;
15209
15210 //request TL for STA State
15211 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15212 {
15213 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15214 }
15215
15216 return tlSTAState;
15217}
15218
Jeff Johnson295189b2012-06-20 16:38:30 -070015219eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15220 tANI_U32 statsMask,
15221 tCsrStatsCallback callback,
15222 tANI_U32 periodicity, tANI_BOOLEAN cache,
15223 tANI_U8 staId, void *pContext)
15224{
15225 tCsrStatsClientReqInfo staEntry;
15226 tCsrStatsClientReqInfo *pStaEntry = NULL;
15227 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15228 tListElem *pEntry = NULL;
15229 tANI_BOOLEAN found = FALSE;
15230 eHalStatus status = eHAL_STATUS_SUCCESS;
15231 tANI_BOOLEAN insertInClientList = FALSE;
15232 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015233 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015234
15235 if( csrIsAllSessionDisconnected(pMac) )
15236 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015237 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015238 return eHAL_STATUS_FAILURE;
15239 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015240 if((!statsMask) && (!callback))
15241 {
15242 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015243 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015244 return eHAL_STATUS_FAILURE;
15245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015246 //for the search list method for deregister
15247 staEntry.requesterId = requesterId;
15248 staEntry.statsMask = statsMask;
15249 //requester wants to deregister or just an error
15250 if((statsMask) && (!callback))
15251 {
15252 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15253 if(!pEntry)
15254 {
15255 //msg
15256 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015257 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015258 return eHAL_STATUS_FAILURE;
15259 }
15260 else
15261 {
15262 //clean up & return
15263 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015264 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015265 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015266 pStaEntry->pPeStaEntry->numClient--;
15267 //check if we need to delete the entry from peStatsReqList too
15268 if(!pStaEntry->pPeStaEntry->numClient)
15269 {
15270 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15271 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015272 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015273
Jeff Johnson295189b2012-06-20 16:38:30 -070015274 //check if we need to stop the tl stats timer too
15275 pMac->roam.tlStatsReqInfo.numClient--;
15276 if(!pMac->roam.tlStatsReqInfo.numClient)
15277 {
15278 if(pMac->roam.tlStatsReqInfo.timerRunning)
15279 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015280 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15281 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015282 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015283 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015284 return eHAL_STATUS_FAILURE;
15285 }
15286 }
15287 pMac->roam.tlStatsReqInfo.periodicity = 0;
15288 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15289 }
15290 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015291 // Destroy the vos timer...
15292 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15293 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15294 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015295 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015296 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015297 csrRoamRemoveStatListEntry(pMac, pEntry);
15298 pStaEntry = NULL;
15299 return eHAL_STATUS_SUCCESS;
15300 }
15301 }
15302
15303 if(cache && !periodicity)
15304 {
15305 //return the cached stats
15306 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15307 }
15308 else
15309 {
15310 //add the request in the client req list
15311 staEntry.callback = callback;
15312 staEntry.pContext = pContext;
15313 staEntry.periodicity = periodicity;
15314 staEntry.pPeStaEntry = NULL;
15315 staEntry.staId = staId;
15316 staEntry.pMac = pMac;
15317 staEntry.timerExpired = FALSE;
15318
15319
Jeff Johnson295189b2012-06-20 16:38:30 -070015320 //if periodic report requested with non cached result from PE/TL
15321 if(periodicity)
15322 {
15323
15324 //if looking for stats from PE
15325 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15326 {
15327
15328 //check if same request made already & waiting for rsp
15329 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15330 periodicity, &found, staId);
15331 if(!pPeStaEntry)
15332 {
15333 //bail out, maxed out on number of req for PE
15334 return eHAL_STATUS_FAILURE;
15335 }
15336 else
15337 {
15338 staEntry.pPeStaEntry = pPeStaEntry;
15339 }
15340
15341 }
15342 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15343 if(statsMask & (1 << eCsrGlobalClassDStats))
15344 {
15345 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15346 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015347 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015348 }
15349 else
15350 {
15351
15352 //update periodicity
15353 if(pMac->roam.tlStatsReqInfo.periodicity)
15354 {
15355 pMac->roam.tlStatsReqInfo.periodicity =
15356 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15357 }
15358 else
15359 {
15360 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15361 }
15362 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15363 {
15364 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15365 }
15366
15367 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15368 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015369 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015370 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015371 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015372 //req TL for class D stats
15373 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15374 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015375 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015376 }
15377 else
15378 {
15379 //save in SME
15380 csrRoamSaveStatsFromTl(pMac, pTlStats);
15381 }
15382 vos_mem_free(pTlStats);
15383 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015384 }
15385 else
15386 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015387 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015388 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015389
Jeff Johnson295189b2012-06-20 16:38:30 -070015390 if(pMac->roam.tlStatsReqInfo.periodicity)
15391 {
15392 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015393 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15394 pMac->roam.tlStatsReqInfo.periodicity);
15395 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015396 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015397 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015398 return eHAL_STATUS_FAILURE;
15399 }
15400 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15401 }
15402 }
15403 }
15404 pMac->roam.tlStatsReqInfo.numClient++;
15405 }
15406
15407 insertInClientList = TRUE;
15408 }
15409 //if one time report requested with non cached result from PE/TL
15410 else if(!cache && !periodicity)
15411 {
15412 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15413 {
15414 //send down a req
15415 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15416 if(!HAL_STATUS_SUCCESS(status))
15417 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015418 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015419 }
15420 //so that when the stats rsp comes back from PE we respond to upper layer
15421 //right away
15422 staEntry.timerExpired = TRUE;
15423 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015424 }
15425 if(statsMask & (1 << eCsrGlobalClassDStats))
15426 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015427 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015428 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015429 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015430 //req TL for class D stats
15431 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15432 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015433 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015434 }
15435 else
15436 {
15437 //save in SME
15438 csrRoamSaveStatsFromTl(pMac, pTlStats);
15439 }
15440 vos_mem_free(pTlStats);
15441 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015442 }
15443 else
15444 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015445 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015446 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015447
15448 }
15449 //if looking for stats from TL only
15450 if(!insertInClientList)
15451 {
15452 //return the stats
15453 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15454 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015455 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015456 if(insertInClientList)
15457 {
15458 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15459 if(!pStaEntry)
15460 {
15461 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015462 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015463 return eHAL_STATUS_FAILURE;
15464 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015465 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015466 //Init & start timer if needed
15467 if(periodicity)
15468 {
15469 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15470 csrRoamStatsClientTimerHandler, pStaEntry );
15471 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15472 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015473 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015474 return eHAL_STATUS_FAILURE;
15475 }
15476 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15477 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15478 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015479 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015480 return eHAL_STATUS_FAILURE;
15481 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015482 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015483 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015484 }
15485 return eHAL_STATUS_SUCCESS;
15486}
15487
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015488#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15489
15490static tSirRetStatus
15491csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15492 tANI_U8* pBD,
15493 tANI_U8 type,
15494 tANI_U8 subType,
15495 tSirMacAddr peerAddr,
15496 tSirMacAddr selfMacAddr)
15497{
15498 tSirRetStatus statusCode = eSIR_SUCCESS;
15499 tpSirMacMgmtHdr pMacHdr;
15500
15501 /* Prepare MAC management header */
15502 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15503
15504 /* Prepare FC */
15505 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15506 pMacHdr->fc.type = type;
15507 pMacHdr->fc.subType = subType;
15508
15509 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015510 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15511 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015512
15513 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15514
15515 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015516 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15517 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015518 return statusCode;
15519} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15520
15521static tSirRetStatus
15522csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15523 tANI_U8 nChannelNum,
15524 tANI_U32 dot11mode,
15525 tSirMacAddr selfMacAddr,
15526 tANI_U8 *pFrame,
15527 tANI_U16 *pusLen)
15528{
15529 tDot11fProbeRequest pr;
15530 tANI_U32 nStatus, nBytes, nPayload;
15531 tSirRetStatus nSirStatus;
15532 /*Bcast tx*/
15533 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15534 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15535
15536
Kiet Lam64c1b492013-07-12 13:56:44 +053015537 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015538
15539 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15540
15541 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15542 {
15543 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15544 }
15545
15546
15547 if (IS_DOT11_MODE_HT(dot11mode))
15548 {
15549 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15550 }
15551
15552
15553 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15554 if ( DOT11F_FAILED( nStatus ) )
15555 {
15556 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15557 "Failed to calculate the packed size f"
15558 "or a Probe Request (0x%08x).\n", nStatus );
15559
15560
15561 nPayload = sizeof( tDot11fProbeRequest );
15562 }
15563 else if ( DOT11F_WARNED( nStatus ) )
15564 {
15565 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15566 "There were warnings while calculating"
15567 "the packed size for a Probe Request ("
15568 "0x%08x).\n", nStatus );
15569 }
15570
15571 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15572
15573 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015574 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015575
15576
15577 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015578 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015579
15580 if ( eSIR_SUCCESS != nSirStatus )
15581 {
15582 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15583 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15584 nSirStatus );
15585 return nSirStatus;
15586 }
15587
15588
15589 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15590 sizeof( tSirMacMgmtHdr ),
15591 nPayload, &nPayload );
15592 if ( DOT11F_FAILED( nStatus ) )
15593 {
15594 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15595 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15596 return eSIR_FAILURE;
15597 }
15598 else if ( DOT11F_WARNED( nStatus ) )
15599 {
15600 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015601 "There were warnings while packing a Probe Request (0x%08x).\n",
15602 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015603 }
15604
15605 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15606 return eSIR_SUCCESS;
15607}
15608
15609eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15610{
15611 vos_msg_t msg;
15612 tSirRoamOffloadScanReq *pRequestBuf;
15613 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15614 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015615 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015616 tANI_U8 *ChannelList = NULL;
15617 tANI_U32 sessionId;
15618 eHalStatus status = eHAL_STATUS_SUCCESS;
15619 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015620 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015621 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015622 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015623 tSirBssDescription *pBssDesc = NULL;
15624 tDot11fBeaconIEs *pIes = NULL;
15625 tANI_U8 minRate = 0, dataRate;
15626 tANI_U8 operationChannel;
15627
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015628 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15629
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015630 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015631 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015632 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015633 return eHAL_STATUS_FAILURE;
15634 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015635
15636 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15637 {
15638 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15639 return eHAL_STATUS_FAILURE;
15640 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015641 status = csrRoamGetSessionIdFromBSSID(pMac,
15642 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15643 &sessionId);
15644 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15645 * It is important to ensure that the command is passed down to the FW only
15646 * if the Infra Station is in a connected state.A connected station could also be
15647 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15648 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15649 * irrespective of whichever state we are in.*/
15650 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15651 (command != ROAM_SCAN_OFFLOAD_STOP))
15652 {
15653 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
15654 pMac->roam.neighborRoamInfo.neighborRoamState, command);
15655 return eHAL_STATUS_FAILURE;
15656 }
15657
15658 if ( !HAL_STATUS_SUCCESS( status ) )
15659 {
15660 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15661 return eHAL_STATUS_FAILURE;
15662 }
15663 pSession = CSR_GET_SESSION( pMac, sessionId );
krunal soni587bf012014-02-04 12:35:11 -080015664 if (NULL == pSession)
15665 {
15666 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15667 "%s:pSession is null", __func__);
15668 return eHAL_STATUS_FAILURE;
15669 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015670 pBssDesc = pSession->pConnectBssDesc;
15671 if (pBssDesc == NULL)
15672 {
15673 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: pBssDesc not found for current session", __func__);
15674 return eHAL_STATUS_FAILURE;
15675 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015676 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15677 if (NULL == pRequestBuf)
15678 {
15679 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15680 return eHAL_STATUS_FAILED_ALLOC;
15681 }
15682
Kiet Lam64c1b492013-07-12 13:56:44 +053015683 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015684 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15685 * host driver reloads, but Riva still up and running*/
15686 if(command == ROAM_SCAN_OFFLOAD_STOP)
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015687 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015688 pRequestBuf->RoamScanOffloadEnabled = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015689 /*For a STOP Command, there is no need to
15690 * go through filling up all the below parameters
15691 * since they are not required for the STOP command*/
15692 goto send_roam_scan_offload_cmd;
15693 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015694 else
15695 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015696 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15697 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015698 sizeof(tCsrBssid));
15699 pRequestBuf->ConnectedNetwork.ssId.length =
15700 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15701 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15702 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15703 pRequestBuf->ConnectedNetwork.ssId.length);
15704 pRequestBuf->ConnectedNetwork.authentication =
15705 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15706 pRequestBuf->ConnectedNetwork.encryption =
15707 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15708 pRequestBuf->ConnectedNetwork.mcencryption =
15709 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015710 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
15711 {
15712 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015713 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015714 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15715 }
15716 else
15717 {
15718 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
15719 operationChannel = pSession->connectedProfile.operationChannel;
15720
15721 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
15722 {
15723 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15724 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
15725 vos_mem_free(pRequestBuf);
15726 return eHAL_STATUS_FAILURE;
15727 }
15728 if (pIes->SuppRates.present)
15729 {
15730 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
15731 /*Check for both basic rates and extended rates.*/
15732 for (i = 0; i < pIes->SuppRates.num_rates; i++)
15733 {
15734 /*Check if the Rate is Mandatory or Not*/
15735 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
15736 && (pIes->SuppRates.rates[i] & 0x80))
15737 {
15738 /*Retrieve the actual data rate*/
15739 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
15740 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15741 if (minRate == 0)
15742 minRate = dataRate;
15743 else
15744 minRate = (minRate < dataRate) ? minRate:dataRate;
15745 }
15746 }
15747
15748 if (pIes->ExtSuppRates.present)
15749 {
15750 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
15751 {
15752 /*Check if the Rate is Mandatory or Not*/
15753 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
15754 && (pIes->ExtSuppRates.rates[i] & 0x80))
15755 {
15756 /*Retrieve the actual data rate*/
15757 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
15758 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15759 if (minRate == 0)
15760 minRate = dataRate;
15761 else
15762 minRate = (minRate < dataRate) ? minRate:dataRate;
15763 }
15764 }
15765 }
15766 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
15767 }
15768 else
15769 {
15770 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15771 "%s: Supp Rates not present in pIes", __func__);
15772 vos_mem_free(pRequestBuf);
15773 return eHAL_STATUS_FAILURE;
15774 }
15775 if (NULL != pIes)
15776 {
15777 vos_mem_free(pIes);
15778 pIes = NULL;
15779 }
15780 switch (minRate)
15781 {
15782 case 1:
15783 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
15784 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
15785 break;
15786 case 2:
15787 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
15788 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
15789 break;
15790 case 5:
15791 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
15792 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
15793 break;
15794 case 6:
15795 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15796 {
15797 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
15798 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
15799 }
15800 else
15801 {
15802 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
15803 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
15804 }
15805 break;
15806 case 11:
15807 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
15808 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
15809 break;
15810 case 12:
15811 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15812 {
15813 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
15814 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
15815 }
15816 else
15817 {
15818 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
15819 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
15820 }
15821 break;
15822 case 24:
15823 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15824 {
15825 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
15826 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
15827 }
15828 else
15829 {
15830 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
15831 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
15832 }
15833 break;
15834 default:
15835 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
15836 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15837 break;
15838 }
15839 }
15840 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15841 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
15842 operationChannel, minRate,
15843 pRequestBuf->RxSensitivityThreshold,
15844 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015845 pRequestBuf->RoamRssiDiff =
15846 pMac->roam.configParam.RoamRssiDiff;
15847 pRequestBuf->Command = command;
15848 pRequestBuf->StartScanReason = reason;
15849 pRequestBuf->NeighborScanTimerPeriod =
15850 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
15851 pRequestBuf->NeighborRoamScanRefreshPeriod =
15852 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
15853 pRequestBuf->NeighborScanChannelMinTime =
15854 pNeighborRoamInfo->cfgParams.minChannelScanTime;
15855 pRequestBuf->NeighborScanChannelMaxTime =
15856 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
15857 pRequestBuf->EmptyRefreshScanPeriod =
15858 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080015859 /* MAWC feature */
15860 pRequestBuf->MAWCEnabled =
15861 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015862#ifdef FEATURE_WLAN_CCX
15863 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
15864#endif
15865 if (
15866#ifdef FEATURE_WLAN_CCX
15867 ((pNeighborRoamInfo->isCCXAssoc) &&
15868 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
15869 eANI_BOOLEAN_FALSE)) ||
15870 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
15871#endif // CCX
15872 currChannelListInfo->numOfChannels == 0)
15873 {
15874
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015875 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
15876 * Give Preference to INI Channels.*/
15877 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
15878 {
15879 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
15880 /*The INI channels need to be filtered with respect to the current
15881 * band that is supported.*/
15882 eBand = pMac->roam.configParam.bandCapability;
15883 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015884 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015885 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15886 "Invalid band, No operation carried out (Band %d)", eBand);
15887 vos_mem_free(pRequestBuf);
15888 return eHAL_STATUS_FAILURE;
15889 }
15890 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
15891 {
15892 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
15893 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
15894 (eCSR_BAND_ALL == eBand))
15895 {
15896 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
15897 csrRoamIsChannelValid(pMac, *ChannelList) &&
15898 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
15899 {
15900 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15901 }
15902 }
15903 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015904 }
15905 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15906 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015907 }
15908 else
15909 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015910 ChannelList = pMac->scan.occupiedChannels.channelList;
15911 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
15912 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015913 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
15914 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
15915 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015916 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015917 }
15918 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015919 }
15920 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15921 /* If the profile changes as to what it was earlier, inform the FW through
15922 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
15923 * for the earlier profile and try to learn them afresh.*/
15924 if (reason == REASON_FLUSH_CHANNEL_LIST)
15925 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
15926 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015927 if (csrNeighborRoamIsNewConnectedProfile(pMac))
15928 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
15929 else
15930 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015931 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015932 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015933 }
15934#ifdef FEATURE_WLAN_CCX
15935 else
15936 {
15937 /* If CCX is enabled, and a neighbor Report is received,then
15938 * Ignore the INI Channels or the Occupied Channel List. Consider
15939 * the channels in the neighbor list sent by the CCX AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015940 if (currChannelListInfo->numOfChannels != 0)
15941 {
15942 ChannelList = currChannelListInfo->ChannelList;
15943 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015944 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015945 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15946 {
15947 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15948 }
15949 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015950 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015951 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15952 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15953 }
15954 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015955#endif
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015956 for (i = 0, j = 0; i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
15957 {
15958 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
15959 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
15960 }
15961 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15962 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
15963 pRequestBuf->ChannelCacheType,
15964 pRequestBuf->ConnectedNetwork.ChannelCount,
15965 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015966 num_channels = 0;
15967 ChannelList = NULL;
15968
15969 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070015970 host_channels = sizeof(pMac->roam.validChannelList);
15971 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015972 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070015973 ChannelList = pMac->roam.validChannelList;
15974 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015975 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070015976 else
15977 {
15978 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15979 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070015980 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070015981 return eHAL_STATUS_FAILURE;
15982 }
15983 for(i=0; i<pMac->roam.numValidChannels; i++)
15984 {
15985 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15986 {
15987 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15988 }
15989 ChannelList++;
15990 }
15991 pRequestBuf->ValidChannelCount = num_channels;
15992
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015993 pRequestBuf->MDID.mdiePresent =
15994 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
15995 pRequestBuf->MDID.mobilityDomain =
15996 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015997 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
15998
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015999 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016000 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16001 * where RFS is the RF Switching time. It is twice RFS to consider the
16002 * time to go off channel and return to the home channel. */
16003 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16004 {
16005 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16006 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16007 " Hence enforcing home away time to disable (0)",
16008 __func__, pRequestBuf->HomeAwayTime,
16009 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16010 pRequestBuf->HomeAwayTime = 0;
16011 }
16012 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016013
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016014 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16015 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16016 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16017 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16018 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16019
16020 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16021 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016022send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016023 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016024 msg.reserved = 0;
16025 msg.bodyptr = pRequestBuf;
16026 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16027 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016028 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16029 vos_mem_free(pRequestBuf);
16030 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016031 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016032 else
16033 {
16034 if (ROAM_SCAN_OFFLOAD_START == command)
16035 bRoamScanOffloadStarted = VOS_TRUE;
16036 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16037 bRoamScanOffloadStarted = VOS_FALSE;
16038 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016039
16040 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16041 return status;
16042}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016043
16044eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16045{
16046 switch(reason)
16047 {
16048 case 0:
16049 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16050 break;
16051 case REASON_OS_REQUESTED_ROAMING_NOW:
16052 csrNeighborRoamProceedWithHandoffReq(pMac);
16053 break;
16054 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016055 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 -070016056 }
16057 return eHAL_STATUS_SUCCESS;
16058}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016059#endif
16060
Jeff Johnson295189b2012-06-20 16:38:30 -070016061tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16062 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16063{
16064 tANI_BOOLEAN found = FALSE;
16065 eHalStatus status = eHAL_STATUS_SUCCESS;
16066 tCsrPeStatsReqInfo staEntry;
16067 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16068 tListElem *pStaEntry = NULL;
16069 VOS_STATUS vosStatus;
16070 tPmcPowerState powerState;
16071 *pFound = FALSE;
16072
16073 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16074 if(pStaEntry)
16075 {
16076 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16077 if(pTempStaEntry->periodicity)
16078 {
16079 pTempStaEntry->periodicity =
16080 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16081 }
16082 else
16083 {
16084 pTempStaEntry->periodicity = periodicity;
16085 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016086 pTempStaEntry->numClient++;
16087 found = TRUE;
16088 }
16089 else
16090 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016091 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016092 staEntry.numClient = 1;
16093 staEntry.periodicity = periodicity;
16094 staEntry.pMac = pMac;
16095 staEntry.rspPending = FALSE;
16096 staEntry.staId = staId;
16097 staEntry.statsMask = statsMask;
16098 staEntry.timerRunning = FALSE;
16099 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16100 if(!pTempStaEntry)
16101 {
16102 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016103 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016104 return NULL;
16105 }
16106 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016107 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16108 if(ePMC_FULL_POWER == powerState)
16109 {
16110 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16111 {
16112 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16113 }
16114 }
16115 else
16116 {
16117 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16118 {
16119 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16120 }
16121 }
16122 if(!pTempStaEntry->timerRunning)
16123 {
16124 //send down a req in case of one time req, for periodic ones wait for timer to expire
16125 if(!pTempStaEntry->rspPending &&
16126 !pTempStaEntry->periodicity)
16127 {
16128 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16129 if(!HAL_STATUS_SUCCESS(status))
16130 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016131 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016132 }
16133 else
16134 {
16135 pTempStaEntry->rspPending = TRUE;
16136 }
16137 }
16138 if(pTempStaEntry->periodicity)
16139 {
16140 if(!found)
16141 {
16142
16143 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16144 csrRoamPeStatsTimerHandler, pTempStaEntry );
16145 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16146 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016147 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016148 return NULL;
16149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016150 }
16151 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016152 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016153 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16154 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16155 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016156 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016157 return NULL;
16158 }
16159 pTempStaEntry->timerRunning = TRUE;
16160 }
16161 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016162 *pFound = found;
16163 return pTempStaEntry;
16164}
16165
Jeff Johnson295189b2012-06-20 16:38:30 -070016166/*
16167 pStaEntry is no longer invalid upon the return of this function.
16168*/
16169static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16170{
16171 if(pEntry)
16172 {
16173 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16174 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016175 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016176 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016177 }
16178 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016179
16180void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16181{
16182 tListElem *pEntry;
16183 tCsrPeStatsReqInfo *pTempStaEntry;
16184 VOS_STATUS vosStatus;
16185 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016186 if(!pEntry)
16187 {
16188 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016189 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016190 return;
16191 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016192 while( pEntry )
16193 {
16194 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016195 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16196 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016197 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016198 if(pTempStaEntry->timerRunning)
16199 {
16200 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16201 /* If we are not able to stop the timer here, just remove
16202 * the entry from the linked list. Destroy the timer object
16203 * and free the memory in the timer CB
16204 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016205 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016206 {
16207 /* the timer is successfully stopped */
16208 pTempStaEntry->timerRunning = FALSE;
16209
16210 /* Destroy the timer */
16211 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16212 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16213 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016214 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016215 }
16216 }
16217 else
16218 {
16219 // the timer could not be stopped. Hence destroy and free the
16220 // memory for the PE stat entry in the timer CB.
16221 pTempStaEntry->timerStopFailed = TRUE;
16222 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016223 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016224
16225 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16226 {
16227 // Only free the memory if we could stop the timer successfully
16228 if(!pTempStaEntry->timerStopFailed)
16229 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016230 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016231 pTempStaEntry = NULL;
16232 }
16233 break;
16234 }
16235
16236 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16237 }
16238 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016239 return;
16240}
16241
16242
Jeff Johnsone7245742012-09-05 17:12:55 -070016243void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016244{
16245
Jeff Johnsone7245742012-09-05 17:12:55 -070016246 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16247 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16248 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16249 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16250 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16251 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16252 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016253 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016254 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16255 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16256 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16257 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16258 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16259 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016260 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016261 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16262 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016263
16264}
16265
Jeff Johnson295189b2012-06-20 16:38:30 -070016266void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16267 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16268{
16269 tANI_U8 stats[500];
16270 tANI_U8 *pStats = NULL;
16271 tANI_U32 tempMask = 0;
16272 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016273 if(!callback)
16274 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016275 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016276 return;
16277 }
16278 if(!statsMask)
16279 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016280 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016281 return;
16282 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016283 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016284 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016285 while(tempMask)
16286 {
16287 if(tempMask & 1)
16288 {
16289 //new stats info from PE, fill up the stats strucutres in PMAC
16290 switch(counter)
16291 {
16292 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016293 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016294 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16295 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016296 pStats += sizeof(tCsrSummaryStatsInfo);
16297 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016298 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016299 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016300 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16301 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016302 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016303 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016304 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016305 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016306 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16307 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016308 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016309 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016310 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016311 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016312 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16313 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016314 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016315 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016316 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016317 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016318 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16319 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016320 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016321 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016322 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016323 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016324 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16325 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016326 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016327 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016328 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016329 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016330 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016331 }
16332 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016333 tempMask >>=1;
16334 counter++;
16335 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016336 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016337}
16338
Jeff Johnson295189b2012-06-20 16:38:30 -070016339eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16340{
16341 tListElem *pEntry = NULL;
16342 tListElem *pPrevEntry = NULL;
16343 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16344 eHalStatus status = eHAL_STATUS_SUCCESS;
16345 VOS_STATUS vosStatus;
16346 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016347 if(!pEntry)
16348 {
16349 //list empty
16350 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016351 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016352 return status;
16353 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016354 while( pEntry )
16355 {
16356 if(pPrevEntry)
16357 {
16358 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16359 //send up the stats report
16360 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16361 pTempStaEntry->staId, pTempStaEntry->pContext);
16362 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16363 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016364 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016365 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16366 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016367 pTempStaEntry->pPeStaEntry->numClient--;
16368 //check if we need to delete the entry from peStatsReqList too
16369 if(!pTempStaEntry->pPeStaEntry->numClient)
16370 {
16371 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16372 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016373 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016374 //check if we need to stop the tl stats timer too
16375 pMac->roam.tlStatsReqInfo.numClient--;
16376 if(!pMac->roam.tlStatsReqInfo.numClient)
16377 {
16378 if(pMac->roam.tlStatsReqInfo.timerRunning)
16379 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016380 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16381 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016382 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016383 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016384 //we will continue
16385 }
16386 }
16387 pMac->roam.tlStatsReqInfo.periodicity = 0;
16388 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16389 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016390 if (pTempStaEntry->periodicity)
16391 {
16392 //While creating StaEntry in csrGetStatistics,
16393 //Initializing and starting timer only when periodicity is set.
16394 //So Stop and Destroy timer only when periodicity is set.
16395
Jeff Johnsone7245742012-09-05 17:12:55 -070016396 vos_timer_stop( &pTempStaEntry->timer );
16397 // Destroy the vos timer...
16398 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16399 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16400 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016401 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016402 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016403 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016404
Jeff Johnson295189b2012-06-20 16:38:30 -070016405
16406 pPrevEntry = pEntry;
16407 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16408 }
16409 //the last one
16410 if(pPrevEntry)
16411 {
16412 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16413 //send up the stats report
16414 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16415 pTempStaEntry->staId, pTempStaEntry->pContext);
16416 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16417 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016418 return status;
16419
16420}
16421
Jeff Johnson295189b2012-06-20 16:38:30 -070016422eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16423 tRequestFullPowerReason *pReason,
16424 tANI_BOOLEAN *pfNeedPower )
16425{
16426 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16427 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16428 tPmcState pmcState;
16429 eHalStatus status = eHAL_STATUS_SUCCESS;
16430 // TODO : Session info unavailable
16431 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016432 if( pfNeedPower )
16433 {
16434 *pfNeedPower = eANI_BOOLEAN_FALSE;
16435 }
16436 //We only handle CSR commands
16437 if( !(eSmeCsrCommandMask & pCommand->command) )
16438 {
16439 return eHAL_STATUS_SUCCESS;
16440 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016441 //Check PMC state first
16442 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016443 switch( pmcState )
16444 {
16445 case REQUEST_IMPS:
16446 case IMPS:
16447 if( eSmeCommandScan == pCommand->command )
16448 {
16449 switch( pCommand->u.scanCmd.reason )
16450 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016451#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16452 case eCsrScanGetLfrResult:
16453#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016454 case eCsrScanGetResult:
16455 case eCsrScanBGScanAbort:
16456 case eCsrScanBGScanEnable:
16457 case eCsrScanGetScanChnInfo:
16458 //Internal process, no need for full power
16459 fNeedFullPower = eANI_BOOLEAN_FALSE;
16460 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016461 default:
16462 //Other scans are real scan, ask for power
16463 fNeedFullPower = eANI_BOOLEAN_TRUE;
16464 break;
16465 } //switch
16466 }
16467 else
16468 {
16469 //ask for power for roam and status change
16470 fNeedFullPower = eANI_BOOLEAN_TRUE;
16471 }
16472 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016473 case REQUEST_BMPS:
16474 case BMPS:
16475 case REQUEST_START_UAPSD:
16476 case UAPSD:
16477 //We treat WOWL same as BMPS
16478 case REQUEST_ENTER_WOWL:
16479 case WOWL:
16480 if( eSmeCommandRoam == pCommand->command )
16481 {
16482 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16483 tCsrScanResult *pScanResult;
16484 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016485 switch ( pCommand->u.roamCmd.roamReason )
16486 {
16487 case eCsrForcedDisassoc:
16488 case eCsrForcedDisassocMICFailure:
16489 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16490 fNeedFullPower = eANI_BOOLEAN_TRUE;
16491 break;
16492 case eCsrSmeIssuedDisassocForHandoff:
16493 case eCsrForcedDeauth:
16494 case eCsrHddIssuedReassocToSameAP:
16495 case eCsrSmeIssuedReassocToSameAP:
16496 fNeedFullPower = eANI_BOOLEAN_TRUE;
16497 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016498 case eCsrCapsChange:
16499 fNeedFullPower = eANI_BOOLEAN_TRUE;
16500 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016501 default:
16502 //Check whether the profile is already connected. If so, no need for full power
16503 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16504 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16505 {
16506 //Only need to check the first one
16507 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16508 if( pEntry )
16509 {
16510 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16511#if 0
16512 // TODO : Session Specific info pConnectBssDesc
16513 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16514 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16515 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16516 {
16517 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16518 // with Authenticating first. To force this, stop the current association (Disassociate) and
16519 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16520 // a new Association.
16521 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16522 {
16523 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16524 {
16525 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16526 //No need for full power
16527 //Set the flag so the code later can avoid to do the above
16528 //check again.
16529 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16530 break;
16531 }
16532 }
16533 }
16534#endif
16535 }
16536 }
16537 //If we are here, full power is needed
16538 fNeedFullPower = eANI_BOOLEAN_TRUE;
16539 break;
16540 }
16541 }
16542 else if( eSmeCommandWmStatusChange == pCommand->command )
16543 {
16544 //need full power for all
16545 fNeedFullPower = eANI_BOOLEAN_TRUE;
16546 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16547 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016548#ifdef FEATURE_WLAN_TDLS
16549 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16550 {
16551 //TDLS link is getting established. need full power
16552 fNeedFullPower = eANI_BOOLEAN_TRUE;
16553 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16554 }
16555#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016556 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016557 case REQUEST_STOP_UAPSD:
16558 case REQUEST_EXIT_WOWL:
16559 if( eSmeCommandRoam == pCommand->command )
16560 {
16561 fNeedFullPower = eANI_BOOLEAN_TRUE;
16562 switch ( pCommand->u.roamCmd.roamReason )
16563 {
16564 case eCsrForcedDisassoc:
16565 case eCsrForcedDisassocMICFailure:
16566 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16567 break;
16568 default:
16569 break;
16570 }
16571 }
16572 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016573 case STOPPED:
16574 case REQUEST_STANDBY:
16575 case STANDBY:
16576 case LOW_POWER:
16577 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016578 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016579 status = eHAL_STATUS_FAILURE;
16580 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016581 case FULL_POWER:
16582 case REQUEST_FULL_POWER:
16583 default:
16584 //No need to ask for full power. This has to be FULL_POWER state
16585 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016586 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016587 if( pReason )
16588 {
16589 *pReason = reason;
16590 }
16591 if( pfNeedPower )
16592 {
16593 *pfNeedPower = fNeedFullPower;
16594 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016595 return ( status );
16596}
16597
Jeff Johnson295189b2012-06-20 16:38:30 -070016598static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16599{
16600 eHalStatus status = eHAL_STATUS_SUCCESS;
16601 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16602 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016603 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016604 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16605 {
16606 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16607 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016608 return ( status );
16609}
16610
Jeff Johnson295189b2012-06-20 16:38:30 -070016611tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16612{
16613 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016614 if( pCmd )
16615 {
16616 pMac->roam.sPendingCommands++;
16617 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016618 return ( pCmd );
16619}
16620
Jeff Johnson295189b2012-06-20 16:38:30 -070016621void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16622{
16623 if (pMac->roam.sPendingCommands > 0)
16624 {
16625 //All command allocated through csrGetCommandBuffer need to
16626 //decrement the pending count when releasing.
16627 pMac->roam.sPendingCommands--;
16628 smeReleaseCommand( pMac, pCommand );
16629 }
16630 else
16631 {
16632 smsLog(pMac, LOGE, FL( "no pending commands"));
16633 VOS_ASSERT(0);
16634 }
16635}
16636
Jeff Johnson295189b2012-06-20 16:38:30 -070016637//Return SUCCESS is the command is queued, failed
16638eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16639{
16640 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016641 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16642 {
16643 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16644 pCommand->u.scanCmd.reason);
16645 return eHAL_STATUS_CSR_WRONG_STATE;
16646 }
16647
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016648 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16649 {
16650 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16651 &pCommand->Link, LL_ACCESS_LOCK);
16652 // process the command queue...
16653 smeProcessPendingQueue(pMac);
16654 status = eHAL_STATUS_SUCCESS;
16655 goto end;
16656 }
16657
Jeff Johnson295189b2012-06-20 16:38:30 -070016658 //We can call request full power first before putting the command into pending Q
16659 //because we are holding SME lock at this point.
16660 status = csrRequestFullPower( pMac, pCommand );
16661 if( HAL_STATUS_SUCCESS( status ) )
16662 {
16663 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016664 //make sure roamCmdPendingList is not empty first
16665 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16666 if( fNoCmdPending )
16667 {
16668 smePushCommand( pMac, pCommand, fHighPriority );
16669 }
16670 else
16671 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016672 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016673 //no list lock is needed since SME lock is held
16674 if( !fHighPriority )
16675 {
16676 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16677 }
16678 else {
16679 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16680 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016681 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016682 }
16683 else if( eHAL_STATUS_PMC_PENDING == status )
16684 {
16685 //no list lock is needed since SME lock is held
16686 if( !fHighPriority )
16687 {
16688 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16689 }
16690 else {
16691 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16692 }
16693 //Let caller know the command is queue
16694 status = eHAL_STATUS_SUCCESS;
16695 }
16696 else
16697 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016698 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016699 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016700 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016701 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016702end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016703 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016704}
Jeff Johnson295189b2012-06-20 16:38:30 -070016705eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16706{
16707 eHalStatus status = eHAL_STATUS_SUCCESS;
16708 tSirUpdateAPWPSIEsReq *pMsg;
16709 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16710
16711 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16712 if (NULL == pSession)
16713 {
16714 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16715 return eHAL_STATUS_FAILURE;
16716 }
16717
Jeff Johnson295189b2012-06-20 16:38:30 -070016718 do
16719 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016720 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
16721 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16722 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016723 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
16724
16725 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070016726 VOS_ASSERT(pBuf);
16727
Jeff Johnson295189b2012-06-20 16:38:30 -070016728 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016729 // transactionId
16730 *pBuf = 0;
16731 *( pBuf + 1 ) = 0;
16732 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070016733 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016734 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16735 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016736 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016737 //sessionId
16738 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016739 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016740 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070016741 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070016742 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016743 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016744 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016745 return ( status );
16746}
Jeff Johnson295189b2012-06-20 16:38:30 -070016747eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
16748{
16749 eHalStatus status = eHAL_STATUS_SUCCESS;
16750 tSirUpdateAPWPARSNIEsReq *pMsg;
16751 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016752 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16753 if (NULL == pSession)
16754 {
16755 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16756 return eHAL_STATUS_FAILURE;
16757 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016758 do
16759 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016760 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
16761 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16762 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016763 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016764 pBuf = (tANI_U8 *)&pMsg->transactionId;
16765 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016766 // transactionId
16767 *pBuf = 0;
16768 *( pBuf + 1 ) = 0;
16769 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070016770 VOS_ASSERT(pBuf);
16771
Jeff Johnson295189b2012-06-20 16:38:30 -070016772 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016773 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16774 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016775 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016776 // sessionId
16777 *pBuf++ = (tANI_U8)sessionId;
16778
16779 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016780 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070016781 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070016782 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016783 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016784 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016785 return ( status );
16786}
Jeff Johnson295189b2012-06-20 16:38:30 -070016787
16788#ifdef WLAN_FEATURE_VOWIFI_11R
16789//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
16790eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
16791{
16792 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16793 tpSirFTPreAuthReq pftPreAuthReq;
16794 tANI_U16 auth_req_len = 0;
16795 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016796 auth_req_len = sizeof(tSirFTPreAuthReq);
16797 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053016798 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070016799 {
16800 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
16801 return eHAL_STATUS_RESOURCES;
16802 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016803 // Save the SME Session ID here. We need it while processing the preauth response
16804 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016805 vos_mem_zero(pftPreAuthReq, auth_req_len);
16806
16807 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
16808 sizeof(pBssDescription->length) + pBssDescription->length);
16809
16810 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
16811
16812 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
16813
Kiet Lam64c1b492013-07-12 13:56:44 +053016814 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
16815 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
16816 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
16817 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016818
Jeff Johnson295189b2012-06-20 16:38:30 -070016819#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080016820 if (csrRoamIs11rAssoc(pMac) &&
16821 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070016822 {
16823 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053016824 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
16825 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070016826 }
16827 else
16828#endif
16829 {
16830 pftPreAuthReq->ft_ies_length = 0;
16831 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070016832 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
16833 sizeof(pBssDescription->length) + pBssDescription->length);
16834 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070016835 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
16836}
Jeff Johnson295189b2012-06-20 16:38:30 -070016837/*--------------------------------------------------------------------------
16838 * This will receive and process the FT Pre Auth Rsp from the current
16839 * associated ap.
16840 *
16841 * This will invoke the hdd call back. This is so that hdd can now
16842 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
16843 ------------------------------------------------------------------------*/
16844void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
16845{
16846 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16847 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016848#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016849 tCsrRoamInfo roamInfo;
16850#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016851
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016852#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016853 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016854 if (status != eHAL_STATUS_SUCCESS) {
16855 /*
16856 * Bail out if pre-auth was not even processed.
16857 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016858 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
16859 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016860 return;
16861 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016862#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016863 /* The below function calls/timers should be invoked only if the pre-auth is successful */
16864 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
16865 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070016866 // Implies a success
16867 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016868 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
16869 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070016870 /* No need to notify qos module if this is a non 11r roam*/
16871 if (csrRoamIs11rAssoc(pMac))
16872 {
16873 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
16874 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016875 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
16876 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016877 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
16878 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070016879 if (eHAL_STATUS_SUCCESS != status)
16880 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016881 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016882 return;
16883 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016884 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016885 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
16886 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016887 if (csrRoamIs11rAssoc(pMac))
16888 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
16889 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
16890
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016891#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16892 if (csrRoamIsCCXAssoc(pMac))
16893 {
16894 /* read TSF */
16895 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
16896
16897 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080016898 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016899 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
16900 }
16901#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016902#ifdef FEATURE_WLAN_LFR
16903 // If Legacy Fast Roaming is enabled, signal the supplicant
16904 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053016905 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016906 {
16907 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016908 vos_mem_copy((void *)&roamInfo.bssid,
16909 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016910 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
16911 }
16912
16913#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016914
16915 // Done with it, init it.
16916 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
16917}
16918#endif
16919#ifdef FEATURE_WLAN_BTAMP_UT_RF
16920void csrRoamJoinRetryTimerHandler(void *pv)
16921{
16922 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
16923 tpAniSirGlobal pMac = pInfo->pMac;
16924 tANI_U32 sessionId = pInfo->sessionId;
16925 tCsrRoamSession *pSession;
16926
16927 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16928 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016929 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016930 pSession = CSR_GET_SESSION( pMac, sessionId );
16931 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
16932 {
16933 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
16934 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016935 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016936 }
16937 }
16938 }
16939}
Jeff Johnson295189b2012-06-20 16:38:30 -070016940eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
16941{
16942 eHalStatus status = eHAL_STATUS_FAILURE;
16943 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16944
16945 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
16946 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016947 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070016948 pSession->maxRetryCount--;
16949 pSession->joinRetryTimerInfo.pMac = pMac;
16950 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016951 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
16952 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016953 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016954 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016955 }
16956 }
16957 else
16958 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016959 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070016960 pSession->maxRetryCount);
16961 }
16962
16963 return (status);
16964}
Jeff Johnson295189b2012-06-20 16:38:30 -070016965eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
16966{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016967 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070016968 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16969 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016970 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070016971 }
16972
16973 return eHAL_STATUS_SUCCESS;
16974}
16975#endif
16976
16977
16978/*
16979 pBuf points to the beginning of the message
16980 LIM packs disassoc rsp as below,
16981 messageType - 2 bytes
16982 messageLength - 2 bytes
16983 sessionId - 1 byte
16984 transactionId - 2 bytes (tANI_U16)
16985 reasonCode - 4 bytes (sizeof(tSirResultCodes))
16986 peerMacAddr - 6 bytes
16987 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
16988*/
16989static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
16990{
16991 if(pBuf && pRsp)
16992 {
16993 pBuf += 4; //skip type and length
16994 pRsp->sessionId = *pBuf++;
16995 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
16996 pBuf += 2;
16997 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
16998 pBuf += 4;
16999 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17000 }
17001}
17002
Jeff Johnsond13512a2012-07-17 11:42:19 -070017003eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17004{
17005 static uNvTables nvTables;
17006 eHalStatus status = eHAL_STATUS_SUCCESS;
17007 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17008
17009 /* read the country code from NV and use it */
17010 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17011 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017012 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17013 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017014 return status;
17015 }
17016 else
17017 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017018 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017019 status = eHAL_STATUS_FAILURE;
17020 return status;
17021 }
17022}
17023
17024eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17025{
Kiet Lam64c1b492013-07-12 13:56:44 +053017026 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017027 return eHAL_STATUS_SUCCESS;
17028}
schang86c22c42013-03-13 18:41:24 -070017029
17030eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17031{
17032 tSirSetTxPowerReq *pMsg = NULL;
17033 eHalStatus status = eHAL_STATUS_SUCCESS;
17034 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17035
17036 if (!pSession)
17037 {
17038 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17039 return eHAL_STATUS_FAILURE;
17040 }
17041
Kiet Lam64c1b492013-07-12 13:56:44 +053017042 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17043 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17044 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17045 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17046 pMsg->length = sizeof(tSirSetTxPowerReq);
17047 pMsg->mwPower = mW;
17048 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17049 sizeof(tSirMacAddr));
17050 status = palSendMBMessage(pMac->hHdd, pMsg);
17051 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017052 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017053 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17054 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017055 }
17056 return status;
17057}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017058
17059/* Returns whether a session is in VOS_STA_MODE...or not */
17060tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17061{
17062 tCsrRoamSession *pSession = NULL;
17063 pSession = CSR_GET_SESSION ( pMac, sessionId );
17064 if(!pSession)
17065 {
17066 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17067 return eANI_BOOLEAN_FALSE;
17068 }
17069 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17070 {
17071 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17072 return eANI_BOOLEAN_FALSE;
17073 }
17074 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17075 {
17076 return eANI_BOOLEAN_FALSE;
17077 }
17078 /* There is a possibility that the above check may fail,because
17079 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17080 * when it is connected.So,we may sneak through the above check even
17081 * if we are not a STA mode INFRA station. So, if we sneak through
17082 * the above condition, we can use the following check if we are
17083 * really in STA Mode.*/
17084
17085 if ( NULL != pSession->pCurRoamProfile )
17086 {
17087 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17088 {
17089 return eANI_BOOLEAN_TRUE;
17090 } else {
17091 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17092 return eANI_BOOLEAN_FALSE;
17093 }
17094 }
17095
17096 return eANI_BOOLEAN_FALSE;
17097}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017098
17099#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17100eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17101 tCsrHandoffRequest *pHandoffInfo)
17102{
17103 eHalStatus status = eHAL_STATUS_SUCCESS;
17104 vos_msg_t msg;
17105
17106 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017107 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17108 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017109 {
17110 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017111 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017112 }
17113 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17114 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17115 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17116 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017117 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017118 pHandoffInfo->bssid,
17119 6);
17120 msg.type = eWNI_SME_HANDOFF_REQ;
17121 msg.bodyptr = pMsg;
17122 msg.reserved = 0;
17123 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17124 {
17125 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017126 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017127 status = eHAL_STATUS_FAILURE;
17128 }
17129 return status;
17130}
17131#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017132
17133#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
17134/* ---------------------------------------------------------------------------
17135 \fn csrSetCCKMIe
17136 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17137 data structure and this IE will be packed inside reassociation request
17138 \param pMac - pMac global structure
17139 \param sessionId - Current session id
17140 \param pCckmIe - pointer to CCKM IE data
17141 \param ccKmIeLen - length of the CCKM IE
17142 \- return Success or failure
17143 -------------------------------------------------------------------------*/
17144VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17145 const tANI_U8 *pCckmIe,
17146 const tANI_U8 ccKmIeLen)
17147{
17148 eHalStatus status = eHAL_STATUS_SUCCESS;
17149 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17150
17151 if (!pSession)
17152 {
17153 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17154 return eHAL_STATUS_FAILURE;
17155 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017156 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017157 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17158 return status;
17159}
17160
17161/* ---------------------------------------------------------------------------
17162 \fn csrRoamReadTSF
17163 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17164 probe response reception from the hand off AP to arrive at the latest TSF value.
17165 \param pMac - pMac global structure
17166 \param pTimestamp - output TSF timestamp
17167 \- return Success or failure
17168 -------------------------------------------------------------------------*/
17169VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17170{
17171 eHalStatus status = eHAL_STATUS_SUCCESS;
17172 tCsrNeighborRoamBSSInfo handoffNode;
17173 tANI_U32 timer_diff = 0;
17174 tANI_U32 timeStamp[2];
17175 tpSirBssDescription pBssDescription = NULL;
17176
17177 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17178 pBssDescription = handoffNode.pBssDescription;
17179
17180 // Get the time diff in milli seconds
17181 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17182 // Convert msec to micro sec timer
17183 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17184
17185 timeStamp[0] = pBssDescription->timeStamp[0];
17186 timeStamp[1] = pBssDescription->timeStamp[1];
17187
17188 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17189
Kiet Lamf2f201e2013-11-16 21:24:16 +053017190 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017191 sizeof (tANI_U32) * 2);
17192 return status;
17193}
17194
17195#endif /*FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
17196