blob: f48bd7356e3169813ede1a4081bf238f659a1d33 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
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
50 Copyright (C) 2008 Qualcomm, Incorporated
51
52
53 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070054/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070055 EDIT HISTORY FOR FILE
56
Jeff Johnson295189b2012-06-20 16:38:30 -070057 This section contains comments describing changes made to the module.
58 Notice that changes are listed in reverse chronological order.
59
Jeff Johnson295189b2012-06-20 16:38:30 -070060 when who what, where, why
61---------- --- --------------------------------------------------------
6206/03/10 js Added support to hostapd driven
63 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070064===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "aniGlobal.h" //for tpAniSirGlobal
66#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070067#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070068#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070069#include "palApi.h"
70#include "csrInsideApi.h"
71#include "smsDebug.h"
72#include "logDump.h"
73#include "smeQosInternal.h"
74#include "wlan_qct_tl.h"
75#include "smeInside.h"
76#include "vos_diag_core_event.h"
77#include "vos_diag_core_log.h"
78#include "csrApi.h"
79#include "pmc.h"
80#include "vos_nvitem.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070081#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
82#include "csrNeighborRoam.h"
83#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070084#if defined(FEATURE_WLAN_CCX) && !defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson295189b2012-06-20 16:38:30 -070085#include "csrCcx.h"
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070086#endif /* FEATURE_WLAN_CCX && !FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070087#define CSR_NUM_IBSS_START_CHANNELS_50 4
88#define CSR_NUM_IBSS_START_CHANNELS_24 3
89#define CSR_DEF_IBSS_START_CHANNEL_50 36
90#define CSR_DEF_IBSS_START_CHANNEL_24 1
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080091#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 -070092#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
93/*---------------------------------------------------------------------------
94 OBIWAN recommends [8 10]% : pick 9%
95---------------------------------------------------------------------------*/
96#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070097/*---------------------------------------------------------------------------
98 OBIWAN recommends -85dBm
99---------------------------------------------------------------------------*/
100#define CSR_VCC_RSSI_THRESHOLD 80
101#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
102#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
103#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
104#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -0700105//We use constatnt 4 here
106//This macro returns true when higher AC parameter is bigger than lower AC for a difference
107//The bigger the number, the less chance of TX
108//It must put lower AC as the first parameter.
109#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700110//Flag to send/do not send disassoc frame over the air
111#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700112#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700113#define MAX_CB_VALUE_IN_INI (2)
114
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700115#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
116static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
117#endif
118
Jeff Johnson295189b2012-06-20 16:38:30 -0700119/*--------------------------------------------------------------------------
120 Static Type declarations
121 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800122static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800123
Jeff Johnson295189b2012-06-20 16:38:30 -0700124/*--------------------------------------------------------------------------
125 Type declarations
126 ------------------------------------------------------------------------*/
127#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700128int diagAuthTypeFromCSRType(eCsrAuthType authType)
129{
130 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700131 switch(authType)
132 {
133 case eCSR_AUTH_TYPE_SHARED_KEY:
134 n = AUTH_SHARED;
135 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700136 case eCSR_AUTH_TYPE_WPA:
137 n = AUTH_WPA_EAP;
138 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700139 case eCSR_AUTH_TYPE_WPA_PSK:
140 n = AUTH_WPA_PSK;
141 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700142 case eCSR_AUTH_TYPE_RSN:
143 n = AUTH_WPA2_EAP;
144 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700145 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700146#ifdef WLAN_FEATURE_11W
147 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
148#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700149 n = AUTH_WPA2_PSK;
150 break;
151#ifdef FEATURE_WLAN_WAPI
152 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
153 n = AUTH_WAPI_CERT;
154 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
156 n = AUTH_WAPI_PSK;
157 break;
158#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 default:
160 break;
161 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 return (n);
163}
Jeff Johnson295189b2012-06-20 16:38:30 -0700164int diagEncTypeFromCSRType(eCsrEncryptionType encType)
165{
166 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 switch(encType)
168 {
169 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
170 case eCSR_ENCRYPT_TYPE_WEP40:
171 n = ENC_MODE_WEP40;
172 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700173 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
174 case eCSR_ENCRYPT_TYPE_WEP104:
175 n = ENC_MODE_WEP104;
176 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700177 case eCSR_ENCRYPT_TYPE_TKIP:
178 n = ENC_MODE_TKIP;
179 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 case eCSR_ENCRYPT_TYPE_AES:
181 n = ENC_MODE_AES;
182 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700183#ifdef FEATURE_WLAN_WAPI
184 case eCSR_ENCRYPT_TYPE_WPI:
185 n = ENC_MODE_SMS4;
186 break;
187#endif /* FEATURE_WLAN_WAPI */
188 default:
189 break;
190 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700191 return (n);
192}
Jeff Johnson295189b2012-06-20 16:38:30 -0700193#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700194static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
195static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700196static void initConfigParam(tpAniSirGlobal pMac);
197static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
198 eCsrRoamCompleteResult Result, void *Context );
199static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
200 tCsrRoamProfile *pProfile,
201 tANI_BOOLEAN *pfSameIbss );
202static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
203static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700204 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
205static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700206eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
207static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
208eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
209eHalStatus csrRoamClose(tpAniSirGlobal pMac);
210void csrRoamMICErrorTimerHandler(void *pv);
211void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
212tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
213
214static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
215static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
216static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700217eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
218eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
219static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700220static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700221static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700222static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
223eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
224 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
225 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
226 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
227 tANI_U8 *pKeyRsc );
228static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
229 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
230 tCsrRoamProfile *pProfile );
231void csrRoamStatisticsTimerHandler(void *pv);
232void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700233static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
234VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
235 v_U8_t rssiNotification,
236 void * context);
237static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
238void csrRoamVccTrigger(tpAniSirGlobal pMac);
239eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
240/*
241 pStaEntry is no longer invalid upon the return of this function.
242*/
243static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700244static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700245static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700246tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
247 tDblLinkList *pStaList,
248 tCsrStatsClientReqInfo *pStaEntry);
249void csrRoamStatsClientTimerHandler(void *pv);
250tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
251 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
252void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
253 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700254void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700255void csrRoamTlStatsTimerHandler(void *pv);
256void csrRoamPeStatsTimerHandler(void *pv);
257tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
258void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
259tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
260eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
261static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
262static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
263static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
264static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
265 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
266//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
267static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
268void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
269#ifdef FEATURE_WLAN_BTAMP_UT_RF
270void csrRoamJoinRetryTimerHandler(void *pv);
271#endif
272extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700273extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700274static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700275void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700276
277//Initialize global variables
278static void csrRoamInitGlobals(tpAniSirGlobal pMac)
279{
280 if(pMac)
281 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800282 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
283 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700284 }
285 return;
286}
287
Jeff Johnson295189b2012-06-20 16:38:30 -0700288static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
289{
290 if(pMac)
291 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800292 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700293 }
294 return;
295}
Jeff Johnson295189b2012-06-20 16:38:30 -0700296eHalStatus csrOpen(tpAniSirGlobal pMac)
297{
298 eHalStatus status = eHAL_STATUS_SUCCESS;
299 static uNvTables nvTables;
300 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700301 v_REGDOMAIN_t regId;
302 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;
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
324 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
325 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530326 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
327 WNI_CFG_COUNTRY_CODE_LEN);
328 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 }
330 else
331 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800332 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700333 //hardcoded for now
334 pMac->scan.countryCodeDefault[0] = 'U';
335 pMac->scan.countryCodeDefault[1] = 'S';
336 pMac->scan.countryCodeDefault[2] = 'I';
337 //status = eHAL_STATUS_SUCCESS;
338 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700339 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Jeff Johnson295189b2012-06-20 16:38:30 -0700340 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault, &regId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700341 WDA_SetRegDomain(pMac, regId);
342 pMac->scan.domainIdDefault = regId;
343 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530344 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
345 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700346 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700347 }while(0);
348
349 return (status);
350}
351
Jeff Johnson295189b2012-06-20 16:38:30 -0700352eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
353{
354 eHalStatus status = eHAL_STATUS_SUCCESS;
355 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
356 v_REGDOMAIN_t regId;
357 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700358 if(NULL == apCntryCode)
359 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800360 smsLog( pMac, LOGW, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700361 return eHAL_STATUS_FAILURE;
362 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700363 smsLog( pMac, LOGW, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700364 /* To get correct Regulatory domain from NV table
365 * 2 character Country code should be used
366 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700367 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
368/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700370
371 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
372 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800373 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700374 return eHAL_STATUS_FAILURE;
375 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700376*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700377 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId);
378 if (status != eHAL_STATUS_SUCCESS)
379 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700380 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700381 return status;
382 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700383 status = WDA_SetRegDomain(hHal, regId);
384 if (status != eHAL_STATUS_SUCCESS)
385 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700386 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 return status;
388 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 pMac->scan.domainIdDefault = regId;
390 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530392 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
393
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530395 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
396
Jeff Johnson295189b2012-06-20 16:38:30 -0700397 /* If 2 bytes country code, 3rd byte must be filled with space */
398 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
399 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530400 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700401 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530402 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
403 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700404 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700405 return status;
406}
Jeff Johnson295189b2012-06-20 16:38:30 -0700407eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
408{
409 eHalStatus status = eHAL_STATUS_SUCCESS;
410 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
411 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530412 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
413 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700414 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
415 {
416 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
417 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
418 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
419 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
420 }
421 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
422
423 return status;
424}
Jeff Johnson295189b2012-06-20 16:38:30 -0700425eHalStatus csrClose(tpAniSirGlobal pMac)
426{
427 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800428
Jeff Johnson295189b2012-06-20 16:38:30 -0700429 csrRoamClose(pMac);
430 csrScanClose(pMac);
431 csrLLClose(&pMac->roam.statsClientReqList);
432 csrLLClose(&pMac->roam.peStatsReqList);
433 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700434 /* DeInit Globals */
435 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700436 return (status);
437}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530438
439eHalStatus csrUpdateChannelList(tCsrScanStruct *pScan)
440{
441 tSirUpdateChanList *pChanList;
442 tANI_U8 numChan = pScan->base20MHzChannels.numChannels;
443 tANI_U32 bufLen = sizeof(tSirUpdateChanList) +
444 (sizeof(tSirUpdateChanParam) * (numChan - 1));
445 vos_msg_t msg;
446 tANI_U8 i;
447
448 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
449 if (!pChanList)
450 {
451 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
452 "Failed to allocate memory for tSirUpdateChanList");
453 return eHAL_STATUS_FAILED_ALLOC;
454 }
455
456 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
457 msg.reserved = 0;
458 msg.bodyptr = pChanList;
459 pChanList->numChan = numChan;
460 for (i = 0; i < pChanList->numChan; i++)
461 {
462 pChanList->chanParam[i].chanId = pScan->defaultPowerTable[i].chanId;
463 pChanList->chanParam[i].pwr = pScan->defaultPowerTable[i].pwr;
464 }
465
466 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
467 {
468 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
469 "%s: Failed to post msg to WDA", __func__);
470 vos_mem_free(pChanList);
471 return eHAL_STATUS_FAILURE;
472 }
473
474 return eHAL_STATUS_SUCCESS;
475}
476
Jeff Johnson295189b2012-06-20 16:38:30 -0700477eHalStatus csrStart(tpAniSirGlobal pMac)
478{
479 eHalStatus status = eHAL_STATUS_SUCCESS;
480 tANI_U32 i;
481
482 do
483 {
484 //save the global vos context
485 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
486 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
487 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
488
489 status = csrRoamStart(pMac);
490 if(!HAL_STATUS_SUCCESS(status)) break;
491 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
492 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
493 if(!HAL_STATUS_SUCCESS(status)) break;
494 pMac->roam.sPendingCommands = 0;
495 csrScanEnable(pMac);
496#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
497 status = csrNeighborRoamInit(pMac);
498#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
499 pMac->roam.tlStatsReqInfo.numClient = 0;
500 pMac->roam.tlStatsReqInfo.periodicity = 0;
501 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
502 //init the link quality indication also
503 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
504 if(!HAL_STATUS_SUCCESS(status))
505 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800506 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 break;
508 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530509
510 if (pMac->fScanOffload)
511 {
512 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
513 "Scan offload is enabled, update default chan list");
514 status = csrUpdateChannelList(&pMac->scan);
515 }
516
Jeff Johnson295189b2012-06-20 16:38:30 -0700517 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700518#if defined(ANI_LOGDUMP)
519 csrDumpInit(pMac);
520#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700521 return (status);
522}
523
Jeff Johnson295189b2012-06-20 16:38:30 -0700524eHalStatus csrStop(tpAniSirGlobal pMac)
525{
526 tANI_U32 sessionId;
527 tANI_U32 i;
528
529 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
530 {
531 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
532 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 csrScanDisable(pMac);
534 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
535 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700536 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
537
538#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
539 csrNeighborRoamClose(pMac);
540#endif
541 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700542 // deregister from PMC since we register during csrStart()
543 // (ignore status since there is nothing we can do if it fails)
544 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 //Reset the domain back to the deault
546 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800547 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700548
549 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
550 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530551 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700552 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
553 }
554
555 return (eHAL_STATUS_SUCCESS);
556}
557
Jeff Johnson295189b2012-06-20 16:38:30 -0700558eHalStatus csrReady(tpAniSirGlobal pMac)
559{
560 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700561 csrScanGetSupportedChannels( pMac );
562 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
563 //use it to init the background scan list
564 csrInitBGScanChannelList(pMac);
565 /* HDD issues the init scan */
566 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800567 /* If the gScanAgingTime is set to '0' then scan results aging timeout
568 based on timer feature is not enabled*/
569 if(0 != pMac->scan.scanResultCfgAgingTime )
570 {
571 csrScanStartResultCfgAgingTimer(pMac);
572 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 //Store the AC weights in TL for later use
574 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700575 status = csrInitChannelList( pMac );
576 if ( ! HAL_STATUS_SUCCESS( status ) )
577 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800578 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700579 status );
580 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700581 return (status);
582}
Jeff Johnson295189b2012-06-20 16:38:30 -0700583void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
584{
585 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
587 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
588}
Jeff Johnson295189b2012-06-20 16:38:30 -0700589void csrSetGlobalCfgs( tpAniSirGlobal pMac )
590{
Jeff Johnsone7245742012-09-05 17:12:55 -0700591
Jeff Johnson295189b2012-06-20 16:38:30 -0700592 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
593 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
594 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
595 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
596 NULL, eANI_BOOLEAN_FALSE);
597 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700598 /* 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
599 * Once session is established we will use the session related params stored in PE session for CB mode
600 */
601 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
603
604 //Update the operating mode to configured value during initialization,
605 //So that client can advertise full capabilities in Probe request frame.
606 csrSetDefaultDot11Mode( pMac );
607}
608
Jeff Johnson295189b2012-06-20 16:38:30 -0700609eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
610{
611 eHalStatus status = eHAL_STATUS_SUCCESS;
612 tANI_U32 i;
613 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 do
615 {
616 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
617 {
618 pSession = CSR_GET_SESSION( pMac, i );
619 pSession->roamingTimerInfo.pMac = pMac;
620 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
621 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700622 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
623 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530624 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
625 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700626 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530627 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800629 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 break;
631 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530632 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
633 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
634 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700635 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800636 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 return eHAL_STATUS_FAILURE;
638 }
639 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 return (status);
641}
642
Jeff Johnson295189b2012-06-20 16:38:30 -0700643eHalStatus csrRoamClose(tpAniSirGlobal pMac)
644{
645 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700646 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
647 {
648 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
649 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530650 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
651 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
652 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
653 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700654 return (eHAL_STATUS_SUCCESS);
655}
656
Jeff Johnson295189b2012-06-20 16:38:30 -0700657eHalStatus csrRoamStart(tpAniSirGlobal pMac)
658{
659 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 return (eHAL_STATUS_SUCCESS);
661}
662
Jeff Johnson295189b2012-06-20 16:38:30 -0700663void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
664{
665 csrRoamStopRoamingTimer(pMac, sessionId);
666 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
667 csrRoamDeregStatisticsReq(pMac);
668}
Jeff Johnson295189b2012-06-20 16:38:30 -0700669eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
670{
671 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800672 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 {
674 status = eHAL_STATUS_SUCCESS;
675 *pState = pMac->roam.roamSession[sessionId].connectState;
676 }
677 return (status);
678}
679
Jeff Johnson295189b2012-06-20 16:38:30 -0700680eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
681{
682 eHalStatus status = eHAL_STATUS_FAILURE;
683 tANI_U32 size = 0;
684 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700685
686 if(!pSession)
687 {
688 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
689 return eHAL_STATUS_FAILURE;
690 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700691
692 if(pProfile)
693 {
694 if(pSession->pConnectBssDesc)
695 {
696 do
697 {
698 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
699 if(size)
700 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530701 pProfile->pBssDesc = vos_mem_malloc(size);
702 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530704 vos_mem_copy(pProfile->pBssDesc,
705 pSession->pConnectBssDesc, size);
706 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700707 }
708 else
709 break;
710 }
711 else
712 {
713 pProfile->pBssDesc = NULL;
714 }
715 pProfile->AuthType = pSession->connectedProfile.AuthType;
716 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
717 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
718 pProfile->BSSType = pSession->connectedProfile.BSSType;
719 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
720 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530721 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
722 sizeof(tCsrBssid));
723 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
724 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700725#ifdef WLAN_FEATURE_VOWIFI_11R
726 if (pSession->connectedProfile.MDID.mdiePresent)
727 {
728 pProfile->MDID.mdiePresent = 1;
729 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
730 }
731 else
732 {
733 pProfile->MDID.mdiePresent = 0;
734 pProfile->MDID.mobilityDomain = 0;
735 }
736#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700737#ifdef FEATURE_WLAN_CCX
738 pProfile->isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 if (csrIsAuthTypeCCX(pSession->connectedProfile.AuthType))
740 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530741 vos_mem_copy (pProfile->ccxCckmInfo.krk,
742 pSession->connectedProfile.ccxCckmInfo.krk,
743 CSR_KRK_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700744 pProfile->ccxCckmInfo.reassoc_req_num=
745 pSession->connectedProfile.ccxCckmInfo.reassoc_req_num;
746 pProfile->ccxCckmInfo.krk_plumbed =
747 pSession->connectedProfile.ccxCckmInfo.krk_plumbed;
748 }
749#endif
750 }while(0);
751 }
752 }
753
754 return (status);
755}
756
Jeff Johnson295189b2012-06-20 16:38:30 -0700757eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
758{
759 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700760
761 if((csrIsConnStateConnected(pMac, sessionId)) ||
762 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 {
764 if(pProfile)
765 {
766 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
767 }
768 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 return (status);
770}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700771
Jeff Johnson295189b2012-06-20 16:38:30 -0700772eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
773{
774 eHalStatus status = eHAL_STATUS_SUCCESS;
775
Kiet Lam64c1b492013-07-12 13:56:44 +0530776 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700777 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530778 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700779 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530780 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700781 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530782 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700783 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530784 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
785
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
787 return (status);
788}
789
Jeff Johnson295189b2012-06-20 16:38:30 -0700790static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
791{
792 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 if( pConnectedInfo->pbFrames )
794 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530795 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 pConnectedInfo->pbFrames = NULL;
797 }
798 pConnectedInfo->nBeaconLength = 0;
799 pConnectedInfo->nAssocReqLength = 0;
800 pConnectedInfo->nAssocRspLength = 0;
801 pConnectedInfo->staId = 0;
802#ifdef WLAN_FEATURE_VOWIFI_11R
803 pConnectedInfo->nRICRspLength = 0;
804#endif
805#ifdef FEATURE_WLAN_CCX
806 pConnectedInfo->nTspecIeLength = 0;
807#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700808 return ( status );
809}
810
Jeff Johnson295189b2012-06-20 16:38:30 -0700811
812
Jeff Johnsone7245742012-09-05 17:12:55 -0700813
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700814void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
815{
816 csrReinitPreauthCmd(pMac, pCommand);
817 csrReleaseCommand( pMac, pCommand );
818}
819
Jeff Johnson295189b2012-06-20 16:38:30 -0700820void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
821{
822 csrReinitRoamCmd(pMac, pCommand);
823 csrReleaseCommand( pMac, pCommand );
824}
825
Jeff Johnson295189b2012-06-20 16:38:30 -0700826void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
827{
828 csrReinitScanCmd(pMac, pCommand);
829 csrReleaseCommand( pMac, pCommand );
830}
831
Jeff Johnson295189b2012-06-20 16:38:30 -0700832void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
833{
834 csrReinitWmStatusChangeCmd(pMac, pCommand);
835 csrReleaseCommand( pMac, pCommand );
836}
837
Jeff Johnson295189b2012-06-20 16:38:30 -0700838void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
839{
Kiet Lam64c1b492013-07-12 13:56:44 +0530840 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700841}
842
Jeff Johnson295189b2012-06-20 16:38:30 -0700843void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
844{
Kiet Lam64c1b492013-07-12 13:56:44 +0530845 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700846}
847
Jeff Johnson295189b2012-06-20 16:38:30 -0700848void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
849{
850 csrReinitSetKeyCmd(pMac, pCommand);
851 csrReleaseCommand( pMac, pCommand );
852}
Jeff Johnson295189b2012-06-20 16:38:30 -0700853void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
854{
855 csrReinitRemoveKeyCmd(pMac, pCommand);
856 csrReleaseCommand( pMac, pCommand );
857}
Jeff Johnson295189b2012-06-20 16:38:30 -0700858void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
859{
860
861 if( eSmeCsrCommandMask & pCommand->command )
862 {
863 switch (pCommand->command)
864 {
865 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800866 // We need to inform the requester before dropping the scan command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800867 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback 0x%X",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700868 __func__, pCommand->u.scanCmd.reason, (unsigned int)pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700869 if (NULL != pCommand->u.scanCmd.callback)
870 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800871 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700872 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
873 }
874 csrReleaseCommandScan( pMac, pCommand );
875 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 case eSmeCommandRoam:
877 csrReleaseCommandRoam( pMac, pCommand );
878 break;
879
880 case eSmeCommandWmStatusChange:
881 csrReleaseCommandWmStatusChange( pMac, pCommand );
882 break;
883
884 case eSmeCommandSetKey:
885 csrReleaseCommandSetKey( pMac, pCommand );
886 break;
887
888 case eSmeCommandRemoveKey:
889 csrReleaseCommandRemoveKey( pMac, pCommand );
890 break;
891
892 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800893 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700894 csrReleaseCommand( pMac, pCommand );
895 break;
896 }
897 }
898}
899
Jeff Johnson295189b2012-06-20 16:38:30 -0700900void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
901{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800902 smsLog( pMac, LOG1, " CSR RoamSubstate: [ %d <== %d ]", NewSubstate, pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700903
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 if(pMac->roam.curSubState[sessionId] == NewSubstate)
905 {
906 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700907 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700908 pMac->roam.curSubState[sessionId] = NewSubstate;
909}
910
Jeff Johnson295189b2012-06-20 16:38:30 -0700911eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
912{
913 eCsrRoamState PreviousState;
914
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +0530915 smsLog( pMac, LOG1, "CSR RoamState[%hu]: [ %d <== %d ]", sessionId,
916 NewRoamState, pMac->roam.curState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -0700917
918 PreviousState = pMac->roam.curState[sessionId];
919
920 if ( NewRoamState != pMac->roam.curState[sessionId] )
921 {
922 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
923 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
924 {
925 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
926 }
927
928 pMac->roam.curState[sessionId] = NewRoamState;
929 }
930 return( PreviousState );
931}
932
Jeff Johnson295189b2012-06-20 16:38:30 -0700933void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_U8 catOffset)
934{
935 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 if(catOffset)
937 {
938 pMac->roam.configParam.bCatRssiOffset = catOffset;
939 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
940 {
941 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)CSR_BEST_RSSI_VALUE - (int)(i * catOffset);
942 }
943 }
944}
945
Jeff Johnson295189b2012-06-20 16:38:30 -0700946static void initConfigParam(tpAniSirGlobal pMac)
947{
948 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -0700949 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
950 pMac->roam.configParam.channelBondingMode24GHz = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
951 pMac->roam.configParam.channelBondingMode5GHz = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700952
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
954 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
955 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
956 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
957 pMac->roam.configParam.HeartbeatThresh24 = 40;
958 pMac->roam.configParam.HeartbeatThresh50 = 40;
959 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
960 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
961 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700962 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 pMac->roam.configParam.RTSThreshold = 2346;
964 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
965 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
966 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
967 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
968 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
969 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
970 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
971 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
972 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
973 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
974 {
975 pMac->roam.configParam.BssPreferValue[i] = i;
976 }
977 csrAssignRssiForCategory(pMac, CSR_DEFAULT_RSSI_DB_GAP);
978 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
979 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
980 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
982 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
983 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
984 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
985 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
986 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800987 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
988 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -0700989 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700990#ifdef WLAN_AP_STA_CONCURRENCY
991 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
992 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
993 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
994 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
995 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -0700996 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
997 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -0700998#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1000 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1001 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1002 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001003#ifdef WLAN_FEATURE_VOWIFI_11R
1004 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1005#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001006#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1007 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1008 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1009 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1010 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1011 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1012 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1013 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1014 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1015 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1016 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1017 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001018 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001019#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001020#ifdef WLAN_FEATURE_11AC
1021 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1022#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001023
1024 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1025 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001026
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001027 //Remove this code once SLM_Sessionization is supported
1028 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001029 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001030
Jeff Johnsone7245742012-09-05 17:12:55 -07001031}
Jeff Johnson295189b2012-06-20 16:38:30 -07001032eCsrBand csrGetCurrentBand(tHalHandle hHal)
1033{
1034 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1035 return pMac->roam.configParam.bandCapability;
1036}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001037
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001038
1039#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
1040/*
1041 This function flushes the roam scan cache
1042*/
1043eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1044{
1045 eHalStatus status = eHAL_STATUS_SUCCESS;
1046 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1047
1048 /* Free up the memory first (if required) */
1049 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1050 {
1051 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1052 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1053 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1054 }
1055 return status;
1056}
1057#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
1058
1059
Srinivas Girigowdade697412013-02-14 16:31:48 -08001060#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001061/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001062 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001063*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001064eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001065{
1066 eHalStatus status = eHAL_STATUS_SUCCESS;
1067 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1068
1069 /* Free up the memory first (if required) */
1070 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1071 {
1072 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1073 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001074 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001075 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001076 return status;
1077}
1078
1079
1080
1081/*
1082 This function flushes the roam scan cache and creates fresh cache
1083 based on the input channel list
1084*/
1085eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1086 const tANI_U8 *pChannelList,
1087 const tANI_U8 numChannels)
1088{
1089 eHalStatus status = eHAL_STATUS_SUCCESS;
1090 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1091
Srinivas Girigowdade697412013-02-14 16:31:48 -08001092 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1093
1094 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1095 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1096
1097 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1098 {
1099 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1100 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1101 return eHAL_STATUS_RESOURCES;
1102 }
1103
1104 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301105 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1106 pChannelList,
1107 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001108 return status;
1109}
1110
1111/* This function modifies the bgscan channel list set via config ini or
1112 runtime, whenever the band changes.
1113 if the band is auto, then no operation is performed on the channel list
1114 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1115 if the band is 5G, then make sure channel list contains only 5G valid channels
1116*/
1117eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1118 eCsrBand eBand)
1119{
1120 eHalStatus status = eHAL_STATUS_SUCCESS;
1121 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1122 tANI_U8 outNumChannels = 0;
1123 tANI_U8 inNumChannels = 0;
1124 tANI_U8 *inPtr = NULL;
1125 tANI_U8 i = 0;
1126 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1127
1128 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1129
1130 {
1131 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1132 "No update required for channel list "
1133 "either cfg.ini channel list is not set up or "
1134 "auto band (Band %d)", eBand);
1135 return status;
1136 }
1137
1138 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1139 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1140 if (eCSR_BAND_24 == eBand)
1141 {
1142 for (i = 0; i < inNumChannels; i++)
1143 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001144 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001145 {
1146 ChannelList[outNumChannels++] = inPtr[i];
1147 }
1148 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001149 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001150 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001151 }
1152 else if (eCSR_BAND_5G == eBand)
1153 {
1154 for (i = 0; i < inNumChannels; i++)
1155 {
1156 /* Add 5G Non-DFS channel */
1157 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001158 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001159 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1160 {
1161 ChannelList[outNumChannels++] = inPtr[i];
1162 }
1163 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001164 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001165 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001166 }
1167 else if (eCSR_BAND_ALL == eBand)
1168 {
1169 for (i = 0; i < inNumChannels; i++)
1170 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001171 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001172 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1173 {
1174 ChannelList[outNumChannels++] = inPtr[i];
1175 }
1176 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001177 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001178 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001179 }
1180 else
1181 {
1182 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1183 "Invalid band, No operation carried out (Band %d)", eBand);
1184 status = eHAL_STATUS_INVALID_PARAMETER;
1185 }
1186
1187 return status;
1188}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001189#endif
1190
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001191#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
1192/* This function modifies the roam scan channel list as per AP neighbor
1193 report; AP neighbor report may be empty or may include only other AP
1194 channels; in any case, we merge the channel list with the learned occupied
1195 channels list.
1196 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1197 if the band is 5G, then make sure channel list contains only 5G valid channels
1198*/
1199eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1200 tANI_U8 *pChannelList,
1201 tANI_U8 numChannels,
1202 const eCsrBand eBand)
1203{
1204 eHalStatus status = eHAL_STATUS_SUCCESS;
1205 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1206 tANI_U8 outNumChannels = 0;
1207 tANI_U8 inNumChannels = numChannels;
1208 tANI_U8 *inPtr = pChannelList;
1209 tANI_U8 i = 0;
1210 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1211 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1212 tANI_U8 mergedOutputNumOfChannels = 0;
1213 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1214
1215 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1216 * report Channels. This increases the chances of the DUT to get a candidate AP while
1217 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1218 if (pMac->scan.occupiedChannels.numChannels)
1219 {
1220 csrNeighborRoamMergeChannelLists(pMac,
1221 &pMac->scan.occupiedChannels.channelList[0],
1222 pMac->scan.occupiedChannels.numChannels,
1223 inPtr,
1224 inNumChannels,
1225 &mergedOutputNumOfChannels);
1226 inNumChannels = mergedOutputNumOfChannels;
1227 }
1228
1229 if (eCSR_BAND_24 == eBand)
1230 {
1231 for (i = 0; i < inNumChannels; i++)
1232 {
1233 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1234 {
1235 ChannelList[outNumChannels++] = inPtr[i];
1236 }
1237 }
1238 }
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]) &&
1245 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1246 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1247 {
1248 ChannelList[outNumChannels++] = inPtr[i];
1249 }
1250 }
1251 }
1252 else if (eCSR_BAND_ALL == eBand)
1253 {
1254 for (i = 0; i < inNumChannels; i++)
1255 {
1256 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1257 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1258 {
1259 ChannelList[outNumChannels++] = inPtr[i];
1260 }
1261 }
1262 }
1263 else
1264 {
1265 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1266 "Invalid band, No operation carried out (Band %d)", eBand);
1267 return eHAL_STATUS_INVALID_PARAMETER;
1268 }
1269
1270 /* if roaming within band is enabled, then select only the
1271 in band channels .
1272 This is required only if the band capability is set to ALL,
1273 E.g., if band capability is only 2.4G then all the channels in the
1274 list are already filtered for 2.4G channels, hence ignore this check*/
1275
1276 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1277 {
1278 csrNeighborRoamChannelsFilterByCurrentBand(
1279 pMac,
1280 ChannelList,
1281 outNumChannels,
1282 tmpChannelList,
1283 &outNumChannels);
1284 palCopyMemory(pMac->hHdd, ChannelList,
1285 tmpChannelList, outNumChannels);
1286 }
1287
1288 /* Prepare final roam scan channel list */
1289 if(outNumChannels)
1290 {
1291 /* Clear the channel list first */
1292 if (NULL != currChannelListInfo->ChannelList)
1293 {
1294 vos_mem_free(currChannelListInfo->ChannelList);
1295 currChannelListInfo->ChannelList = NULL;
1296 currChannelListInfo->numOfChannels = 0;
1297 }
1298
1299 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1300 if (NULL == currChannelListInfo->ChannelList)
1301 {
1302 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1303 "Failed to allocate memory for roam scan channel list");
1304 currChannelListInfo->numOfChannels = 0;
1305 return VOS_STATUS_E_RESOURCES;
1306 }
1307 palCopyMemory(pMac->hHdd, currChannelListInfo->ChannelList,
1308 ChannelList, outNumChannels);
1309 }
1310 return status;
1311}
1312#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
1313
Jeff Johnson295189b2012-06-20 16:38:30 -07001314eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1315{
1316 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1317 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001318 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1319 (eBand == eCSR_BAND_24))
1320 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001321 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001323 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001324 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 pMac->roam.configParam.uCfgDot11Mode, eBand);
1326 return eHAL_STATUS_INVALID_PARAMETER;
1327 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1329 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1330 (eBand == eCSR_BAND_5G))
1331 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001332 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001334 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001335 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 pMac->roam.configParam.uCfgDot11Mode, eBand);
1337 return eHAL_STATUS_INVALID_PARAMETER;
1338 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001339 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001340 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001341 pMac->roam.configParam.eBand = eBand;
1342 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 csrScanGetSupportedChannels( pMac );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001344#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1345 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
1346#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 status = csrInitGetChannels( pMac );
1348 if (eHAL_STATUS_SUCCESS == status)
1349 csrInitChannelList( hHal );
1350 return status;
1351}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001352
1353
Jeff Johnsone7245742012-09-05 17:12:55 -07001354/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1355 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1356 * Ideally we should have kept the ini value and enum value same and representing the same
1357 * cb values as in 11n standard i.e.
1358 * Set to 1 (SCA) if the secondary channel is above the primary channel
1359 * Set to 3 (SCB) if the secondary channel is below the primary channel
1360 * Set to 0 (SCN) if no secondary channel is present
1361 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1362 * 0 - secondary none
1363 * 1 - secondary LOW
1364 * 2 - secondary HIGH
1365 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1366 * The enum values are as follows:
1367 * PHY_SINGLE_CHANNEL_CENTERED = 0
1368 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1369 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1370 */
1371ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1372{
1373
1374 ePhyChanBondState phyCbState;
1375 switch (cbIniValue) {
1376 // secondary none
1377 case 0:
1378 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1379 break;
1380 // secondary LOW
1381 case 1:
1382 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1383 break;
1384 // secondary HIGH
1385 case 2:
1386 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1387 break;
1388#ifdef WLAN_FEATURE_11AC
1389 case 3:
1390 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1391 break;
1392 case 4:
1393 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1394 break;
1395 case 5:
1396 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1397 break;
1398 case 6:
1399 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1400 break;
1401 case 7:
1402 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1403 break;
1404 case 8:
1405 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1406 break;
1407 case 9:
1408 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1409 break;
1410#endif
1411 default:
1412 // If an invalid value is passed, disable CHANNEL BONDING
1413 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1414 break;
1415 }
1416 return phyCbState;
1417}
1418
1419v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1420{
1421
1422 v_U32_t cbIniValue;
1423 switch (phyCbState) {
1424 // secondary none
1425 case PHY_SINGLE_CHANNEL_CENTERED:
1426 cbIniValue = 0;
1427 break;
1428 // secondary LOW
1429 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1430 cbIniValue = 1;
1431 break;
1432 // secondary HIGH
1433 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1434 cbIniValue = 2;
1435 break;
1436#ifdef WLAN_FEATURE_11AC
1437 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1438 cbIniValue = 3;
1439 break;
1440 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1441 cbIniValue = 4;
1442 break;
1443 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1444 cbIniValue = 5;
1445 break;
1446 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1447 cbIniValue = 6;
1448 break;
1449 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1450 cbIniValue = 7;
1451 break;
1452 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1453 cbIniValue = 8;
1454 break;
1455 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1456 cbIniValue = 9;
1457 break;
1458#endif
1459 default:
1460 // return some invalid value
1461 cbIniValue = 10;
1462 break;
1463 }
1464 return cbIniValue;
1465}
Jeff Johnson295189b2012-06-20 16:38:30 -07001466
1467eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1468{
1469 eHalStatus status = eHAL_STATUS_SUCCESS;
1470
1471 if(pParam)
1472 {
1473 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1474 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1475 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1476 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1477 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1478 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1479
1480 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001481 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1482
Jeff Johnsone7245742012-09-05 17:12:55 -07001483 /* channelBondingMode5GHz plays a dual role right now
1484 * 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
1485 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1486 */
1487 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1488 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001489 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001490 }
1491 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1492 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1493 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001494 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001495 }
1496 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1498 pMac->roam.configParam.phyMode = pParam->phyMode;
1499 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1500 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1501 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1502 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1503 pMac->roam.configParam.TxRate = pParam->TxRate;
1504 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1505 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1506 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1507 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1508 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001509 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 //if HDD passed down non zero values then only update,
1511 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001512 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001513 {
1514 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1515 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001516 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001517 {
1518 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1519 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001520 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001521 {
1522 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1523 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001524 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001525 {
1526 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1527 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001528 if (pParam->nActiveMaxChnTimeBtc)
1529 {
1530 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1531 }
1532 if (pParam->nActiveMinChnTimeBtc)
1533 {
1534 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1535 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001536#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001537 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001538 {
1539 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1540 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001541 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001542 {
1543 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1544 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001545 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001546 {
1547 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1548 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001549 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001550 {
1551 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1552 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001553 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001554 {
1555 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1556 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001557 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001558 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001559 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1560 }
1561 if (pParam->nNumP2PChanCombinedConc)
1562 {
1563 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001564 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001565#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001566 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001567 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 {
1569 //Change the unit from second to microsecond
1570 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001571 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1572 {
1573 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1574 }
1575 else
1576 {
1577 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1578 }
1579 }
1580 else
1581 {
1582 pMac->roam.configParam.impsSleepTime = 0;
1583 }
1584 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1586 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001587 //if HDD passed down non zero values for age params, then only update,
1588 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001589 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 {
1591 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 if(pParam->scanAgeTimeNCNPS)
1594 {
1595 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001597 if(pParam->scanAgeTimeNCPS)
1598 {
1599 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001601 if(pParam->scanAgeTimeCNPS)
1602 {
1603 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1604 }
1605 if(pParam->scanAgeTimeCPS)
1606 {
1607 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1608 }
1609
1610 csrAssignRssiForCategory(pMac, pParam->bCatRssiOffset);
1611 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1612 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1613 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1614 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1615 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1617 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1619 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1620 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1621 //Assign this before calling CsrInit11dInfo
1622 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001623 if( csrIs11dSupported( pMac ) )
1624 {
1625 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1626 }
1627 else
1628 {
1629 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1630 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001631
1632 /* Initialize the power + channel information if 11h is enabled.
1633 If 11d is enabled this information has already been initialized */
1634 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1635 {
1636 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1637 }
1638
1639
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301640#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301641 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1642 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001643 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001644#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001645#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001647 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001648 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001649 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001650 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001651 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001652 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001653 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001654 pMac->roam.configParam.nProbes = pParam->nProbes;
1655 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001656#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001657#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1658 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001659 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001660#endif
1661#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001662 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
1663#endif
1664
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301665#ifdef FEATURE_WLAN_CCX
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 pMac->roam.configParam.isCcxIniFeatureEnabled = pParam->isCcxIniFeatureEnabled;
1667#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001668#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301669 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1670 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001671 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1672 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1673 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1674 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1675 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1676 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1677 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1678 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001679 {
1680 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001681 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 -07001682 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1683 {
1684 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1685 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001686 smsLog( pMac, LOG1, "");
Jeff Johnson295189b2012-06-20 16:38:30 -07001687 }
1688#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001689 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1690 pMac->scan.fValidateList = pParam->fValidateList;
1691 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1692 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001693 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001694 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001695 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1696 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1697 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1698 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1699 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1700 * single session
1701 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001702 //Remove this code once SLM_Sessionization is supported
1703 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001704 pMac->roam.configParam.doBMPSWorkaround = 0;
1705
Jeff Johnsone7245742012-09-05 17:12:55 -07001706#ifdef WLAN_FEATURE_11AC
1707 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001708 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001709 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001710 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001711#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001712 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001713
1714 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 }
1716
1717 return status;
1718}
1719
Jeff Johnson295189b2012-06-20 16:38:30 -07001720eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1721{
1722 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 if(pParam)
1724 {
1725 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1726 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1727 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1728 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1729 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1730 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001731 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1732 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1734 pParam->phyMode = pMac->roam.configParam.phyMode;
1735 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1736 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1737 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1738 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1739 pParam->TxRate = pMac->roam.configParam.TxRate;
1740 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1741 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1742 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1743 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1744 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001745 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1746 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1747 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1748 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001749 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1750 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1751 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001752#ifdef WLAN_AP_STA_CONCURRENCY
1753 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1754 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1755 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1756 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1757 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001758 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1759 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001760#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 //Change the unit from microsecond to second
1762 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1763 pParam->eBand = pMac->roam.configParam.eBand;
1764 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1765 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1766 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1767 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1768 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1769 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1770 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1771 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1772 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1773 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1774 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1775 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1776 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001777 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1778 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1779 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1780 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001781 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1782 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1783 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1784 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1785 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001786 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001787 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001788 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001789 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001790
1791#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301792 vos_mem_copy(&pParam->neighborRoamConfig,
1793 &pMac->roam.configParam.neighborRoamConfig,
1794 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001795#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001796#ifdef WLAN_FEATURE_11AC
1797 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001798 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001799 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001800 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001801#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001802#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301803 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1804 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001805#endif
1806#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1807 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1808 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1809 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1810 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1811 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001812 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001813 pParam->nProbes = pMac->roam.configParam.nProbes;
1814 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001815#endif
1816#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1817 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1818 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1819#endif
1820#ifdef FEATURE_WLAN_LFR
1821 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1822#endif
1823
1824#ifdef FEATURE_WLAN_CCX
1825 pParam->isCcxIniFeatureEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
1826#endif
1827#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301828 vos_mem_copy(&pParam->neighborRoamConfig,
1829 &pMac->roam.configParam.neighborRoamConfig,
1830 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001831 {
1832 int i;
1833 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1834 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1835 {
1836 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1837 }
1838 smsLog( pMac, LOG1, "");
1839 }
1840#endif
1841
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001842 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001843
krunal soni5afa96c2013-09-06 22:19:02 -07001844 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
1845
Jeff Johnson295189b2012-06-20 16:38:30 -07001846 csrSetChannels(pMac, pParam);
1847
1848 status = eHAL_STATUS_SUCCESS;
1849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 return (status);
1851}
1852
Jeff Johnson295189b2012-06-20 16:38:30 -07001853eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1854{
1855 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1856 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1857 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1858 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001859 do
1860 {
1861 if(eCSR_BAND_24 == eBand)
1862 {
1863 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1864 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1865 }
1866 if(eCSR_BAND_5G == eBand)
1867 {
1868 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1869 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1870 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1871 )
1872 {
1873 break;
1874 }
1875 }
1876 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1877 {
1878 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1879 }
1880 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1881 {
1882 newPhyMode = eCSR_DOT11_MODE_AUTO;
1883 }
1884 else
1885 {
1886 //Check for dual band and higher capability first
1887 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1888 {
1889 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1890 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1891 }
1892 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1893 {
1894 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1895 if(eCSR_BAND_24 == eBand) break;
1896 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1897 eBand = eCSR_BAND_5G;
1898 }
1899 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1900 {
1901 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1902 if(eCSR_BAND_5G == eBand) break;
1903 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1904 eBand = eCSR_BAND_24;
1905 }
1906 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1907 {
1908 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1909 if(eCSR_BAND_5G == eBand) break;
1910 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
1911 eBand = eCSR_BAND_24;
1912 }
1913 else if(eCSR_DOT11_MODE_11n & phyMode)
1914 {
1915 newPhyMode = eCSR_DOT11_MODE_11n;
1916 }
1917 else if(eCSR_DOT11_MODE_abg & phyMode)
1918 {
1919 newPhyMode = eCSR_DOT11_MODE_abg;
1920 }
1921 else if(eCSR_DOT11_MODE_11a & phyMode)
1922 {
1923 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
1924 {
1925 if(eCSR_BAND_ALL == eBand)
1926 {
1927 newPhyMode = eCSR_DOT11_MODE_abg;
1928 }
1929 else
1930 {
1931 //bad setting
1932 break;
1933 }
1934 }
1935 else
1936 {
1937 newPhyMode = eCSR_DOT11_MODE_11a;
1938 eBand = eCSR_BAND_5G;
1939 }
1940 }
1941 else if(eCSR_DOT11_MODE_11g & phyMode)
1942 {
1943 newPhyMode = eCSR_DOT11_MODE_11g;
1944 eBand = eCSR_BAND_24;
1945 }
1946 else if(eCSR_DOT11_MODE_11b & phyMode)
1947 {
1948 newPhyMode = eCSR_DOT11_MODE_11b;
1949 eBand = eCSR_BAND_24;
1950 }
1951 else
1952 {
1953 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001954 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07001955 newPhyMode = eCSR_DOT11_MODE_AUTO;
1956 }
1957 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 //Done validating
1959 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 //Now we need to check whether a restart is needed.
1961 if(eBand != pMac->roam.configParam.eBand)
1962 {
1963 fRestartNeeded = eANI_BOOLEAN_TRUE;
1964 break;
1965 }
1966 if(newPhyMode != pMac->roam.configParam.phyMode)
1967 {
1968 fRestartNeeded = eANI_BOOLEAN_TRUE;
1969 break;
1970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 if(HAL_STATUS_SUCCESS(status))
1973 {
1974 pMac->roam.configParam.eBand = eBand;
1975 pMac->roam.configParam.phyMode = newPhyMode;
1976 if(pfRestartNeeded)
1977 {
1978 *pfRestartNeeded = fRestartNeeded;
1979 }
1980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001981 return (status);
1982}
1983
Jeff Johnson295189b2012-06-20 16:38:30 -07001984void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
1985{
1986 tANI_U8 Index;
1987 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07001988 // for dual band NICs, don't need to trim the channel list....
1989 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
1990 {
1991 // 2.4 GHz band operation requires the channel list to be trimmed to
1992 // the 2.4 GHz channels only...
1993 if ( CSR_IS_24_BAND_ONLY( pMac ) )
1994 {
1995 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
1996 Index++ )
1997 {
1998 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
1999 {
2000 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2001 cChannels++;
2002 }
2003 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002004 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2005 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2006 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2007 // only if we need to.
2008 //
2009 // The amount of memory to clear is the number of channesl that we trimmed
2010 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2011
2012 if ( pChannelList->numChannels > cChannels )
2013 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302014 vos_mem_set(&pChannelList->channelList[ cChannels ],
2015 sizeof( pChannelList->channelList[ 0 ] ) *
2016 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002017 }
2018
2019 pChannelList->numChannels = cChannels;
2020 }
2021 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2022 {
2023 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2024 {
2025 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2026 {
2027 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2028 cChannels++;
2029 }
2030 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002031 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2032 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2033 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2034 // only if we need to.
2035 //
2036 // The amount of memory to clear is the number of channesl that we trimmed
2037 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2038 if ( pChannelList->numChannels > cChannels )
2039 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302040 vos_mem_set(&pChannelList->channelList[ cChannels ],
2041 sizeof( pChannelList->channelList[ 0 ] ) *
2042 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 }
2044
2045 pChannelList->numChannels = cChannels;
2046 }
2047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002048}
Jeff Johnson295189b2012-06-20 16:38:30 -07002049#define INFRA_AP_DEFAULT_CHANNEL 6
2050eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2051{
2052 tANI_U8 index= 0;
2053 eHalStatus status = eHAL_STATUS_FAILURE;
2054 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2055 {
2056 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2057 status = eHAL_STATUS_SUCCESS;
2058 break;
2059 }
2060 }
2061 return status;
2062}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002063
2064eHalStatus csrGet5GChannels(tpAniSirGlobal pMac)
2065{
2066 eHalStatus status = eHAL_STATUS_SUCCESS;
2067 tANI_U8 num20MHzChannelsFound = 0;
2068 VOS_STATUS vosStatus;
2069 tANI_U8 num40MHzChannelsFound = 0;
2070 tANI_U8 Index = 0;
2071 tANI_U8 channelList = 0;
2072
2073 // Updating the defaultpower Table for changed Domain Id
2074 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2075 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2076
2077 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2078 {
2079 smsLog( pMac, LOGE, FL("failed to get channels"));
2080 status = eHAL_STATUS_FAILURE;
2081 }
2082 else
2083 {
2084 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2085 {
2086 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2087 }
2088
2089 // Move the only 5GHZ channel list to the global data,
2090 // As 2.4GHZ list coming from the AP for the changed domain
2091 // structure -- this will be used as the scan list
2092 for(channelList = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
2093 {
2094 // If Channel is 5GHz just break the for loop
2095 if(!(pMac->scan.base20MHzChannels.channelList[ channelList ] > 0 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 14))
2096 break;
2097 }
2098 // Update the 5G channels from nv.bin
2099 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2100 {
2101 if(pMac->scan.defaultPowerTable[Index].chanId >= 36 && pMac->scan.defaultPowerTable[Index].chanId <= 165)
2102 {
Krunal Sonia75019a2013-05-01 01:08:22 -07002103 if (channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN)
2104 {
2105 pMac->scan.base20MHzChannels.channelList[ channelList ] = pMac->scan.defaultPowerTable[Index].chanId;
2106 channelList++;
2107 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002108 }
2109 }
2110
2111 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
2112 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > channelList) ? num20MHzChannelsFound : channelList;
2113 // Filling the remaining index as Zero Just for causion
2114 for(Index = pMac->scan.base20MHzChannels.numChannels; Index < WNI_CFG_VALID_CHANNEL_LIST_LEN; Index++)
2115 pMac->scan.base20MHzChannels.channelList[ Index ] = 0;
2116 }
2117 return status;
2118}
2119
2120eHalStatus csrGet24GChannels(tpAniSirGlobal pMac)
2121{
2122 eHalStatus status = eHAL_STATUS_SUCCESS;
2123 tANI_U8 num20MHzChannelsFound = 0;
2124 VOS_STATUS vosStatus;
2125 tANI_U8 Index = 0;
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302126 tANI_U8 numChan = 0;
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002127 tANI_U8 num40MHzChannelsFound = 0;
2128 tANI_U8 channelList5GBackup[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0}, nuum5GchannelListBackup;
2129 tANI_U8 channelList = 0;
2130
2131 // Read the scan channel list (including the power limit) from EEPROM
2132 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2133 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2134
2135 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2136 {
2137 smsLog( pMac, LOGE, FL("failed to get channels \n"));
2138 status = eHAL_STATUS_FAILURE;
2139 }
2140 else
2141 {
2142 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2143 {
2144 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2145 }
2146
2147 // Move the 2.4GHZ channel list only to the global data,
2148 // As 5GHz list been provided by AP as part of 11d IE
2149 // structure -- this will be used as the scan list
2150 for(channelList = 0, nuum5GchannelListBackup = 0; channelList < WNI_CFG_VALID_CHANNEL_LIST_LEN; channelList++)
2151 {
2152 if(pMac->scan.base20MHzChannels.channelList[ channelList ] >= 36 && pMac->scan.base20MHzChannels.channelList[ channelList ] <= 165)
2153 {
2154 // First taking the 5GHz channel list backup
2155 channelList5GBackup[nuum5GchannelListBackup] = pMac->scan.base20MHzChannels.channelList[ channelList ];
2156 nuum5GchannelListBackup++;
2157 }
2158 }
2159 // Updating the 2.4GHz list
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302160 for ( Index = 0, numChan = 0; Index < num20MHzChannelsFound; Index++)
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002161 {
2162 if(pMac->scan.defaultPowerTable[Index].chanId > 0 && pMac->scan.defaultPowerTable[Index].chanId <= 14)
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302163 {
2164 pMac->scan.base20MHzChannels.channelList[ numChan ] = pMac->scan.defaultPowerTable[Index].chanId;
2165 numChan++;
2166 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002167 }
2168 // Restoring the Backed up 5 GHZ channels
2169 for(channelList = 0;channelList < nuum5GchannelListBackup; channelList++ )
2170 {
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302171 if (numChan < WNI_CFG_VALID_CHANNEL_LIST_LEN)
Krunal Sonia75019a2013-05-01 01:08:22 -07002172 {
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302173 pMac->scan.base20MHzChannels.channelList[ numChan ] = channelList5GBackup[channelList];
2174 numChan++;
Krunal Sonia75019a2013-05-01 01:08:22 -07002175 }
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002176 }
2177
Gopichand Nakkalac8d06aa2013-06-27 12:35:23 +05302178 pMac->scan.numChannelsDefault = (num20MHzChannelsFound > numChan) ? num20MHzChannelsFound : numChan;
2179 pMac->scan.base20MHzChannels.numChannels = (num20MHzChannelsFound > numChan) ? num20MHzChannelsFound : numChan;
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002180 }
2181 return (status);
2182}
2183
Jeff Johnson295189b2012-06-20 16:38:30 -07002184eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2185{
2186 eHalStatus status = eHAL_STATUS_SUCCESS;
2187 tANI_U8 num20MHzChannelsFound = 0;
2188 VOS_STATUS vosStatus;
2189 tANI_U8 Index = 0;
2190 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002191
Jeff Johnson295189b2012-06-20 16:38:30 -07002192
2193 //TODO: this interface changed to include the 40MHz channel list
2194 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2195 // Read the scan channel list (including the power limit) from EEPROM
2196 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2197 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2198 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2199 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002200 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 status = eHAL_STATUS_FAILURE;
2202 }
2203 else
2204 {
2205 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2206 {
2207 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2208 }
2209 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2210 // Move the channel list to the global data
2211 // structure -- this will be used as the scan list
2212 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2213 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002214 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002215 }
2216 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2217 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2218 {
2219 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2220 }
2221 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2222 {
2223 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2224 }
2225 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 return (status);
2228}
2229
Jeff Johnson295189b2012-06-20 16:38:30 -07002230eHalStatus csrInitChannelList( tHalHandle hHal )
2231{
2232 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2233 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2235 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002236 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2237 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002239 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002240
2241 return (status);
2242}
Jeff Johnson295189b2012-06-20 16:38:30 -07002243eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2244 tCsrUpdateConfigParam *pUpdateConfigParam)
2245{
2246 eHalStatus status = eHAL_STATUS_FAILURE;
2247 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002248 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2249 status = CsrInit11dInfo(pMac, ps11dinfo);
2250 return status;
2251}
2252
Jeff Johnson295189b2012-06-20 16:38:30 -07002253static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2254{
2255 eHalStatus status = eHAL_STATUS_FAILURE;
2256 tANI_U8 index;
2257 tANI_U32 count=0;
2258 tSirMacChanInfo *pChanInfo;
2259 tSirMacChanInfo *pChanInfoStart;
2260 tANI_BOOLEAN applyConfig = TRUE;
2261
2262 if(!ps11dinfo)
2263 {
2264 return (status);
2265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2267 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302268 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2269 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2270 ps11dinfo->Channels.channelList,
2271 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 }
2273 else
2274 {
2275 //No change
2276 return (eHAL_STATUS_SUCCESS);
2277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302279
2280 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2281 WNI_CFG_COUNTRY_CODE_LEN);
2282
2283
Jeff Johnson295189b2012-06-20 16:38:30 -07002284 //Tush: at csropen get this initialized with default, during csr reset if this
2285 // already set with some value no need initilaize with default again
2286 if(0 == pMac->scan.countryCodeCurrent[0])
2287 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302288 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2289 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302292 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2293 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302295 vos_mem_set(pChanInfo,
2296 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2297 0);
2298
Jeff Johnson295189b2012-06-20 16:38:30 -07002299 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002300 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2301 {
2302 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2303 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2304 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2305 pChanInfo++;
2306 count++;
2307 }
2308 if(count)
2309 {
2310 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2311 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302312 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002313 }
2314 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2315 if( HAL_STATUS_SUCCESS(status) )
2316 {
2317 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2318 {
2319 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2320 {
2321 applyConfig = FALSE;
2322 }
2323 }
2324
2325 if(TRUE == applyConfig)
2326 {
2327 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002328 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002329 }
2330
2331 }
2332 return (status);
2333}
2334/* Initialize the Channel + Power List in the local cache and in the CFG */
2335eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2336{
2337 tANI_U8 index;
2338 tANI_U32 count=0;
2339 tSirMacChanInfo *pChanInfo;
2340 tSirMacChanInfo *pChanInfoStart;
2341
2342 if(!ps11dinfo || !pMac)
2343 {
2344 return eHAL_STATUS_FAILURE;
2345 }
2346
Kiet Lam64c1b492013-07-12 13:56:44 +05302347 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2348 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002349 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302350 vos_mem_set(pChanInfo,
2351 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2352 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002353 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002354
2355 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2356 {
2357 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2358 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2359 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2360 pChanInfo++;
2361 count++;
2362 }
2363 if(count)
2364 {
2365 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2366 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302367 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 }
2369
Jeff Johnsone7245742012-09-05 17:12:55 -07002370 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002371}
2372
2373//pCommand may be NULL
2374//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2375void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2376{
2377 tListElem *pEntry, *pNextEntry;
2378 tSmeCmd *pDupCommand;
2379 tDblLinkList localList;
2380
2381 vos_mem_zero(&localList, sizeof(tDblLinkList));
2382 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2383 {
2384 smsLog(pMac, LOGE, FL(" failed to open list"));
2385 return;
2386 }
2387 csrLLLock( &pMac->sme.smeCmdPendingList );
2388 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2389 while( pEntry )
2390 {
2391 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2392 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002393 // Remove the previous command if..
2394 // - the new roam command is for the same RoamReason...
2395 // - the new roam command is a NewProfileList.
2396 // - the new roam command is a Forced Dissoc
2397 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2398 if (
2399 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2400 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002401 /* This peermac check is requried for Softap/GO scenarios
2402 * For STA scenario below OR check will suffice as pCommand will
2403 * always be NULL for STA scenarios
2404 */
2405 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2407 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2408 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2409 ||
2410 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002411 ( (sessionId == pDupCommand->sessionId) &&
2412 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002413 ((eCsrForcedDisassoc == eRoamReason) ||
2414 (eCsrHddIssued == eRoamReason))
2415 )
2416 )
2417 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002418 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 // Remove the 'stale' roam command from the pending list...
2420 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2421 {
2422 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2423 }
2424 }
2425 pEntry = pNextEntry;
2426 }
2427 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2428
2429 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2430 {
2431 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2432 //Tell caller that the command is cancelled
2433 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2434 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2435 csrReleaseCommandRoam(pMac, pDupCommand);
2436 }
2437 csrLLClose(&localList);
2438}
Jeff Johnson295189b2012-06-20 16:38:30 -07002439eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2440 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2441{
2442 eHalStatus status = eHAL_STATUS_SUCCESS;
2443#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2444 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2445#endif
2446 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2448 {
2449 pSession = CSR_GET_SESSION( pMac, sessionId );
2450 }
2451 else
2452 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002453 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 VOS_ASSERT(0);
2455 return eHAL_STATUS_FAILURE;
2456 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002457 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
2458 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002459 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002461 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2462 /*
2463 * Decrement bRefAssocStartCnt for FT reassoc failure.
2464 * Reason: For FT reassoc failures, we first call
2465 * csrRoamCallCallback before notifying a failed roam
2466 * completion through csrRoamComplete. The latter in
2467 * turn calls csrRoamProcessResults which tries to
2468 * once again call csrRoamCallCallback if bRefAssocStartCnt
2469 * is non-zero. Since this is redundant for FT reassoc
2470 * failure, decrement bRefAssocStartCnt.
2471 */
2472 pSession->bRefAssocStartCnt--;
2473 }
2474
Jeff Johnson295189b2012-06-20 16:38:30 -07002475 if ( (pSession == NULL) ||
2476 (eANI_BOOLEAN_FALSE == pSession->sessionActive) )
2477 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002478 smsLog(pMac, LOG1, "Session ID is not valid");
Jeff Johnson295189b2012-06-20 16:38:30 -07002479 return eHAL_STATUS_FAILURE;
2480 }
2481
2482 if(NULL != pSession->callback)
2483 {
2484 if( pRoamInfo )
2485 {
2486 pRoamInfo->sessionId = (tANI_U8)sessionId;
2487 }
2488
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302489 /* avoid holding the global lock when making the roaming callback, original change came
2490 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2491 is possible on other OS ports where the callback may need to take locks to protect
2492 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002493 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2494 that may actually depend on the lock being held */
2495 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2496 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2497 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2498 }
2499 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2500 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2501#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302502 vos_mem_set(&connectionStatus,
2503 sizeof(vos_event_wlan_status_payload_type), 0);
2504
Jeff Johnson295189b2012-06-20 16:38:30 -07002505 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2))
2506 {
2507 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2508 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2509 if(NULL != pRoamInfo->pBssDesc)
2510 {
2511 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2512 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2513 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002514 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2515 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2516 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302517 vos_mem_copy(connectionStatus.ssid,
2518 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2519
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2521 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002523 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2524 {
2525 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2526 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2527 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002529 if(eCSR_ROAM_RESULT_FORCED == u2)
2530 {
2531 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2532 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2533 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2536 {
2537 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2538 connectionStatus.reason = eCSR_REASON_DISASSOC;
2539 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002541 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2542 {
2543 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2544 connectionStatus.reason = eCSR_REASON_DEAUTH;
2545 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002547#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2548
2549 return (status);
2550}
Jeff Johnson295189b2012-06-20 16:38:30 -07002551// Returns whether handoff is currently in progress or not
2552tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2553{
2554#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2555 return csrNeighborRoamIsHandoffInProgress(pMac);
2556#else
2557 return eANI_BOOLEAN_FALSE;
2558#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002559}
Jeff Johnson295189b2012-06-20 16:38:30 -07002560eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2561 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2562{
2563 eHalStatus status = eHAL_STATUS_SUCCESS;
2564 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2565 tANI_U16 reasonCode;
2566 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002567
2568 if(!pSession)
2569 {
2570 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2571 return eHAL_STATUS_FAILURE;
2572 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002573
2574 //Restore AC weight in case we change it
2575 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2576 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002577 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 -07002578 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2579 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2580 }
2581
2582 if ( fMICFailure )
2583 {
2584 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2585 }
2586 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2587 {
2588 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002589 }
2590 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002591 {
2592 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2593 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002594#ifdef WLAN_FEATURE_VOWIFI_11R
2595 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2596 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2597 {
2598 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302599 vos_mem_copy(&bssId,
2600 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2601 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002602 }
2603 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002604#endif
2605 if(pSession->pConnectBssDesc)
2606 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302607 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002608 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002609
Jeff Johnson295189b2012-06-20 16:38:30 -07002610
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002611 smsLog( pMac, LOG2, "CSR Attempting to Disassociate Bssid=%02x-%02x-%02x-%02x-%02x-%02x"
2612 "subState = %d reason=%d", bssId[ 0 ], bssId[ 1 ], bssId[ 2 ], bssId[ 3 ],
2613 bssId[ 4 ], bssId[ 5 ], NewSubstate, reasonCode);
2614
Jeff Johnson295189b2012-06-20 16:38:30 -07002615 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2616
2617 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2618
2619 if(HAL_STATUS_SUCCESS(status))
2620 {
2621 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002622#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2623 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2624 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2625 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002626 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2628 }
2629#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002630 }
2631 else
2632 {
2633 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2634 }
2635
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 return (status);
2637}
Jeff Johnson295189b2012-06-20 16:38:30 -07002638
Jeff Johnson295189b2012-06-20 16:38:30 -07002639/* ---------------------------------------------------------------------------
2640 \fn csrRoamIssueDisassociateStaCmd
2641 \brief csr function that HDD calls to disassociate a associated station
2642 \param sessionId - session Id for Soft AP
2643 \param pPeerMacAddr - MAC of associated station to delete
2644 \param reason - reason code, be one of the tSirMacReasonCodes
2645 \return eHalStatus
2646 ---------------------------------------------------------------------------*/
2647eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2648 tANI_U32 sessionId,
2649 tANI_U8 *pPeerMacAddr,
2650 tANI_U32 reason)
2651{
2652 eHalStatus status = eHAL_STATUS_SUCCESS;
2653 tSmeCmd *pCommand;
2654
2655 do
2656 {
2657 pCommand = csrGetCommandBuffer( pMac );
2658 if ( !pCommand )
2659 {
2660 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2661 status = eHAL_STATUS_RESOURCES;
2662 break;
2663 }
2664 pCommand->command = eSmeCommandRoam;
2665 pCommand->sessionId = (tANI_U8)sessionId;
2666 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2667 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2668 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2669 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2670 if( !HAL_STATUS_SUCCESS( status ) )
2671 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002672 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002673 csrReleaseCommandRoam( pMac, pCommand );
2674 }
2675 }while(0);
2676
2677 return status;
2678}
2679
2680
Jeff Johnson295189b2012-06-20 16:38:30 -07002681/* ---------------------------------------------------------------------------
2682 \fn csrRoamIssueDeauthSta
2683 \brief csr function that HDD calls to delete a associated station
2684 \param sessionId - session Id for Soft AP
2685 \param pPeerMacAddr - MAC of associated station to delete
2686 \param reason - reason code, be one of the tSirMacReasonCodes
2687 \return eHalStatus
2688 ---------------------------------------------------------------------------*/
2689eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2690 tANI_U32 sessionId,
2691 tANI_U8 *pPeerMacAddr,
2692 tANI_U32 reason)
2693{
2694 eHalStatus status = eHAL_STATUS_SUCCESS;
2695 tSmeCmd *pCommand;
2696
2697 do
2698 {
2699 pCommand = csrGetCommandBuffer( pMac );
2700 if ( !pCommand )
2701 {
2702 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2703 status = eHAL_STATUS_RESOURCES;
2704 break;
2705 }
2706 pCommand->command = eSmeCommandRoam;
2707 pCommand->sessionId = (tANI_U8)sessionId;
2708 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2709 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2710 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2711 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2712 if( !HAL_STATUS_SUCCESS( status ) )
2713 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002714 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 csrReleaseCommandRoam( pMac, pCommand );
2716 }
2717 }while(0);
2718
2719 return status;
2720}
Jeff Johnson295189b2012-06-20 16:38:30 -07002721eHalStatus
2722csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2723 tANI_BOOLEAN bEnable )
2724{
2725 eHalStatus status = eHAL_STATUS_FAILURE;
2726 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2727 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002728 if (!pSession)
2729 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002730 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002731 return (status);
2732 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 if (pSession->pConnectBssDesc)
2734 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302735 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 }
2737 else
2738 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002739 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 return (status);
2741 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002742 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = %02x-%02x-%02x-%02x-%02x-%02x, Enable = %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002743 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302744 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ], bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2746 return (status);
2747}
Jeff Johnson295189b2012-06-20 16:38:30 -07002748eHalStatus
2749csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2750 VOS_MODULE_ID modId, void *pUsrContext,
2751 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2752{
2753 eHalStatus status = eHAL_STATUS_SUCCESS;
2754 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2755 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002756 if (!pSession)
2757 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002758 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 return (status);
2760 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002761 if(pSession->pConnectBssDesc)
2762 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302763 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002764 }
2765 else
2766 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002767 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002768 return (status);
2769 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002770 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002771 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2772 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002773 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2774 return (status);
2775}
Jeff Johnson295189b2012-06-20 16:38:30 -07002776eHalStatus
2777csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2778 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2779{
2780 eHalStatus status = eHAL_STATUS_SUCCESS;
2781 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2782 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2783
2784 if (!pSession)
2785 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002786 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002787 return (status);
2788 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 if(pSession->pConnectBssDesc)
2790 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302791 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002792 }
2793 else
2794 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002795 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 return (status);
2797 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002798 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002799 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2800 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
2801
2802 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2803
2804 return (status);
2805}
Jeff Johnson295189b2012-06-20 16:38:30 -07002806eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2807{
2808 eHalStatus status = eHAL_STATUS_SUCCESS;
2809 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2810 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002811
2812 if (!pSession)
2813 {
2814 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2815 return eHAL_STATUS_FAILURE;
2816 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002817
2818 if(pSession->pConnectBssDesc)
2819 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302820 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002821 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002822 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07002823 bssId[ 0 ], bssId[ 1 ], bssId[ 2 ],
2824 bssId[ 3 ], bssId[ 4 ], bssId[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002825 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2826
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302827 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002828 if(!HAL_STATUS_SUCCESS(status))
2829 {
2830 smsLog(pMac, LOGW, FL("csrSendMBDeauthReqMsg failed with status %d"), status);
2831 }
2832
Jeff Johnson295189b2012-06-20 16:38:30 -07002833 return (status);
2834}
2835
Jeff Johnson295189b2012-06-20 16:38:30 -07002836eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2837{
2838 eHalStatus status = eHAL_STATUS_SUCCESS;
2839 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2840 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002841
2842 if(!pSession)
2843 {
2844 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2845 return eHAL_STATUS_FAILURE;
2846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002847
2848 // If no BSS description was found in this connection (happens with start IBSS), then
2849 // nix the BSS description that we keep around for the connected BSS) and get out...
2850 if(NULL == pBssDesc)
2851 {
2852 csrFreeConnectBssDesc(pMac, sessionId);
2853 }
2854 else
2855 {
2856 size = pBssDesc->length + sizeof( pBssDesc->length );
2857 if(NULL != pSession->pConnectBssDesc)
2858 {
2859 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2860 {
2861 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2862 csrFreeConnectBssDesc(pMac, sessionId);
2863 }
2864 }
2865 if(NULL == pSession->pConnectBssDesc)
2866 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302867 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302869 if (NULL == pSession->pConnectBssDesc)
2870 status = eHAL_STATUS_FAILURE;
2871 else
2872 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2873 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002874 return (status);
2875}
2876
Jeff Johnson295189b2012-06-20 16:38:30 -07002877eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2878 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2879 tDot11fBeaconIEs *pIes)
2880{
2881 eHalStatus status = eHAL_STATUS_SUCCESS;
2882 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302884 if (pIes == NULL)
2885 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002886
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 do
2888 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302889 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2890 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 //get qos
2892 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2893 //get SSID
2894 if(pIes->SSID.present)
2895 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302896 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2898 }
2899 else
2900 pBssConfig->SSID.length = 0;
2901 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2902 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002903 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 //Return failed if profile doesn't have an SSID either.
2905 if(pProfile->SSIDs.numOfSSIDs == 0)
2906 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002907 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 status = eHAL_STATUS_FAILURE;
2909 break;
2910 }
2911 }
2912 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2913 {
2914 pBssConfig->eBand = eCSR_BAND_5G;
2915 }
2916 else
2917 {
2918 pBssConfig->eBand = eCSR_BAND_24;
2919 }
2920 //phymode
2921 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2922 {
2923 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2924 }
2925 else
2926 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002927 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002928 //force it
2929 if(eCSR_BAND_24 == pBssConfig->eBand)
2930 {
2931 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2932 }
2933 else
2934 {
2935 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2936 }
2937 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002938 //Qos
2939 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2940 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2941 {
2942 //Joining BSS is not 11n capable and WMM is disabled on client.
2943 //Disable QoS and WMM
2944 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2945 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302946
2947 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302948 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302949 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2950 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2951 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2952 {
2953 //Joining BSS is 11n capable and WMM is disabled on AP.
2954 //Assume all HT AP's are QOS AP's and enable WMM
2955 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2956 }
2957
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 //auth type
2959 switch( pProfile->negotiatedAuthType )
2960 {
2961 default:
2962 case eCSR_AUTH_TYPE_WPA:
2963 case eCSR_AUTH_TYPE_WPA_PSK:
2964 case eCSR_AUTH_TYPE_WPA_NONE:
2965 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2966 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2967 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 case eCSR_AUTH_TYPE_SHARED_KEY:
2969 pBssConfig->authType = eSIR_SHARED_KEY;
2970 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 case eCSR_AUTH_TYPE_AUTOSWITCH:
2972 pBssConfig->authType = eSIR_AUTO_SWITCH;
2973 break;
2974 }
2975 //short slot time
2976 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2977 {
2978 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2979 }
2980 else
2981 {
2982 pBssConfig->uShortSlotTime = 0;
2983 }
2984 if(pBssConfig->BssCap.ibss)
2985 {
2986 //We don't support 11h on IBSS
2987 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2988 }
2989 else
2990 {
2991 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2992 }
2993 //power constraint
2994 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2995 //heartbeat
2996 if ( CSR_IS_11A_BSS( pBssDesc ) )
2997 {
2998 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2999 }
3000 else
3001 {
3002 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3003 }
3004 //Join timeout
3005 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07003006 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 if ( pBssDesc->beaconInterval )
3008 {
3009 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07003010 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003011 }
3012 else
3013 {
3014 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3015 }
3016 //validate CB
3017 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
3018 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003019 return (status);
3020}
3021
Jeff Johnson295189b2012-06-20 16:38:30 -07003022static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3023 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3024{
3025 eHalStatus status = eHAL_STATUS_SUCCESS;
3026 tANI_U8 operationChannel = 0;
3027 tANI_U8 qAPisEnabled = FALSE;
3028 //SSID
3029 pBssConfig->SSID.length = 0;
3030 if(pProfile->SSIDs.numOfSSIDs)
3031 {
3032 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303033 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3034 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 }
3036 else
3037 {
3038 //SSID must present
3039 return eHAL_STATUS_FAILURE;
3040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 //Settomg up the capabilities
3042 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3043 {
3044 pBssConfig->BssCap.ibss = 1;
3045 }
3046 else
3047 {
3048 pBssConfig->BssCap.ess = 1;
3049 }
3050 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3051 {
3052 pBssConfig->BssCap.privacy = 1;
3053 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 pBssConfig->eBand = pMac->roam.configParam.eBand;
3055 //phymode
3056 if(pProfile->ChannelInfo.ChannelList)
3057 {
3058 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3059 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003060 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3061 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003062 //QOS
3063 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003064 if ( pBssConfig->BssCap.ess == 1 )
3065 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 /*For Softap case enable WMM*/
3067 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3068 qAPisEnabled = TRUE;
3069 }
3070 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3072 qAPisEnabled = TRUE;
3073 } else {
3074 qAPisEnabled = FALSE;
3075 }
3076 } else {
3077 qAPisEnabled = TRUE;
3078 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3080 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3081 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3082 )
3083 {
3084 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3085 } else {
3086 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3087 }
3088
3089 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003090 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003091 {
3092 default:
3093 case eCSR_AUTH_TYPE_WPA:
3094 case eCSR_AUTH_TYPE_WPA_PSK:
3095 case eCSR_AUTH_TYPE_WPA_NONE:
3096 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3097 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3098 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003099 case eCSR_AUTH_TYPE_SHARED_KEY:
3100 pBssConfig->authType = eSIR_SHARED_KEY;
3101 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003102 case eCSR_AUTH_TYPE_AUTOSWITCH:
3103 pBssConfig->authType = eSIR_AUTO_SWITCH;
3104 break;
3105 }
3106 //short slot time
3107 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3108 {
3109 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3110 }
3111 else
3112 {
3113 pBssConfig->uShortSlotTime = 0;
3114 }
3115 //power constraint. We don't support 11h on IBSS
3116 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3117 pBssConfig->uPowerLimit = 0;
3118 //heartbeat
3119 if ( eCSR_BAND_5G == pBssConfig->eBand )
3120 {
3121 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3122 }
3123 else
3124 {
3125 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3126 }
3127 //Join timeout
3128 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003129
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 return (status);
3131}
Jeff Johnson295189b2012-06-20 16:38:30 -07003132static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3133{
3134 eHalStatus status = eHAL_STATUS_FAILURE;
3135 tDot11fBeaconIEs *pIes = NULL;
3136
3137 do
3138 {
3139 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3140 {
3141 //err msg
3142 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003143 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003144 break;
3145 }
3146 //check if the AP is QAP & it supports APSD
3147 if( CSR_IS_QOS_BSS(pIes) )
3148 {
3149 return eHAL_STATUS_SUCCESS;
3150 }
3151 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 return status;
3153}
3154
Jeff Johnson295189b2012-06-20 16:38:30 -07003155void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3156{
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3158 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3159 // See !!Note: below in this function...
3160 tANI_U32 PrivacyEnabled = 0;
3161 tANI_U32 RsnEnabled = 0;
3162 tANI_U32 WepDefaultKeyId = 0;
3163 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3164 tANI_U32 Key0Length = 0;
3165 tANI_U32 Key1Length = 0;
3166 tANI_U32 Key2Length = 0;
3167 tANI_U32 Key3Length = 0;
3168
3169 // Reserve for the biggest key
3170 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3171 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3172 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3173 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3174
3175 switch ( pProfile->negotiatedUCEncryptionType )
3176 {
3177 case eCSR_ENCRYPT_TYPE_NONE:
3178
3179 // for NO encryption, turn off Privacy and Rsn.
3180 PrivacyEnabled = 0;
3181 RsnEnabled = 0;
3182
3183 // WEP key length and Wep Default Key ID don't matter in this case....
3184
3185 // clear out the WEP keys that may be hanging around.
3186 Key0Length = 0;
3187 Key1Length = 0;
3188 Key2Length = 0;
3189 Key3Length = 0;
3190
3191 break;
3192
3193 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303194 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003195
3196 // Privacy is ON. NO RSN for Wep40 static key.
3197 PrivacyEnabled = 1;
3198 RsnEnabled = 0;
3199
3200 // Set the Wep default key ID.
3201 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 // Wep key size if 5 bytes (40 bits).
3203 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3204
3205 // set encryption keys in the CFG database or clear those that are not present in this profile.
3206 if ( pProfile->Keys.KeyLength[0] )
3207 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303208 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3209 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3211 }
3212 else
3213 {
3214 Key0Length = 0;
3215 }
3216
3217 if ( pProfile->Keys.KeyLength[1] )
3218 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303219 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3220 WNI_CFG_WEP_KEY_LENGTH_5);
3221 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003222 }
3223 else
3224 {
3225 Key1Length = 0;
3226 }
3227
3228 if ( pProfile->Keys.KeyLength[2] )
3229 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303230 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3231 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003232 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3233 }
3234 else
3235 {
3236 Key2Length = 0;
3237 }
3238
3239 if ( pProfile->Keys.KeyLength[3] )
3240 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303241 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3242 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003243 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3244 }
3245 else
3246 {
3247 Key3Length = 0;
3248 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 break;
3250
3251 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303252 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003253
3254 // Privacy is ON. NO RSN for Wep40 static key.
3255 PrivacyEnabled = 1;
3256 RsnEnabled = 0;
3257
3258 // Set the Wep default key ID.
3259 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3260
3261 // Wep key size if 13 bytes (104 bits).
3262 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3263
3264 // set encryption keys in the CFG database or clear those that are not present in this profile.
3265 if ( pProfile->Keys.KeyLength[0] )
3266 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303267 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3268 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3270 }
3271 else
3272 {
3273 Key0Length = 0;
3274 }
3275
3276 if ( pProfile->Keys.KeyLength[1] )
3277 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303278 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3279 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3281 }
3282 else
3283 {
3284 Key1Length = 0;
3285 }
3286
3287 if ( pProfile->Keys.KeyLength[2] )
3288 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303289 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3290 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003291 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3292 }
3293 else
3294 {
3295 Key2Length = 0;
3296 }
3297
3298 if ( pProfile->Keys.KeyLength[3] )
3299 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303300 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3301 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3303 }
3304 else
3305 {
3306 Key3Length = 0;
3307 }
3308
3309 break;
3310
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 case eCSR_ENCRYPT_TYPE_TKIP:
3312 case eCSR_ENCRYPT_TYPE_AES:
3313#ifdef FEATURE_WLAN_WAPI
3314 case eCSR_ENCRYPT_TYPE_WPI:
3315#endif /* FEATURE_WLAN_WAPI */
3316 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3317 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3318 PrivacyEnabled = (0 != fPrivacy);
3319
3320 // turn on RSN enabled for WPA associations
3321 RsnEnabled = 1;
3322
3323 // WEP key length and Wep Default Key ID don't matter in this case....
3324
3325 // clear out the static WEP keys that may be hanging around.
3326 Key0Length = 0;
3327 Key1Length = 0;
3328 Key2Length = 0;
3329 Key3Length = 0;
3330
3331 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003332 default:
3333 PrivacyEnabled = 0;
3334 RsnEnabled = 0;
3335 break;
3336 }
3337
3338 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3339 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3340 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3341 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3342 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3343 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3344 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3345 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3346}
3347
Jeff Johnson295189b2012-06-20 16:38:30 -07003348static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3349{
3350 tANI_U32 len = 0;
3351 if(pSSID->length <= WNI_CFG_SSID_LEN)
3352 {
3353 len = pSSID->length;
3354 }
3355 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3356}
3357
Jeff Johnson295189b2012-06-20 16:38:30 -07003358eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3359{
3360 eHalStatus status = eHAL_STATUS_SUCCESS;
3361 tANI_U32 QoSEnabled;
3362 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003363 // set the CFG enable/disable variables based on the qosType being configured...
3364 switch( qosType )
3365 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003366 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3367 QoSEnabled = FALSE;
3368 WmeEnabled = TRUE;
3369 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003370 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3371 QoSEnabled = FALSE;
3372 WmeEnabled = TRUE;
3373 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003374 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3375 QoSEnabled = FALSE;
3376 WmeEnabled = TRUE;
3377 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3379 QoSEnabled = TRUE;
3380 WmeEnabled = FALSE;
3381 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003382 case eCSR_MEDIUM_ACCESS_11e_HCF:
3383 QoSEnabled = TRUE;
3384 WmeEnabled = FALSE;
3385 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 default:
3387 case eCSR_MEDIUM_ACCESS_DCF:
3388 QoSEnabled = FALSE;
3389 WmeEnabled = FALSE;
3390 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003391 }
3392 //save the WMM setting for later use
3393 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 status = ccmCfgSetInt(pMac, WNI_CFG_QOS_ENABLED, QoSEnabled, NULL, eANI_BOOLEAN_FALSE);
3395 status = ccmCfgSetInt(pMac, WNI_CFG_WME_ENABLED, WmeEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 return (status);
3397}
Jeff Johnson295189b2012-06-20 16:38:30 -07003398static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3399 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3400{
3401 eHalStatus status = eHAL_STATUS_FAILURE;
3402 int i;
3403 eCsrCfgDot11Mode cfgDot11Mode;
3404 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303405 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3406 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003407 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003408
3409 if( NULL != pIes )
3410 {
3411 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003412 // Originally, we thought that for 11a networks, the 11a rates are always
3413 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3414 // appear in the Operational Rate set. Consequently, in either case, we
3415 // would blindly put the rates we support into our Operational Rate set
3416 // (including the basic rates, which we have already verified are
3417 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 // However, it turns out that this is not always the case. Some AP's
3419 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3420 // too. Now, we're a little more careful:
3421 pDstRate = pOpRateSet->rate;
3422 if(pIes->SuppRates.present)
3423 {
3424 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3425 {
3426 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3427 {
3428 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003429 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003430 }
3431 }
3432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3434 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3435 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3436 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3437 {
3438 // If there are Extended Rates in the beacon, we will reflect those
3439 // extended rates that we support in out Extended Operational Rate
3440 // set:
3441 pDstRate = pExRateSet->rate;
3442 if(pIes->ExtSuppRates.present)
3443 {
3444 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3445 {
3446 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3447 {
3448 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3449 pExRateSet->numRates++;
3450 }
3451 }
3452 }
3453 }
3454 }//Parsing BSSDesc
3455 else
3456 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003457 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 }
3459 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3460 return status;
3461}
3462
3463static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3464 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3465{
3466 int i;
3467 tANI_U8 *pDstRate;
3468 eCsrCfgDot11Mode cfgDot11Mode;
3469 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3470 tANI_U32 OperationalRatesLength = 0;
3471 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3472 tANI_U32 ExtendedOperationalRatesLength = 0;
3473 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3474 tANI_U32 ProprietaryOperationalRatesLength = 0;
3475 tANI_U32 PropRatesEnable = 0;
3476 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3477 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 if( NULL != pIes )
3480 {
3481 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003482 // Originally, we thought that for 11a networks, the 11a rates are always
3483 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3484 // appear in the Operational Rate set. Consequently, in either case, we
3485 // would blindly put the rates we support into our Operational Rate set
3486 // (including the basic rates, which we have already verified are
3487 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003488 // However, it turns out that this is not always the case. Some AP's
3489 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3490 // too. Now, we're a little more careful:
3491 pDstRate = OperationalRates;
3492 if(pIes->SuppRates.present)
3493 {
3494 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3495 {
3496 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3497 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3498 {
3499 *pDstRate++ = pIes->SuppRates.rates[ i ];
3500 OperationalRatesLength++;
3501 }
3502 }
3503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3505 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3506 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3507 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3508 {
3509 // If there are Extended Rates in the beacon, we will reflect those
3510 // extended rates that we support in out Extended Operational Rate
3511 // set:
3512 pDstRate = ExtendedOperationalRates;
3513 if(pIes->ExtSuppRates.present)
3514 {
3515 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3516 {
3517 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3518 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3519 {
3520 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3521 ExtendedOperationalRatesLength++;
3522 }
3523 }
3524 }
3525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003526 // Enable proprietary MAC features if peer node is Airgo node and STA
3527 // user wants to use them
3528 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3529 {
3530 PropRatesEnable = 1;
3531 }
3532 else
3533 {
3534 PropRatesEnable = 0;
3535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003536 // For ANI network companions, we need to populate the proprietary rate
3537 // set with any proprietary rates we found in the beacon, only if user
3538 // allows them...
3539 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3540 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3541 {
3542 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3543 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3544 {
3545 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3546 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303547 vos_mem_copy(ProprietaryOperationalRates,
3548 pIes->Airgo.PropSuppRates.rates,
3549 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 }
3551 else {
3552 // No proprietary modes...
3553 ProprietaryOperationalRatesLength = 0;
3554 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003555 /* Get MCS Rate */
3556 pDstRate = MCSRateIdxSet;
3557 if ( pIes->HTCaps.present )
3558 {
3559 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3560 {
3561 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3562 {
3563 MCSRateLength++;
3564 *pDstRate++ = i;
3565 }
3566 }
3567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 // Set the operational rate set CFG variables...
3569 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3570 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3571 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3572 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3573 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3574 ProprietaryOperationalRates,
3575 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3576 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3577 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3578 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3579 }//Parsing BSSDesc
3580 else
3581 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003582 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003583 }
3584}
3585
Jeff Johnson295189b2012-06-20 16:38:30 -07003586static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3587 tCsrRoamProfile *pProfile )
3588{
3589 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3590 { 8,
3591 { SIR_MAC_RATE_6,
3592 SIR_MAC_RATE_9,
3593 SIR_MAC_RATE_12,
3594 SIR_MAC_RATE_18,
3595 SIR_MAC_RATE_24,
3596 SIR_MAC_RATE_36,
3597 SIR_MAC_RATE_48,
3598 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3600 { 4,
3601 { SIR_MAC_RATE_1,
3602 SIR_MAC_RATE_2,
3603 SIR_MAC_RATE_5_5,
3604 SIR_MAC_RATE_11 } } };
3605
3606
3607 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3608 { SIR_MAC_RATE_72,
3609 SIR_MAC_RATE_96,
3610 SIR_MAC_RATE_108 } };
3611 eCsrCfgDot11Mode cfgDot11Mode;
3612 eCsrBand eBand;
3613 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3614 tANI_U32 OperationalRatesLength = 0;
3615 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3616 tANI_U32 ExtendedOperationalRatesLength = 0;
3617 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3618 tANI_U32 ProprietaryOperationalRatesLength = 0;
3619 tANI_U32 PropRatesEnable = 0;
3620 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 if(pProfile->ChannelInfo.ChannelList)
3622 {
3623 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3624 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3627 // networks, the 11b rates appear in the Operational Rate set. In either case,
3628 // we can blindly put the rates we support into our Operational Rate set
3629 // (including the basic rates, which we have already verified are supported
3630 // earlier in the roaming decision).
3631 if ( eCSR_BAND_5G == eBand )
3632 {
3633 // 11a rates into the Operational Rate Set.
3634 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3635 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303636 vos_mem_copy(OperationalRates,
3637 DefaultSupportedRates11a.supportedRateSet.rate,
3638 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003639
3640 // Nothing in the Extended rate set.
3641 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 // populate proprietary rates if user allows them
3643 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3644 {
3645 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3646 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303647 vos_mem_copy(ProprietaryOperationalRates,
3648 DefaultSupportedPropRates.propRate,
3649 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 }
3651 else
3652 {
3653 // No proprietary modes
3654 ProprietaryOperationalRatesLength = 0;
3655 }
3656 }
3657 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3658 {
3659 // 11b rates into the Operational Rate Set.
3660 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3661 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303662 vos_mem_copy(OperationalRates,
3663 DefaultSupportedRates11b.supportedRateSet.rate,
3664 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003665 // Nothing in the Extended rate set.
3666 ExtendedOperationalRatesLength = 0;
3667 // No proprietary modes
3668 ProprietaryOperationalRatesLength = 0;
3669 }
3670 else
3671 {
3672 // 11G
3673
3674 // 11b rates into the Operational Rate Set.
3675 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3676 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303677 vos_mem_copy(OperationalRates,
3678 DefaultSupportedRates11b.supportedRateSet.rate,
3679 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003680
3681 // 11a rates go in the Extended rate set.
3682 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3683 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303684 vos_mem_copy(ExtendedOperationalRates,
3685 DefaultSupportedRates11a.supportedRateSet.rate,
3686 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003687
3688 // populate proprietary rates if user allows them
3689 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3690 {
3691 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3692 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303693 vos_mem_copy(ProprietaryOperationalRates,
3694 DefaultSupportedPropRates.propRate,
3695 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 }
3697 else
3698 {
3699 // No proprietary modes
3700 ProprietaryOperationalRatesLength = 0;
3701 }
3702 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3704 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3705 {
3706 PropRatesEnable = 1;
3707 }
3708 else
3709 {
3710 PropRatesEnable = 0;
3711 }
3712
3713 // Set the operational rate set CFG variables...
3714 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3715 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3716 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3717 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3718 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3719 ProprietaryOperationalRates,
3720 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3721 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003722}
Jeff Johnson295189b2012-06-20 16:38:30 -07003723void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3724{
3725 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003726
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3728 tANI_U32 sessionId;
3729 tSmeCmd *pCommand = NULL;
3730
3731 if(NULL == pEntry)
3732 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003733 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 return;
3735 }
3736 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3737 sessionId = pCommand->sessionId;
3738
3739 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3740 {
3741 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3742 }
3743}
3744
Jeff Johnson295189b2012-06-20 16:38:30 -07003745//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3746tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3747{
3748 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3749 {
3750 return (WNI_CFG_PHY_MODE_11B);
3751 }
3752 else
3753 {
3754 if(eCSR_BAND_24 == band)
3755 return (WNI_CFG_PHY_MODE_11G);
3756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003757 return (WNI_CFG_PHY_MODE_11A);
3758}
Jeff Johnson295189b2012-06-20 16:38:30 -07003759
Jeff Johnsone7245742012-09-05 17:12:55 -07003760
3761#ifdef WLAN_FEATURE_11AC
3762ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3763{
3764 switch ( aniCBMode )
3765 {
3766 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3767 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3768 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3769 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3770 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3771 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3772 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3773 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3774 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003775 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003776 return PHY_SINGLE_CHANNEL_CENTERED;
3777 }
3778}
3779#endif
3780
Jeff Johnson295189b2012-06-20 16:38:30 -07003781//pIes may be NULL
3782eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3783 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303784 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003785{
3786 eHalStatus status = eHAL_STATUS_SUCCESS;
3787 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3788 tANI_U8 channel = 0;
3789 //Make sure we have the domain info for the BSS we try to connect to.
3790 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303791 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303793 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 {
3795 //Make sure the 11d info from this BSSDesc can be applied
3796 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303797 if (VOS_TRUE == resetCountry)
3798 {
3799 csrApplyCountryInformation(pMac, FALSE);
3800 }
3801 else
3802 {
3803 csrApplyCountryInformation(pMac, TRUE);
3804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 }
Kiran4a17ebe2013-01-31 10:43:43 -08003806 if ((csrIs11dSupported (pMac)) && pIes)
3807 {
3808 if (!pIes->Country.present)
3809 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
3810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 //Qos
3813 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3814 //SSID
3815 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3816 //fragment threshold
3817 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3818 //RTS threshold
3819 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3820
3821 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
3822
3823 //Auth type
3824 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3825 //encryption type
3826 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3827 //short slot time
3828 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003829 //11d
3830 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3831 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3832 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003833 /*//11h
3834 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3835 */
3836 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3837 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003838
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003839 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 {
3841 channel = pProfile->operationChannel;
3842 }
3843 else
3844 {
3845 if(pBssDesc)
3846 {
3847 channel = pBssDesc->channelId;
3848 }
3849 }
3850 if(0 != channel)
3851 {
3852 if(CSR_IS_CHANNEL_24GHZ(channel))
3853 {//for now if we are on 2.4 Ghz, CB will be always disabled
3854 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3855 }
3856 else
3857 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003858 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003859 }
3860 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003861#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003862 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3863 // in function csrConvertCBIniValueToPhyCBState()
3864 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3865 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003866 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003867 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003868 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003869 }
3870 else
3871 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003872 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003873 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003874 }
3875 else
3876#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3878 //Rate
3879 //Fixed Rate
3880 if(pBssDesc)
3881 {
3882 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3883 }
3884 else
3885 {
3886 csrSetCfgRateSetFromProfile(pMac, pProfile);
3887 }
3888 //Make this the last CFG to set. The callback will trigger a join_req
3889 //Join time out
3890 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3891
3892 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003893 return (status);
3894}
3895
Jeff Johnson295189b2012-06-20 16:38:30 -07003896eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3897 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3898{
3899 eHalStatus status;
3900 tBssConfigParam *pBssConfig;
3901 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003902
3903 if(!pSession)
3904 {
3905 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3906 return eHAL_STATUS_FAILURE;
3907 }
3908
Kiet Lam64c1b492013-07-12 13:56:44 +05303909 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
3910 if ( NULL == pBssConfig )
3911 status = eHAL_STATUS_FAILURE;
3912 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303914 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3916 if(HAL_STATUS_SUCCESS(status))
3917 {
3918 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003919 /* This will allow to pass cbMode during join req */
3920 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 //For IBSS, we need to prepare some more information
3922 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 )
3925 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003926 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003927 }
3928 // If we are in an IBSS, then stop the IBSS...
3929 ////Not worry about WDS connection for now
3930 if ( csrIsConnStateIbss( pMac, sessionId ) )
3931 {
3932 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3933 }
3934 else
3935 {
3936 // if we are in an Infrastructure association....
3937 if ( csrIsConnStateInfra( pMac, sessionId ) )
3938 {
3939 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3940 // across SSIDs (roaming to a new SSID)... //
3941 //Not worry about WDS connection for now
3942 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303943 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 {
3945 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303946 status = csrRoamIssueDisassociate( pMac, sessionId,
3947 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003948 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303949 else
3950 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003951 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3952 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303953 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303955 // Set parameters for this Bss.
3956 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3957 pBssDesc, pBssConfig,
3958 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303962 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003963 {
3964 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3965 // Nothing to stop.
3966 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303968 )
3969 {
3970 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3971 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3972 // Set parameters for this Bss.
3973 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3974 pBssDesc, pBssConfig,
3975 pIes, is11rRoamingFlag);
3976 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003977 }
3978 }
3979 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05303980 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07003982 return (status);
3983}
3984
Jeff Johnson295189b2012-06-20 16:38:30 -07003985eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3986 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3987{
3988 eCsrJoinState eRoamState = eCsrContinueRoaming;
3989 eHalStatus status;
3990 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3991 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3992 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003993
3994 if(!pSession)
3995 {
3996 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3997 return (eCsrStopRoaming);
3998 }
3999
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 if( CSR_IS_WDS_STA( pProfile ) )
4001 {
4002 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4003 if( !HAL_STATUS_SUCCESS( status ) )
4004 {
4005 eRoamState = eCsrStopRoaming;
4006 }
4007 }
4008 else
4009 {
4010 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4011 {
4012 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4013 return (eCsrStopRoaming);
4014 }
4015 if ( csrIsInfraBssDesc( pBssDesc ) )
4016 {
4017 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4018 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4019 // have changed and handle the changes (without disturbing the current association).
4020
4021 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4022 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4023 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4024 )
4025 {
4026 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4027 // with Authenticating first. To force this, stop the current association (Disassociate) and
4028 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4029 // a new Association.
4030 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4031 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004032 smsLog(pMac, LOGW, FL(" detect same profile authType = %d encryType = %d"), pProfile->AuthType, pProfile->EncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4034 {
4035 eRoamState = eCsrReassocToSelfNoCapChange;
4036 }
4037 else
4038 {
4039 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004040 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304041 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4043 if(HAL_STATUS_SUCCESS(status))
4044 {
4045 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004046 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004047 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304048 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4049 pBssDesc, &bssConfig,
4050 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 if(!HAL_STATUS_SUCCESS(status))
4052 {
4053 eRoamState = eCsrStopRoaming;
4054 }
4055 }
4056 else
4057 {
4058 eRoamState = eCsrStopRoaming;
4059 }
4060 }//same profile
4061 }
4062 else
4063 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304064 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4066 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004067 smsLog(pMac, LOGW, FL(" fail to issue disassociate"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304069 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304071 }
4072 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 {
4074 // 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 +05304075 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 // work much better.
4077 //
4078 //
4079 // stop the existing network before attempting to join the new network...
4080 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4081 {
4082 eRoamState = eCsrStopRoaming;
4083 }
4084 }
4085 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304086 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004087 {
4088 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4089 {
4090 eRoamState = eCsrStopRoaming;
4091 }
4092 }
4093 if( pIesLocal && !pScanResult->pvIes )
4094 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304095 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004096 }
4097 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 return( eRoamState );
4099}
4100
Jeff Johnson295189b2012-06-20 16:38:30 -07004101eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4102 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4103{
4104 eHalStatus status = eHAL_STATUS_SUCCESS;
4105 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304106 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 roamInfo.pBssDesc = pBssDesc;
4108 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4109 return (status);
4110}
Jeff Johnson295189b2012-06-20 16:38:30 -07004111//In case no matching BSS is found, use whatever default we can find
4112static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4113{
4114 //Need to get all negotiated types in place first
4115 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004116 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 {
4118 default:
4119 case eCSR_AUTH_TYPE_WPA:
4120 case eCSR_AUTH_TYPE_WPA_PSK:
4121 case eCSR_AUTH_TYPE_WPA_NONE:
4122 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4123 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4124 break;
4125
4126 case eCSR_AUTH_TYPE_SHARED_KEY:
4127 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4128 break;
4129
4130 case eCSR_AUTH_TYPE_AUTOSWITCH:
4131 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4132 break;
4133 }
4134 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4135 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4136 //In this case, the multicast encryption needs to follow the uncast ones.
4137 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4138 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4139}
4140
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004141
4142static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4143{
4144 switch(pCommand->u.roamCmd.roamReason)
4145 {
4146 case eCsrLostLink1:
4147 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4148 break;
4149 case eCsrLostLink2:
4150 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4151 break;
4152 case eCsrLostLink3:
4153 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4154 break;
4155 default:
4156 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4157 pCommand->u.roamCmd.roamReason);
4158 break;
4159 }
4160}
4161
Jeff Johnson295189b2012-06-20 16:38:30 -07004162static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4163{
4164 eHalStatus status;
4165 tCsrScanResult *pScanResult = NULL;
4166 eCsrJoinState eRoamState = eCsrStopRoaming;
4167 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4168 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4169 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4170#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4171 v_U8_t acm_mask = 0;
4172#endif
4173 tANI_U32 sessionId = pCommand->sessionId;
4174 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4175 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4176 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004177
4178 if(!pSession)
4179 {
4180 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4181 return (eCsrStopRoaming);
4182 }
4183
Jeff Johnson295189b2012-06-20 16:38:30 -07004184 do
4185 {
4186 // Check for Cardbus eject condition, before trying to Roam to any BSS
4187 //***if( !balIsCardPresent(pAdapter) ) break;
4188
Kiet Lam64c1b492013-07-12 13:56:44 +05304189 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004190 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 if(NULL != pBSSList)
4192 {
4193 // When handling AP's capability change, continue to associate to
4194 // same BSS and make sure pRoamBssEntry is not Null.
4195 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4196 {
4197 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4198 {
4199 //Try the first BSS
4200 pCommand->u.roamCmd.pLastRoamBss = NULL;
4201 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4202 }
4203 else
4204 {
4205 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4206 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4207 {
4208 //Done with all the BSSs
4209 //In this case, will tell HDD the completion
4210 break;
4211 }
4212 else
4213 {
4214 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304215 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4217 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4218 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4219 pRoamInfo = &roamInfo;
4220 }
4221 }
4222 while(pCommand->u.roamCmd.pRoamBssEntry)
4223 {
4224 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004225 /*If concurrency enabled take the concurrent connected channel first. */
4226 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004227 if (vos_concurrent_sessions_running() &&
4228 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 {
4230 concurrentChannel =
4231 csrGetConcurrentOperationChannel(pMac);
4232 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004233 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004234 if ((concurrentChannel) &&
4235 (concurrentChannel ==
4236 pScanResult->Result.BssDescriptor.channelId))
4237 {
4238 //make this 0 because we do not want the
4239 //below check to pass as we don't want to
4240 //connect on other channel
4241 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4242 FL("Concurrent channel match =%d"),
4243 concurrentChannel);
4244 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 }
4246 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004247
4248 if (!concurrentChannel)
4249 {
4250
4251 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4252 sessionId, &pScanResult->Result.BssDescriptor,
4253 pCommand->u.roamCmd.roamId)))
4254 {
4255 //Ok to roam this
4256 break;
4257 }
4258 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004259 else
4260 {
4261 eRoamState = eCsrStopRoamingDueToConcurrency;
4262 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004263 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4264 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4265 {
4266 //Done with all the BSSs
4267 fDone = eANI_BOOLEAN_TRUE;
4268 break;
4269 }
4270 }
4271 if(fDone)
4272 {
4273 break;
4274 }
4275 }
4276 }
4277 //We have something to roam, tell HDD when it is infra.
4278 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4279 //For WDS, the indication is eCSR_ROAM_WDS_IND
4280 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4281 {
4282 if(pRoamInfo)
4283 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004284 if(pSession->bRefAssocStartCnt)
4285 {
4286 pSession->bRefAssocStartCnt--;
4287 //Complete the last association attemp because a new one is about to be tried
4288 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4289 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004291 }
4292 }
4293 /* If the roaming has stopped, not to continue the roaming command*/
4294 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4295 {
4296 //No need to complete roaming here as it already completes
4297 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4298 pCommand->u.roamCmd.roamReason);
4299 eRoamState = eCsrStopRoaming;
4300 csrSetAbortRoamingCommand(pMac, pCommand);
4301 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304303 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 if(pScanResult)
4305 {
4306 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004307 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4308 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004309 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004310 fDone = eANI_BOOLEAN_TRUE;
4311 eRoamState = eCsrStopRoaming;
4312 break;
4313 }
4314 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4315 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4316 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4317 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4318 CSR_IS_QOS_BSS(pIesLocal) &&
4319 CSR_IS_UAPSD_BSS(pIesLocal) )
4320 {
4321#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004322 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4323 pIesLocal);
4324 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4325#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 }
4327 else
4328 {
4329 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4330 }
4331 if( pIesLocal && !pScanResult->Result.pvIes)
4332 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304333 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004334 }
4335 }
4336 else
4337 {
4338 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4339 }
4340 roamInfo.pProfile = pProfile;
4341 pSession->bRefAssocStartCnt++;
4342 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4343 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4344 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4346 {
4347 // If this is a start IBSS profile, then we need to start the IBSS.
4348 if ( CSR_IS_START_IBSS(pProfile) )
4349 {
4350 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 // Attempt to start this IBSS...
4352 csrRoamAssignDefaultParam( pMac, pCommand );
4353 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4354 if(HAL_STATUS_SUCCESS(status))
4355 {
4356 if ( fSameIbss )
4357 {
4358 eRoamState = eCsrStartIbssSameIbss;
4359 }
4360 else
4361 {
4362 eRoamState = eCsrContinueRoaming;
4363 }
4364 }
4365 else
4366 {
4367 //it somehow fail need to stop
4368 eRoamState = eCsrStopRoaming;
4369 }
4370 break;
4371 }
4372 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004373 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004374 )
4375 {
4376 // Attempt to start this WDS...
4377 csrRoamAssignDefaultParam( pMac, pCommand );
4378 /* For AP WDS, we dont have any BSSDescription */
4379 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4380 if(HAL_STATUS_SUCCESS(status))
4381 {
4382 eRoamState = eCsrContinueRoaming;
4383 }
4384 else
4385 {
4386 //it somehow fail need to stop
4387 eRoamState = eCsrStopRoaming;
4388 }
4389 }
4390 else
4391 {
4392 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004393 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 eRoamState = eCsrStopRoaming;
4395 break;
4396 }
4397 }
4398 else //We have BSS
4399 {
4400 //Need to assign these value because they are used in csrIsSameProfile
4401 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4402 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4403 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4404 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4405 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4406 {
4407 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4408 {
4409 eRoamState = eCsrStartIbssSameIbss;
4410 break;
4411 }
4412 }
4413 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4414 {
4415 //trying to connect to the one already connected
4416 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4417 eRoamState = eCsrReassocToSelfNoCapChange;
4418 break;
4419 }
4420 // Attempt to Join this Bss...
4421 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4422 break;
4423 }
4424
4425 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4427 {
4428 //Need to indicate association_completion if association_start has been done
4429 if(pSession->bRefAssocStartCnt > 0)
4430 {
4431 pSession->bRefAssocStartCnt--;
4432 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004433 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004434 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4435 eCSR_ROAM_ASSOCIATION_COMPLETION,
4436 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4437 }
4438 }
4439
4440 return( eRoamState );
4441}
4442
Jeff Johnson295189b2012-06-20 16:38:30 -07004443static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4444{
4445 eHalStatus status = eHAL_STATUS_SUCCESS;
4446 eCsrJoinState RoamState;
4447 tANI_U32 sessionId = pCommand->sessionId;
4448
Jeff Johnson295189b2012-06-20 16:38:30 -07004449 //***if( hddIsRadioStateOn( pAdapter ) )
4450 {
4451 // Attept to join a Bss...
4452 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004453
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004455 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 {
4457 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004458 // and if connected in Infrastructure mode...
4459 if ( csrIsConnStateInfra(pMac, sessionId) )
4460 {
4461 //... then we need to issue a disassociation
4462 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4463 if(!HAL_STATUS_SUCCESS(status))
4464 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004465 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 //roam command is completed by caller in the failed case
4467 fComplete = eANI_BOOLEAN_TRUE;
4468 }
4469 }
4470 else if( csrIsConnStateIbss(pMac, sessionId) )
4471 {
4472 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4473 if(!HAL_STATUS_SUCCESS(status))
4474 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004475 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 //roam command is completed by caller in the failed case
4477 fComplete = eANI_BOOLEAN_TRUE;
4478 }
4479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4481 {
4482 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4483 if(!HAL_STATUS_SUCCESS(status))
4484 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004485 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 //roam command is completed by caller in the failed case
4487 fComplete = eANI_BOOLEAN_TRUE;
4488 }
4489 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 else
4491 {
4492 fComplete = eANI_BOOLEAN_TRUE;
4493 }
4494 if(fComplete)
4495 {
4496 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004497 if(eCsrStopRoamingDueToConcurrency == RoamState)
4498 {
4499 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4500 }
4501 else
4502 {
4503 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4504 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 }
4506 }
4507 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4508 {
4509 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4510 }
4511 else if ( eCsrStartIbssSameIbss == RoamState )
4512 {
4513 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4514 }
4515 }//hddIsRadioStateOn
4516
4517 return status;
4518}
Jeff Johnson295189b2012-06-20 16:38:30 -07004519eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4520{
4521 tANI_U32 sessionId;
4522 tCsrRoamSession *pSession;
4523 tCsrScanResult *pScanResult = NULL;
4524 tSirBssDescription *pBssDesc = NULL;
4525 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004526 sessionId = pCommand->sessionId;
4527 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004528
4529 if(!pSession)
4530 {
4531 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4532 return eHAL_STATUS_FAILURE;
4533 }
4534
Jeff Johnson295189b2012-06-20 16:38:30 -07004535 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4536 {
4537 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004538 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4540 return eHAL_STATUS_FAILURE;
4541 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 if (pCommand->u.roamCmd.pRoamBssEntry)
4543 {
4544 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4545 pBssDesc = &pScanResult->Result.BssDescriptor;
4546 }
4547 else
4548 {
4549 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004550 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4552 return eHAL_STATUS_FAILURE;
4553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004554 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4555 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4556 return status;
4557}
4558
Jeff Johnson295189b2012-06-20 16:38:30 -07004559eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4560{
4561 eHalStatus status = eHAL_STATUS_SUCCESS;
4562 tCsrRoamInfo roamInfo;
4563 tANI_U32 sessionId = pCommand->sessionId;
4564 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004565
4566 if(!pSession)
4567 {
4568 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4569 return eHAL_STATUS_FAILURE;
4570 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004571
4572 switch ( pCommand->u.roamCmd.roamReason )
4573 {
4574 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004576 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 case eCsrSmeIssuedDisassocForHandoff:
4579 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4580#if 0 // TODO : Confirm this change
4581 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4582#else
4583 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4584#endif
4585
4586 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004587 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004589 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004591 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004593 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 case eCsrHddIssuedReassocToSameAP:
4596 case eCsrSmeIssuedReassocToSameAP:
4597 {
4598 tDot11fBeaconIEs *pIes = NULL;
4599
Jeff Johnson295189b2012-06-20 16:38:30 -07004600 if( pSession->pConnectBssDesc )
4601 {
4602 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4603 if(!HAL_STATUS_SUCCESS(status) )
4604 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004605 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 }
4607 else
4608 {
4609 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4610 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4611 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4613 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4614 pSession->bRefAssocStartCnt++;
4615 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4616 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4617
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004618 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004619 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4620 &pCommand->u.roamCmd.roamProfile );
4621 if(!HAL_STATUS_SUCCESS(status))
4622 {
4623 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004624 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004625 }
4626
Kiet Lam64c1b492013-07-12 13:56:44 +05304627 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004628 pIes = NULL;
4629 }
4630 }
4631 break;
4632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004633 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004634 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004635 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4636 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4637 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004639 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004640 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4641 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004642
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 case eCsrStopBss:
4644 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4645 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4646 break;
4647
4648 case eCsrForcedDisassocSta:
4649 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4650 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4651 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4652 pCommand->u.roamCmd.reason);
4653 break;
4654
4655 case eCsrForcedDeauthSta:
4656 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4657 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4658 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4659 pCommand->u.roamCmd.reason);
4660 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004661
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004662 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004663 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004664 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4665 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004666 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004667
4668 default:
4669 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4670
4671 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4672 {
4673 //Remember the roaming profile
4674 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304675 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4676 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304678 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004679 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4680 }
4681 }
4682
4683 //At this point, original uapsd_mask is saved in pCurRoamProfile
4684 //uapsd_mask in the pCommand may change from this point on.
4685
4686 // Attempt to roam with the new scan results (if we need to..)
4687 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004688 if(!HAL_STATUS_SUCCESS(status))
4689 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004690 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004691 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004692 break;
4693 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 return (status);
4695}
4696
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004697void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4698{
4699 pCommand->u.roamCmd.pLastRoamBss = NULL;
4700 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4701 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304702 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004703}
4704
Jeff Johnson295189b2012-06-20 16:38:30 -07004705void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4706{
4707 if(pCommand->u.roamCmd.fReleaseBssList)
4708 {
4709 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4710 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4711 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4712 }
4713 if(pCommand->u.roamCmd.fReleaseProfile)
4714 {
4715 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4716 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4717 }
4718 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4719 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304720 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004721}
4722
Jeff Johnson295189b2012-06-20 16:38:30 -07004723void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4724{
Kiet Lam64c1b492013-07-12 13:56:44 +05304725 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004726}
Jeff Johnson295189b2012-06-20 16:38:30 -07004727void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4728{
4729 tListElem *pEntry;
4730 tSmeCmd *pCommand;
4731 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004732 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004733 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4734 if ( pEntry )
4735 {
4736 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 // If the head of the queue is Active and it is a ROAM command, remove
4738 // and put this on the Free queue.
4739 if ( eSmeCommandRoam == pCommand->command )
4740 {
4741 //we need to process the result first before removing it from active list because state changes
4742 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4743 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4744 if( fReleaseCommand )
4745 {
4746 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4747 {
4748 csrReleaseCommandRoam( pMac, pCommand );
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, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004759 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 }
4761 }
4762 else
4763 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004764 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004765 }
4766 }
4767 else
4768 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004769 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 if( fReleaseCommand )
4772 {
4773 smeProcessPendingQueue( pMac );
4774 }
4775}
4776
Jeff Johnson295189b2012-06-20 16:38:30 -07004777void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4778{
4779 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004780 if(!pSession)
4781 {
4782 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4783 return;
4784 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304785 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4786 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004787 pSession->NumPmkidCandidate = 0;
4788}
Jeff Johnson295189b2012-06-20 16:38:30 -07004789#ifdef FEATURE_WLAN_WAPI
4790void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4791{
4792 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004793 if(!pSession)
4794 {
4795 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4796 return;
4797 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304798 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4799 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004800 pSession->NumBkidCandidate = 0;
4801}
4802#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004803extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4804
Jeff Johnson295189b2012-06-20 16:38:30 -07004805static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4806 tSirBssDescription *pSirBssDesc,
4807 tDot11fBeaconIEs *pIes)
4808{
4809 eHalStatus status = eHAL_STATUS_SUCCESS;
4810 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4811 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004812
4813 if(!pSession)
4814 {
4815 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4816 return eHAL_STATUS_FAILURE;
4817 }
4818
Jeff Johnson295189b2012-06-20 16:38:30 -07004819 if((eCSR_AUTH_TYPE_WPA == authType) ||
4820 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4821 (eCSR_AUTH_TYPE_RSN == authType) ||
4822 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4823#if defined WLAN_FEATURE_VOWIFI_11R
4824 ||
4825 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4826 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4827#endif /* FEATURE_WLAN_WAPI */
4828#ifdef FEATURE_WLAN_WAPI
4829 ||
4830 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4831 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4832#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004833#ifdef WLAN_FEATURE_11W
4834 ||
4835 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4836#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004837 )
4838 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4840 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004841 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 }
4843 if( pIesLocal )
4844 {
4845 tANI_U32 nIeLen;
4846 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004847 if((eCSR_AUTH_TYPE_RSN == authType) ||
4848#if defined WLAN_FEATURE_VOWIFI_11R
4849 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4850 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4851#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004852#if defined WLAN_FEATURE_11W
4853 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4854#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4856 {
4857 if(pIesLocal->RSN.present)
4858 {
4859 //Calculate the actual length
4860 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4861 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4862 + 2 //akm_suite_count
4863 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4864 + 2; //reserved
4865 if( pIesLocal->RSN.pmkid_count )
4866 {
4867 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4868 }
4869 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304870 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4871 if (NULL == pSession->pWpaRsnRspIE)
4872 status = eHAL_STATUS_FAILURE;
4873 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004874 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304875 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4877 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4878 //copy upto akm_suites
4879 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304880 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4881 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004882 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304883 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4884 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004885 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304886 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4887 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004888 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004889 if( pIesLocal->RSN.pwise_cipher_suite_count )
4890 {
4891 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304892 vos_mem_copy(pIeBuf,
4893 pIesLocal->RSN.pwise_cipher_suites,
4894 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4896 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304897 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004898 pIeBuf += 2;
4899 if( pIesLocal->RSN.akm_suite_count )
4900 {
4901 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304902 vos_mem_copy(pIeBuf,
4903 pIesLocal->RSN.akm_suites,
4904 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004905 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4906 }
4907 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05304908 vos_mem_copy(pIeBuf,
4909 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
4910 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4912 }
4913 }
4914 }
4915 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4916 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4917 {
4918 if(pIesLocal->WPA.present)
4919 {
4920 //Calculate the actual length
4921 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4922 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4923 + 2 //auth_suite_count
4924 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4925 // The WPA capabilities follows the Auth Suite (two octects)--
4926 // this field is optional, and we always "send" zero, so just
4927 // remove it. This is consistent with our assumptions in the
4928 // frames compiler; c.f. bug 15234:
4929 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304930
4931 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4932 if ( NULL == pSession->pWpaRsnRspIE )
4933 status = eHAL_STATUS_FAILURE;
4934 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004935 {
4936 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4937 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4938 pIeBuf = pSession->pWpaRsnRspIE + 2;
4939 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05304940 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304942 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
4943 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004944 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304945 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
4946 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4948 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4949 }
4950 }
4951 }
4952#ifdef FEATURE_WLAN_WAPI
4953 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4954 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4955 {
4956 if(pIesLocal->WAPI.present)
4957 {
4958 //Calculate the actual length
4959 nIeLen = 4 //version + akm_suite_count
4960 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4961 + 2 //pwise_cipher_suite_count
4962 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4963 + 6; //gp_cipher_suite + preauth + reserved
4964 if( pIesLocal->WAPI.bkid_count )
4965 {
4966 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4967 }
4968
4969 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304970 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
4971 if ( NULL == pSession->pWapiRspIE )
4972 status = eHAL_STATUS_FAILURE;
4973 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 {
4975 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4976 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4977 pIeBuf = pSession->pWapiRspIE + 2;
4978 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05304979 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 pIeBuf += 4;
4981 if( pIesLocal->WAPI.akm_suite_count )
4982 {
4983 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304984 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
4985 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304987 }
4988 vos_mem_copy(pIeBuf,
4989 &pIesLocal->WAPI.unicast_cipher_suite_count,
4990 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004991 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4993 {
4994 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304995 vos_mem_copy( pIeBuf,
4996 pIesLocal->WAPI.unicast_cipher_suites,
4997 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4999 }
lukez3c809222013-05-03 10:23:02 -07005000 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305001 vos_mem_copy(pIeBuf,
5002 pIesLocal->WAPI.multicast_cipher_suite,
5003 4);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305004 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305005 vos_mem_copy(pIeBuf,
5006 pIesLocal->WAPI.multicast_cipher_suite + 4,
5007 2);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305008 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305009 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5010
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 pIeBuf += 8;
5012 if( pIesLocal->WAPI.bkid_count )
5013 {
5014 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305015 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5016 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005017 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5018 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305019 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005021 }
5022 }
5023#endif /* FEATURE_WLAN_WAPI */
5024 if( !pIes )
5025 {
5026 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305027 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005028 }
5029 }
5030 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005031 return (status);
5032}
5033
Jeff Johnson295189b2012-06-20 16:38:30 -07005034static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5035{
5036 v_U8_t bACWeights[WLANTL_MAX_AC];
5037 v_U8_t paramBk, paramBe, paramVi, paramVo;
5038 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005039 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5040 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5041 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5042 //This doesn't address the case where the lower AC needs a real higher weight
5043 if( pIEs->WMMParams.present )
5044 {
5045 //no change to the lowest ones
5046 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5047 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5048 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5049 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5050 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5051 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5052 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5053 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5054 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5055 {
5056 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5057 fWeightChange = VOS_TRUE;
5058 }
5059 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5060 {
5061 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5062 fWeightChange = VOS_TRUE;
5063 }
5064 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5065 {
5066 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5067 fWeightChange = VOS_TRUE;
5068 }
5069 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5070 {
5071 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5072 fWeightChange = VOS_TRUE;
5073 }
5074 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5075 {
5076 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5077 fWeightChange = VOS_TRUE;
5078 }
5079 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5080 {
5081 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5082 fWeightChange = VOS_TRUE;
5083 }
5084 if(fWeightChange)
5085 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005086 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005087 bACWeights[2], bACWeights[3]);
5088 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5089 }
5090 }
5091}
Jeff Johnson295189b2012-06-20 16:38:30 -07005092#ifdef WLAN_FEATURE_VOWIFI_11R
5093//Returns whether the current association is a 11r assoc or not
5094tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5095{
5096#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5097 return csrNeighborRoamIs11rAssoc(pMac);
5098#else
5099 return eANI_BOOLEAN_FALSE;
5100#endif
5101}
5102#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005103#ifdef FEATURE_WLAN_CCX
5104//Returns whether the current association is a CCX assoc or not
5105tANI_BOOLEAN csrRoamIsCCXAssoc(tpAniSirGlobal pMac)
5106{
5107#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5108 return csrNeighborRoamIsCCXAssoc(pMac);
5109#else
5110 return eANI_BOOLEAN_FALSE;
5111#endif
5112}
5113#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005114#ifdef FEATURE_WLAN_LFR
5115//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305116tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005117{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305118 tCsrRoamSession *pSession = NULL;
5119
5120 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5121 {
5122 pSession = CSR_GET_SESSION( pMac, sessionId );
5123 if (NULL != pSession->pCurRoamProfile)
5124 {
5125 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5126 {
5127 return eANI_BOOLEAN_FALSE;
5128 }
5129 }
5130 }
5131
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005132#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5133 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5134 {
5135 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5136 }
5137 else
5138#endif
5139 {
5140 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005141 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005142 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005143}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005144
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005145#ifdef FEATURE_WLAN_CCX
5146/* ---------------------------------------------------------------------------
5147
5148 \fn csrNeighborRoamIsCCXAssoc
5149
5150 \brief This function returns whether the current association is a CCX assoc or not
5151
5152 \param pMac - The handle returned by macOpen.
5153
5154 \return eANI_BOOLEAN_TRUE if current assoc is CCX, eANI_BOOLEAN_FALSE otherwise
5155
5156---------------------------------------------------------------------------*/
5157tANI_BOOLEAN csrNeighborRoamIsCCXAssoc(tpAniSirGlobal pMac)
5158{
5159 return pMac->roam.neighborRoamInfo.isCCXAssoc;
5160}
5161#endif /* FEATURE_WLAN_CCX */
5162
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005163#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5164//Returns whether "FW based BG scan" is currently enabled...or not
5165tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5166{
5167 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5168}
5169#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005170#endif
5171
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005172#if defined(FEATURE_WLAN_CCX)
5173tANI_BOOLEAN csrRoamIsCcxIniFeatureEnabled(tpAniSirGlobal pMac)
5174{
5175 return pMac->roam.configParam.isCcxIniFeatureEnabled;
5176}
5177#endif /*FEATURE_WLAN_CCX*/
5178
Jeff Johnson295189b2012-06-20 16:38:30 -07005179//Return true means the command can be release, else not
5180static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5181 eCsrRoamCompleteResult Result, void *Context )
5182{
5183 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5184 tSirBssDescription *pSirBssDesc = NULL;
5185 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5186 tCsrScanResult *pScanResult = NULL;
5187 tCsrRoamInfo roamInfo;
5188 sme_QosAssocInfo assocInfo;
5189 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5190 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5191 tDot11fBeaconIEs *pIes = NULL;
5192 tANI_U32 sessionId = pCommand->sessionId;
5193 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5194 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5195 eRoamCmdStatus roamStatus;
5196 eCsrRoamResult roamResult;
5197 eHalStatus status;
5198 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005199 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005200
Jeff Johnson32d95a32012-09-10 13:15:23 -07005201 if(!pSession)
5202 {
5203 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5204 return eANI_BOOLEAN_FALSE;
5205 }
5206
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005207 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005208 switch( Result )
5209 {
5210 case eCsrJoinSuccess:
5211 // reset the IDLE timer
5212 // !!
5213 // !! fall through to the next CASE statement here is intentional !!
5214 // !!
5215 case eCsrReassocSuccess:
5216 if(eCsrReassocSuccess == Result)
5217 {
5218 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5219 }
5220 else
5221 {
5222 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5223 }
5224 // Success Join Response from LIM. Tell NDIS we are connected and save the
5225 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005226 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305227 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005228 //always free the memory here
5229 if(pSession->pWpaRsnRspIE)
5230 {
5231 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305232 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005233 pSession->pWpaRsnRspIE = NULL;
5234 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005235#ifdef FEATURE_WLAN_WAPI
5236 if(pSession->pWapiRspIE)
5237 {
5238 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305239 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005240 pSession->pWapiRspIE = NULL;
5241 }
5242#endif /* FEATURE_WLAN_WAPI */
5243#ifdef FEATURE_WLAN_BTAMP_UT_RF
5244 //Reset counter so no join retry is needed.
5245 pSession->maxRetryCount = 0;
5246 csrRoamStopJoinRetryTimer(pMac, sessionId);
5247#endif
5248 /* This creates problem since we have not saved the connected profile.
5249 So moving this after saving the profile
5250 */
5251 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
5252 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5253 {
5254 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5255 }
5256 else
5257 {
5258 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5259 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005260 //Use the last connected bssdesc for reassoc-ing to the same AP.
5261 //NOTE: What to do when reassoc to a different AP???
5262 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5263 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5264 {
5265 pSirBssDesc = pSession->pConnectBssDesc;
5266 if(pSirBssDesc)
5267 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305268 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5269 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005270 }
5271 }
5272 else
5273 {
5274
5275 if(pCommand->u.roamCmd.pRoamBssEntry)
5276 {
5277 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5278 if(pScanResult != NULL)
5279 {
5280 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5281 //this can be NULL
5282 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305283 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5284 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005285 }
5286 }
5287 }
5288 if( pSirBssDesc )
5289 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005290 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005291 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5292 //Save WPA/RSN IE
5293 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
5294#ifdef FEATURE_WLAN_CCX
5295 roamInfo.isCCXAssoc = pSession->connectedProfile.isCCXAssoc;
5296#endif
5297
5298 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5299 // substate change.
5300 // Moving even save profile above so that below mentioned conditon is also met.
5301 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5302 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005303 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5304 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5305 // will be dropped for the security context may not be set properly.
5306 //
5307 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5308 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5309 //
5310 // this reordering was done on titan_prod_usb branch and is being replicated here.
5311 //
5312
5313 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5314 !pProfile->bWPSAssociation)
5315 {
5316 // Issue the set Context request to LIM to establish the Unicast STA context
5317 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5318 pProfile->negotiatedUCEncryptionType,
5319 pSirBssDesc, &(pSirBssDesc->bssId),
5320 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5321 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005322 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005323 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5324 }
5325 // Issue the set Context request to LIM to establish the Broadcast STA context
5326 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5327 pSirBssDesc, &BroadcastMac,
5328 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5329 }
5330 else
5331 {
5332 //Need to wait for supplicant authtication
5333 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 //Set the subestate to WaitForKey in case authentiation is needed
5335 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5336
Jeff Johnson295189b2012-06-20 16:38:30 -07005337 if(pProfile->bWPSAssociation)
5338 {
5339 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5340 }
5341 else
5342 {
5343 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5344 }
5345
5346 //Save sessionId in case of timeout
5347 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5348 //This time should be long enough for the rest of the process plus setting key
5349 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5350 {
5351 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005352 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5354 }
5355 }
5356
5357 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5358 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 if(Context)
5360 {
5361 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5362 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005363 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5364 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5365#ifdef WLAN_FEATURE_VOWIFI_11R
5366 len += pJoinRsp->parsedRicRspLen;
5367#endif /* WLAN_FEATURE_VOWIFI_11R */
5368#ifdef FEATURE_WLAN_CCX
5369 len += pJoinRsp->tspecIeLen;
5370#endif
5371 if(len)
5372 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305373 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5374 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005375 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305376 vos_mem_copy(pSession->connectedInfo.pbFrames,
5377 pJoinRsp->frames, len);
5378 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5379 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5380 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005381#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305382 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005383#endif /* WLAN_FEATURE_VOWIFI_11R */
5384#ifdef FEATURE_WLAN_CCX
Kiet Lam64c1b492013-07-12 13:56:44 +05305385 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005386#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305387 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5388 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5389 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5390 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005391 }
5392 }
5393 if(pCommand->u.roamCmd.fReassoc)
5394 {
5395 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5396 }
5397 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5398 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5399 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5400 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5401 }
5402 else
5403 {
5404 if(pCommand->u.roamCmd.fReassoc)
5405 {
5406 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5407 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5408 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5409 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5410 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5411 }
5412 }
5413#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5414 // Indicate SME-QOS with reassoc success event, only after
5415 // copying the frames
5416 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5417#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005418 roamInfo.pBssDesc = pSirBssDesc;
5419 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5420 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5421#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5422 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5423#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5424 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5426 //It may be better to let QoS do this????
5427 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5428 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005429 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5431 pmcStartUapsd( pMac, NULL, NULL );
5432 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305433 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005434 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5435 if( pSession->bRefAssocStartCnt > 0 )
5436 {
5437 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005438 //Remove this code once SLM_Sessionization is supported
5439 //BMPS_WORKAROUND_NOT_NEEDED
5440 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005441 {
5442 pMac->roam.configParam.doBMPSWorkaround = 1;
5443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5445 }
5446
5447 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 // reset the PMKID candidate list
5449 csrResetPMKIDCandidateList( pMac, sessionId );
5450 //Update TL's AC weight base on the current EDCA parameters
5451 //These parameters may change in the course of the connection, that sictuation
5452 //is not taken care here. This change is mainly to address a WIFI WMM test where
5453 //BE has a equal or higher TX priority than VI.
5454 //We only do this for infra link
5455 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5456 {
5457 csrCheckAndUpdateACWeight(pMac, pIes);
5458 }
5459#ifdef FEATURE_WLAN_WAPI
5460 // reset the BKID candidate list
5461 csrResetBKIDCandidateList( pMac, sessionId );
5462#endif /* FEATURE_WLAN_WAPI */
5463 }
5464 else
5465 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005466 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005468 csrScanCancelIdleScan(pMac);
5469 //Not to signal link up because keys are yet to be set.
5470 //The linkup function will overwrite the sub-state that we need to keep at this point.
5471 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5472 {
5473 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005475 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5476 //enough to let security and DHCP handshake succeed before entry into BMPS
5477 if (pmcShouldBmpsTimerRun(pMac))
5478 {
5479 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5480 != eHAL_STATUS_SUCCESS)
5481 {
5482 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5483 }
5484 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005486 break;
5487
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 case eCsrStartBssSuccess:
5489 // on the StartBss Response, LIM is returning the Bss Description that we
5490 // are beaconing. Add this Bss Description to our scan results and
5491 // chain the Profile to this Bss Description. On a Start BSS, there was no
5492 // detected Bss description (no partner) so we issued the Start Bss to
5493 // start the Ibss without any Bss description. Lim was kind enough to return
5494 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005495 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005497 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305498 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 if( CSR_IS_IBSS( pProfile ) )
5500 {
5501 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005503 else if (CSR_IS_INFRA_AP(pProfile))
5504 {
5505 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5506 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 else
5508 {
5509 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5510 }
5511 if( !CSR_IS_WDS_STA( pProfile ) )
5512 {
5513 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005515 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5516 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005517 smsLog(pMac, LOG2, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 roamInfo.pBssDesc = pSirBssDesc;
5519 //We need to associate_complete it first, becasue Associate_start already indicated.
5520 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5521 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5522 break;
5523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005524 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005525 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005526 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005527 }
5528 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5529 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5530 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5531 if(pSirBssDesc)
5532 {
5533 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305534 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5535 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005536 }
5537 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305538 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005539#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5540 {
5541 vos_log_ibss_pkt_type *pIbssLog;
5542 tANI_U32 bi;
5543
5544 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5545 if(pIbssLog)
5546 {
5547 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5548 {
5549 //We start the IBSS (didn't find any matched IBSS out there)
5550 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5551 }
5552 else
5553 {
5554 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5555 }
5556 if(pSirBssDesc)
5557 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305558 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005559 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5560 }
5561 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5562 {
5563 //***U8 is not enough for beacon interval
5564 pIbssLog->beaconInterval = (v_U8_t)bi;
5565 }
5566 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5567 }
5568 }
5569#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5570 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5571 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005572 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5573 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005574 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5575 csrRoamIssueSetContextReq( pMac, sessionId,
5576 pProfile->negotiatedMCEncryptionType,
5577 pSirBssDesc, &BroadcastMac,
5578 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5579 }
5580 }
5581 else
5582 {
5583 //Keep the state to eCSR_ROAMING_STATE_JOINING
5584 //Need to send join_req.
5585 if(pCommand->u.roamCmd.pRoamBssEntry)
5586 {
5587 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5588 {
5589 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5590 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5591 // Set the roaming substate to 'join attempt'...
5592 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005593 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005594 }
5595 }
5596 else
5597 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005598 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005599 VOS_ASSERT( 0 );
5600 }
5601 }
5602 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5603 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5604 //trigger the connection start indication in Vista
5605 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5606 {
5607 roamStatus = eCSR_ROAM_IBSS_IND;
5608 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5609 if( CSR_IS_WDS( pProfile ) )
5610 {
5611 roamStatus = eCSR_ROAM_WDS_IND;
5612 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 if( CSR_IS_INFRA_AP( pProfile ) )
5615 {
5616 roamStatus = eCSR_ROAM_INFRA_IND;
5617 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5618 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005619
5620 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5621 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5622 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305623 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005624 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5625 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005626 //We start the IBSS (didn't find any matched IBSS out there)
5627 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005628 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305629 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5630 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005631 //Remove this code once SLM_Sessionization is supported
5632 //BMPS_WORKAROUND_NOT_NEEDED
5633 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005634 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005635 {
5636 pMac->roam.configParam.doBMPSWorkaround = 1;
5637 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005638
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5640 }
5641
5642 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005643
5644 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005645 {
5646 //need to send stop BSS because we fail to send join_req
5647 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5648 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5649 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5650 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005651 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005652 case eCsrStartBssFailure:
5653#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5654 {
5655 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005656 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5657 if(pIbssLog)
5658 {
5659 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5660 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5661 }
5662 }
5663#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 roamStatus = eCSR_ROAM_IBSS_IND;
5665 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5666 if( CSR_IS_WDS( pProfile ) )
5667 {
5668 roamStatus = eCSR_ROAM_WDS_IND;
5669 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5670 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005671 if( CSR_IS_INFRA_AP( pProfile ) )
5672 {
5673 roamStatus = eCSR_ROAM_INFRA_IND;
5674 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005676 if(Context)
5677 {
5678 pSirBssDesc = (tSirBssDescription *)Context;
5679 }
5680 else
5681 {
5682 pSirBssDesc = NULL;
5683 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305684 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 roamInfo.pBssDesc = pSirBssDesc;
5686 //We need to associate_complete it first, becasue Associate_start already indicated.
5687 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5688 csrSetDefaultDot11Mode( pMac );
5689 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005690 case eCsrSilentlyStopRoaming:
5691 // We are here because we try to start the same IBSS
5692 //No message to PE
5693 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005694 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005695 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5696 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305697 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005698 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5699 if( roamInfo.pBssDesc )
5700 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305701 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5702 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005703 }
5704 //Since there is no change in the current state, simply pass back no result otherwise
5705 //HDD may be mistakenly mark to disconnected state.
5706 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5707 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005708 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 case eCsrSilentlyStopRoamingSaveState:
5710 //We are here because we try to connect to the same AP
5711 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005712 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305713 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005714
5715 //to aviod resetting the substate to NONE
5716 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5717 //No need to change substate to wai_for_key because there is no state change
5718 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5719 if( roamInfo.pBssDesc )
5720 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305721 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5722 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5725 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5726 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5727 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5728 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5729 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5730 roamInfo.staId = pSession->connectedInfo.staId;
5731 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005732 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005733 pSession->bRefAssocStartCnt--;
5734 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5735 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5736 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5737 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005738 case eCsrReassocFailure:
5739#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5740 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5741#endif
5742 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005743 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005744 csrFreeConnectBssDesc(pMac, sessionId);
5745 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5746 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305747 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5749 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5750 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5751 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5752 eCSR_ROAM_WDS_IND,
5753 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5754 //Need to issue stop_bss
5755 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 case eCsrJoinFailure:
5757 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005758 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005759 default:
5760 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005761 smsLog(pMac, LOGW, FL("receives no association indication"));
5762 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005763 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5765 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5766 {
5767 //do not free for the other profiles as we need to send down stop BSS later
5768 csrFreeConnectBssDesc(pMac, sessionId);
5769 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5770 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5771 csrSetDefaultDot11Mode( pMac );
5772 }
5773
5774 switch( pCommand->u.roamCmd.roamReason )
5775 {
5776 // If this transition is because of an 802.11 OID, then we transition
5777 // back to INIT state so we sit waiting for more OIDs to be issued and
5778 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005779 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 case eCsrSmeIssuedAssocToSimilarAP:
5781 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005782 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305784 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5786 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5787 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305788 vos_mem_copy(&roamInfo.bssid,
5789 &pSession->joinFailStatusCode.bssId,
5790 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005791
Jeff Johnson295189b2012-06-20 16:38:30 -07005792 /* Defeaturize this later if needed */
5793#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5794 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5795 if (csrRoamIsHandoffInProgress(pMac))
5796 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005797 /* Should indicate neighbor roam algorithm about the connect failure here */
5798 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5799 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005800#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005801 if(pSession->bRefAssocStartCnt > 0)
5802 {
5803 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005804 if(eCsrJoinFailureDueToConcurrency == Result)
5805 {
5806 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5807 eCSR_ROAM_ASSOCIATION_COMPLETION,
5808 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5809 }
5810 else
5811 {
5812 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 eCSR_ROAM_ASSOCIATION_COMPLETION,
5814 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005816 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005817 else
5818 {
5819 /* bRefAssocStartCnt is not incremented when
5820 * eRoamState == eCsrStopRoamingDueToConcurrency
5821 * in csrRoamJoinNextBss API. so handle this in
5822 * else case by sending assoc failure
5823 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005824 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005825 pCommand->u.scanCmd.roamId,
5826 eCSR_ROAM_ASSOCIATION_FAILURE,
5827 eCSR_ROAM_RESULT_FAILURE);
5828 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005829 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005830#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5831 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5832#endif
5833 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5834 csrScanStartIdleScan(pMac);
5835#ifdef FEATURE_WLAN_BTAMP_UT_RF
5836 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5837 //BT activity and not able to recevie WLAN traffic. Retry the join
5838 if( CSR_IS_WDS_STA(pProfile) )
5839 {
5840 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5841 }
5842#endif
5843 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005844 case eCsrHddIssuedReassocToSameAP:
5845 case eCsrSmeIssuedReassocToSameAP:
5846 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5847
5848 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5849#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5850 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5851#endif
5852 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5853 csrScanStartIdleScan(pMac);
5854 break;
5855 case eCsrForcedDisassoc:
5856 case eCsrForcedDeauth:
5857 case eCsrSmeIssuedIbssJoinFailure:
5858 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5859
5860 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5861 {
5862 // Notify HDD that IBSS join failed
5863 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5864 }
5865 else
5866 {
5867 csrRoamCallCallback(pMac, sessionId, NULL,
5868 pCommand->u.roamCmd.roamId,
5869 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5870 }
5871#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5872 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5873#endif
5874 csrRoamLinkDown(pMac, sessionId);
5875 csrScanStartIdleScan(pMac);
5876 break;
5877 case eCsrForcedIbssLeave:
5878 csrRoamCallCallback(pMac, sessionId, NULL,
5879 pCommand->u.roamCmd.roamId,
5880 eCSR_ROAM_IBSS_LEAVE,
5881 eCSR_ROAM_RESULT_IBSS_STOP);
5882 break;
5883 case eCsrForcedDisassocMICFailure:
5884 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5885
5886 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5887#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5888 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5889#endif
5890 csrScanStartIdleScan(pMac);
5891 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005892 case eCsrStopBss:
5893 csrRoamCallCallback(pMac, sessionId, NULL,
5894 pCommand->u.roamCmd.roamId,
5895 eCSR_ROAM_INFRA_IND,
5896 eCSR_ROAM_RESULT_INFRA_STOPPED);
5897 break;
5898 case eCsrForcedDisassocSta:
5899 case eCsrForcedDeauthSta:
5900 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5901 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5902 {
5903 pSession = CSR_GET_SESSION(pMac, sessionId);
5904 if (!pSession)
5905 break;
5906
5907 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5908 {
5909 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05305910 vos_mem_copy(roamInfo.peerMac,
5911 pCommand->u.roamCmd.peerMac,
5912 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005913 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5914 roamInfo.statusCode = eSIR_SME_SUCCESS;
5915 status = csrRoamCallCallback(pMac, sessionId,
5916 &roamInfo, pCommand->u.roamCmd.roamId,
5917 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5918 }
5919 }
5920 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005921 case eCsrLostLink1:
5922 // if lost link roam1 failed, then issue lost link Scan2 ...
5923 csrScanRequestLostLink2(pMac, sessionId);
5924 break;
5925 case eCsrLostLink2:
5926 // if lost link roam2 failed, then issue lost link scan3 ...
5927 csrScanRequestLostLink3(pMac, sessionId);
5928 break;
5929 case eCsrLostLink3:
5930 default:
5931 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5932
5933 //We are done with one round of lostlink roaming here
5934 csrScanHandleFailedLostlink3(pMac, sessionId);
5935 break;
5936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 break;
5938 }
5939 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 return ( fReleaseCommand );
5941}
5942
Jeff Johnson295189b2012-06-20 16:38:30 -07005943eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5944{
5945 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 return (status);
5947}
5948
Jeff Johnson295189b2012-06-20 16:38:30 -07005949eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5950{
5951 eHalStatus status = eHAL_STATUS_SUCCESS;
5952 tANI_U32 size = 0;
5953
5954 do
5955 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305956 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005957 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5958 {
5959 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305960 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
5961 if ( NULL == pDstProfile->BSSIDs.bssid )
5962 status = eHAL_STATUS_FAILURE;
5963 else
5964 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005965 if(!HAL_STATUS_SUCCESS(status))
5966 {
5967 break;
5968 }
5969 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305970 vos_mem_copy(pDstProfile->BSSIDs.bssid,
5971 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005972 }
5973 if(pSrcProfile->SSIDs.numOfSSIDs)
5974 {
5975 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305976 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
5977 if ( NULL == pDstProfile->SSIDs.SSIDList )
5978 status = eHAL_STATUS_FAILURE;
5979 else
5980 status = eHAL_STATUS_SUCCESS;
5981 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 {
5983 break;
5984 }
5985 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305986 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
5987 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005988 }
5989 if(pSrcProfile->nWPAReqIELength)
5990 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305991 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
5992 if ( NULL == pDstProfile->pWPAReqIE )
5993 status = eHAL_STATUS_FAILURE;
5994 else
5995 status = eHAL_STATUS_SUCCESS;
5996
5997 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 {
5999 break;
6000 }
6001 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306002 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6003 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 }
6005 if(pSrcProfile->nRSNReqIELength)
6006 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306007 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6008 if ( NULL == pDstProfile->pRSNReqIE )
6009 status = eHAL_STATUS_FAILURE;
6010 else
6011 status = eHAL_STATUS_SUCCESS;
6012
6013 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 {
6015 break;
6016 }
6017 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306018 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6019 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006020 }
6021#ifdef FEATURE_WLAN_WAPI
6022 if(pSrcProfile->nWAPIReqIELength)
6023 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306024 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6025 if ( NULL == pDstProfile->pWAPIReqIE )
6026 status = eHAL_STATUS_FAILURE;
6027 else
6028 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006029 if(!HAL_STATUS_SUCCESS(status))
6030 {
6031 break;
6032 }
6033 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306034 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6035 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 }
6037#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 if(pSrcProfile->nAddIEScanLength)
6039 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306040 pDstProfile->pAddIEScan = vos_mem_malloc(pSrcProfile->nAddIEScanLength);
6041 if ( NULL == pDstProfile->pAddIEScan )
6042 status = eHAL_STATUS_FAILURE;
6043 else
6044 status = eHAL_STATUS_SUCCESS;
6045
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 if(!HAL_STATUS_SUCCESS(status))
6047 {
6048 break;
6049 }
6050 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306051 vos_mem_copy(pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
6052 pSrcProfile->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006053 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 if(pSrcProfile->nAddIEAssocLength)
6055 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306056 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6057 if ( NULL == pDstProfile->pAddIEAssoc )
6058 status = eHAL_STATUS_FAILURE;
6059 else
6060 status = eHAL_STATUS_SUCCESS;
6061
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 if(!HAL_STATUS_SUCCESS(status))
6063 {
6064 break;
6065 }
6066 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306067 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6068 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006070 if(pSrcProfile->ChannelInfo.ChannelList)
6071 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306072 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6073 pSrcProfile->ChannelInfo.numOfChannels);
6074 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6075 status = eHAL_STATUS_FAILURE;
6076 else
6077 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 if(!HAL_STATUS_SUCCESS(status))
6079 {
6080 break;
6081 }
6082 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306083 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6084 pSrcProfile->ChannelInfo.ChannelList,
6085 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 pDstProfile->AuthType = pSrcProfile->AuthType;
6088 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6089 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6090 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6091 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6092 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006093#ifdef WLAN_FEATURE_11W
6094 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6095 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6096 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6097#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 pDstProfile->BSSType = pSrcProfile->BSSType;
6099 pDstProfile->phyMode = pSrcProfile->phyMode;
6100 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6101
6102#ifdef FEATURE_WLAN_WAPI
6103 if(csrIsProfileWapi(pSrcProfile))
6104 {
6105 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6106 {
6107 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6108 }
6109 }
6110#endif /* FEATURE_WLAN_WAPI */
6111 pDstProfile->CBMode = pSrcProfile->CBMode;
6112 /*Save the WPS info*/
6113 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
6114 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 pDstProfile->privacy = pSrcProfile->privacy;
6117 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6118 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6119 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6120 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6121 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6122 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6123 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6124 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6125 pDstProfile->wps_state = pSrcProfile->wps_state;
6126 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306127 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6128 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006129#ifdef WLAN_FEATURE_VOWIFI_11R
6130 if (pSrcProfile->MDID.mdiePresent)
6131 {
6132 pDstProfile->MDID.mdiePresent = 1;
6133 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6134 }
6135#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006136 }while(0);
6137
6138 if(!HAL_STATUS_SUCCESS(status))
6139 {
6140 csrReleaseProfile(pMac, pDstProfile);
6141 pDstProfile = NULL;
6142 }
6143
6144 return (status);
6145}
Jeff Johnson295189b2012-06-20 16:38:30 -07006146eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6147{
6148 eHalStatus status = eHAL_STATUS_SUCCESS;
6149 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6150 do
6151 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306152 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006153 if(pSrcProfile->bssid)
6154 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306155 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6156 if ( NULL == pDstProfile->BSSIDs.bssid )
6157 status = eHAL_STATUS_FAILURE;
6158 else
6159 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006160 if(!HAL_STATUS_SUCCESS(status))
6161 {
6162 break;
6163 }
6164 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306165 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6166 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006167 }
6168 if(pSrcProfile->SSID.ssId)
6169 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306170 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6171 if ( NULL == pDstProfile->SSIDs.SSIDList )
6172 status = eHAL_STATUS_FAILURE;
6173 else
6174 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006175 if(!HAL_STATUS_SUCCESS(status))
6176 {
6177 break;
6178 }
6179 pDstProfile->SSIDs.numOfSSIDs = 1;
6180 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6181 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306182 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6183 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006184 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006185 if(pSrcProfile->nAddIEAssocLength)
6186 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306187 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6188 if ( NULL == pDstProfile->pAddIEAssoc)
6189 status = eHAL_STATUS_FAILURE;
6190 else
6191 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006192 if(!HAL_STATUS_SUCCESS(status))
6193 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006194 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006195 break;
6196 }
6197 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306198 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6199 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006200 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306201 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6202 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6203 status = eHAL_STATUS_FAILURE;
6204 else
6205 status = eHAL_STATUS_SUCCESS;
6206
Jeff Johnson295189b2012-06-20 16:38:30 -07006207 if(!HAL_STATUS_SUCCESS(status))
6208 {
6209 break;
6210 }
6211 pDstProfile->ChannelInfo.numOfChannels = 1;
6212 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 pDstProfile->AuthType.numEntries = 1;
6214 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6215 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6216 pDstProfile->EncryptionType.numEntries = 1;
6217 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6218 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6219 pDstProfile->mcEncryptionType.numEntries = 1;
6220 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6221 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6222 pDstProfile->BSSType = pSrcProfile->BSSType;
6223 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306224 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6225 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006226#ifdef WLAN_FEATURE_VOWIFI_11R
6227 if (pSrcProfile->MDID.mdiePresent)
6228 {
6229 pDstProfile->MDID.mdiePresent = 1;
6230 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6231 }
6232#endif
6233
6234 }while(0);
6235
6236 if(!HAL_STATUS_SUCCESS(status))
6237 {
6238 csrReleaseProfile(pMac, pDstProfile);
6239 pDstProfile = NULL;
6240 }
6241
6242 return (status);
6243}
6244
Jeff Johnson295189b2012-06-20 16:38:30 -07006245eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6246 tScanResultHandle hBSSList,
6247 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6248 tANI_BOOLEAN fClearScan)
6249{
6250 eHalStatus status = eHAL_STATUS_SUCCESS;
6251 tSmeCmd *pCommand;
6252
6253 pCommand = csrGetCommandBuffer(pMac);
6254 if(NULL == pCommand)
6255 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006256 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 status = eHAL_STATUS_RESOURCES;
6258 }
6259 else
6260 {
6261 if( fClearScan )
6262 {
6263 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306264 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006265 }
6266 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6267 if(NULL == pProfile)
6268 {
6269 //We can roam now
6270 //Since pProfile is NULL, we need to build our own profile, set everything to default
6271 //We can only support open and no encryption
6272 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6273 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6274 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6275 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6276 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6277 }
6278 else
6279 {
6280 //make a copy of the profile
6281 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6282 if(HAL_STATUS_SUCCESS(status))
6283 {
6284 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6285 }
6286 }
6287 pCommand->command = eSmeCommandRoam;
6288 pCommand->sessionId = (tANI_U8)sessionId;
6289 pCommand->u.roamCmd.hBSSList = hBSSList;
6290 pCommand->u.roamCmd.roamId = roamId;
6291 pCommand->u.roamCmd.roamReason = reason;
6292 //We need to free the BssList when the command is done
6293 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6294 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006295 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6296 FL("CSR PERSONA=%d"),
6297 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006298 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6299 if( !HAL_STATUS_SUCCESS( status ) )
6300 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006301 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 csrReleaseCommandRoam( pMac, pCommand );
6303 }
6304 }
6305
6306 return (status);
6307}
Jeff Johnson295189b2012-06-20 16:38:30 -07006308eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6309 tCsrRoamModifyProfileFields *pMmodProfileFields,
6310 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6311{
6312 eHalStatus status = eHAL_STATUS_SUCCESS;
6313 tSmeCmd *pCommand;
6314
6315 pCommand = csrGetCommandBuffer(pMac);
6316 if(NULL == pCommand)
6317 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006318 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006319 status = eHAL_STATUS_RESOURCES;
6320 }
6321 else
6322 {
6323 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306324 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006325 if(pProfile)
6326 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006327 //This is likely trying to reassoc to different profile
6328 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6329 //make a copy of the profile
6330 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6331 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006332 }
6333 else
6334 {
6335 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6336 //how to update WPA/WPA2 info in roamProfile??
6337 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 if(HAL_STATUS_SUCCESS(status))
6340 {
6341 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6342 }
6343 pCommand->command = eSmeCommandRoam;
6344 pCommand->sessionId = (tANI_U8)sessionId;
6345 pCommand->u.roamCmd.roamId = roamId;
6346 pCommand->u.roamCmd.roamReason = reason;
6347 //We need to free the BssList when the command is done
6348 //For reassoc there is no BSS list, so the boolean set to false
6349 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6350 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6351 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006352 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6353 if( !HAL_STATUS_SUCCESS( status ) )
6354 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006355 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006356 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6357 csrReleaseCommandRoam( pMac, pCommand );
6358 }
6359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 return (status);
6361}
6362
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006363eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6364 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306365// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006366{
6367 eHalStatus status = eHAL_STATUS_SUCCESS;
6368 tSmeCmd *pCommand;
6369
6370 pCommand = csrGetCommandBuffer(pMac);
6371 if(NULL == pCommand)
6372 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006373 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006374 status = eHAL_STATUS_RESOURCES;
6375 }
6376 else
6377 {
6378 if(pBssDescription)
6379 {
6380 //copy over the parameters we need later
6381 pCommand->command = eSmeCommandRoam;
6382 pCommand->sessionId = (tANI_U8)sessionId;
6383 pCommand->u.roamCmd.roamReason = reason;
6384 //this is the important parameter
6385 //in this case we are using this field for the "next" BSS
6386 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6387 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6388 if( !HAL_STATUS_SUCCESS( status ) )
6389 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006390 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006391 csrReleaseCommandPreauth( pMac, pCommand );
6392 }
6393 }
6394 else
6395 {
6396 //Return failure
6397 status = eHAL_STATUS_RESOURCES;
6398 }
6399 }
6400 return (status);
6401}
6402
6403eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6404{
6405 tListElem *pEntry;
6406 tSmeCmd *pCommand;
6407 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6408 if ( pEntry )
6409 {
6410 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6411 if ( (eSmeCommandRoam == pCommand->command) &&
6412 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6413 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006414 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006415 pCommand->command, pCommand->u.roamCmd.roamReason);
6416 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6417 csrReleaseCommandPreauth( pMac, pCommand );
6418 }
6419 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006420 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006421 pCommand->command, pCommand->u.roamCmd.roamReason);
6422 }
6423 }
6424 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006425 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006426 }
6427 smeProcessPendingQueue( pMac );
6428 return eHAL_STATUS_SUCCESS;
6429}
6430
Jeff Johnson295189b2012-06-20 16:38:30 -07006431eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6432 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6433{
6434 eHalStatus status = eHAL_STATUS_FAILURE;
6435 tScanResultHandle hBSSList;
6436 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6438 if(HAL_STATUS_SUCCESS(status))
6439 {
6440 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6441 if(pRoamId)
6442 {
6443 *pRoamId = roamId;
6444 }
6445 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6446 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6447 if(!HAL_STATUS_SUCCESS(status))
6448 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006449 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006450 csrScanResultPurge(pMac, hBSSList);
6451 }
6452 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006453 return (status);
6454}
6455
Jeff Johnson295189b2012-06-20 16:38:30 -07006456eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6457 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6458{
6459 eHalStatus status = eHAL_STATUS_SUCCESS;
6460 tScanResultHandle hBSSList;
6461 tCsrScanResultFilter *pScanFilter;
6462 tANI_U32 roamId = 0;
6463 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6464 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006465 if (NULL == pProfile)
6466 {
6467 smsLog(pMac, LOGP, FL("No profile specified"));
6468 return eHAL_STATUS_FAILURE;
6469 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006470 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006471 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006472 if( CSR_IS_WDS( pProfile ) &&
6473 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6474 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006475 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006476 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006477 return status;
6478 }
6479 csrRoamCancelRoaming(pMac, sessionId);
6480 csrScanRemoveFreshScanCommand(pMac, sessionId);
6481 csrScanCancelIdleScan(pMac);
6482 //Only abort the scan if it is not used for other roam/connect purpose
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306483 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006484 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6485 {
6486 csrScanDisable(pMac);
6487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006488 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6489 //Check whether ssid changes
6490 if(csrIsConnStateConnected(pMac, sessionId))
6491 {
6492 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6493 {
6494 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6495 }
6496 }
6497#ifdef FEATURE_WLAN_BTAMP_UT_RF
6498 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6499#endif
6500 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6501 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006502 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006503 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6504 if(pRoamId)
6505 {
6506 roamId = *pRoamId;
6507 }
6508 if(!HAL_STATUS_SUCCESS(status))
6509 {
6510 fCallCallback = eANI_BOOLEAN_TRUE;
6511 }
6512 }
6513 else
6514 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306515 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6516 if ( NULL == pScanFilter )
6517 status = eHAL_STATUS_FAILURE;
6518 else
6519 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 if(HAL_STATUS_SUCCESS(status))
6521 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306522 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006523 //Try to connect to any BSS
6524 if(NULL == pProfile)
6525 {
6526 //No encryption
6527 pScanFilter->EncryptionType.numEntries = 1;
6528 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6529 }//we don't have a profile
6530 else
6531 {
6532 //Here is the profile we need to connect to
6533 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6534 }//We have a profile
6535 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6536 if(pRoamId)
6537 {
6538 *pRoamId = roamId;
6539 }
6540
6541 if(HAL_STATUS_SUCCESS(status))
6542 {
6543 /*Save the WPS info*/
6544 if(NULL != pProfile)
6545 {
6546 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6547 }
6548 else
6549 {
6550 pScanFilter->bWPSAssociation = 0;
6551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006552 do
6553 {
6554 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006555 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006556 )
6557 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006558 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006559 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6560 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6561 if(!HAL_STATUS_SUCCESS(status))
6562 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006563 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006564 fCallCallback = eANI_BOOLEAN_TRUE;
6565 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006566 else
6567 {
6568 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6569 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006570 break;
6571 }
6572 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006573 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006574 if(HAL_STATUS_SUCCESS(status))
6575 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006576 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6577 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6578 if(!HAL_STATUS_SUCCESS(status))
6579 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006580 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006581 csrScanResultPurge(pMac, hBSSList);
6582 fCallCallback = eANI_BOOLEAN_TRUE;
6583 }
6584 }//Have scan result
6585 else if(NULL != pProfile)
6586 {
6587 //Check whether it is for start ibss
6588 if(CSR_IS_START_IBSS(pProfile))
6589 {
6590 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, 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, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006595 fCallCallback = eANI_BOOLEAN_TRUE;
6596 }
6597 }
6598 else
6599 {
6600 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006601 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006602 if(!HAL_STATUS_SUCCESS(status))
6603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006604 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 fCallCallback = eANI_BOOLEAN_TRUE;
6606 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006607 else
6608 {
6609 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6610 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 }
6612 }
6613 else
6614 {
6615 fCallCallback = eANI_BOOLEAN_TRUE;
6616 }
6617 } while (0);
6618 if(NULL != pProfile)
6619 {
6620 //we need to free memory for filter if profile exists
6621 csrFreeScanFilter(pMac, pScanFilter);
6622 }
6623 }//Got the scan filter from profile
6624
Kiet Lam64c1b492013-07-12 13:56:44 +05306625 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006626 }//allocated memory for pScanFilter
6627 }//No Bsslist coming in
6628 //tell the caller if we fail to trigger a join request
6629 if( fCallCallback )
6630 {
6631 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6632 }
6633
6634 return (status);
6635}
Jeff Johnson295189b2012-06-20 16:38:30 -07006636eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6637 tCsrRoamModifyProfileFields modProfileFields,
6638 tANI_U32 *pRoamId)
6639{
6640 eHalStatus status = eHAL_STATUS_SUCCESS;
6641 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6642 tANI_U32 roamId = 0;
6643 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006644 if (NULL == pProfile)
6645 {
6646 smsLog(pMac, LOGP, FL("No profile specified"));
6647 return eHAL_STATUS_FAILURE;
6648 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006649 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 -07006650 csrRoamCancelRoaming(pMac, sessionId);
6651 csrScanRemoveFreshScanCommand(pMac, sessionId);
6652 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306653 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006654 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 if(csrIsConnStateConnected(pMac, sessionId))
6656 {
6657 if(pProfile)
6658 {
6659 if(pProfile->SSIDs.numOfSSIDs &&
6660 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6661 {
6662 fCallCallback = eANI_BOOLEAN_FALSE;
6663 }
6664 else
6665 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006666 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006667 }
6668 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306669 else if (!vos_mem_compare(&modProfileFields,
6670 &pSession->connectedProfile.modifyProfileFields,
6671 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006672 {
6673 fCallCallback = eANI_BOOLEAN_FALSE;
6674 }
6675 else
6676 {
6677 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006678 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 }
6680 }
6681 else
6682 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006683 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006684 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006685 if(!fCallCallback)
6686 {
6687 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6688 if(pRoamId)
6689 {
6690 *pRoamId = roamId;
6691 }
6692
Jeff Johnson295189b2012-06-20 16:38:30 -07006693 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6694 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006695 }
6696 else
6697 {
6698 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6699 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006701 return status;
6702}
Jeff Johnson295189b2012-06-20 16:38:30 -07006703eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6704{
6705 eHalStatus status = eHAL_STATUS_FAILURE;
6706 tScanResultHandle hBSSList = NULL;
6707 tCsrScanResultFilter *pScanFilter = NULL;
6708 tANI_U32 roamId;
6709 tCsrRoamProfile *pProfile = NULL;
6710 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006711
6712 if(!pSession)
6713 {
6714 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6715 return eHAL_STATUS_FAILURE;
6716 }
6717
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 do
6719 {
6720 if(pSession->pCurRoamProfile)
6721 {
6722 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306723 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006724 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306725 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6726 if ( NULL == pProfile )
6727 status = eHAL_STATUS_FAILURE;
6728 else
6729 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 if(!HAL_STATUS_SUCCESS(status))
6731 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306732 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006733 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306734 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006735 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306736 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6737 if ( NULL == pScanFilter )
6738 status = eHAL_STATUS_FAILURE;
6739 else
6740 status = eHAL_STATUS_SUCCESS;
6741
Jeff Johnson295189b2012-06-20 16:38:30 -07006742 if(!HAL_STATUS_SUCCESS(status))
6743 {
6744 break;
6745 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306746 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006747 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6748 if(!HAL_STATUS_SUCCESS(status))
6749 {
6750 break;
6751 }
6752 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6753 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6754 if(HAL_STATUS_SUCCESS(status))
6755 {
6756 //we want to put the last connected BSS to the very beginning, if possible
6757 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6758 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6759 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6760 if(!HAL_STATUS_SUCCESS(status))
6761 {
6762 csrScanResultPurge(pMac, hBSSList);
6763 break;
6764 }
6765 }
6766 else
6767 {
6768 //Do a scan on this profile
6769 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006770 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006771 if(!HAL_STATUS_SUCCESS(status))
6772 {
6773 break;
6774 }
6775 }
6776 }//We have a profile
6777 else
6778 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006779 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006780 break;
6781 }
6782 }while(0);
6783 if(pScanFilter)
6784 {
6785 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306786 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006787 }
6788 if(NULL != pProfile)
6789 {
6790 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306791 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006793 return (status);
6794}
Jeff Johnson295189b2012-06-20 16:38:30 -07006795eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6796{
6797 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006798 if(csrIsConnStateConnected(pMac, sessionId))
6799 {
6800 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6801 if(HAL_STATUS_SUCCESS(status))
6802 {
6803 status = csrRoamJoinLastProfile(pMac, sessionId);
6804 }
6805 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006806 return (status);
6807}
6808
Jeff Johnson295189b2012-06-20 16:38:30 -07006809eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6810{
6811 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006812 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006813 csrRoamCancelRoaming(pMac, sessionId);
6814 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6815 if(csrIsConnStateDisconnected(pMac, sessionId))
6816 {
6817 status = csrRoamJoinLastProfile(pMac, sessionId);
6818 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006819 return (status);
6820}
6821
Jeff Johnson295189b2012-06-20 16:38:30 -07006822eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6823{
6824 eHalStatus status = eHAL_STATUS_SUCCESS;
6825 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6826 eCsrRoamSubState NewSubstate;
6827 tANI_U32 sessionId = pCommand->sessionId;
6828
6829 // change state to 'Roaming'...
6830 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6831
6832 if ( csrIsConnStateIbss( pMac, sessionId ) )
6833 {
6834 // If we are in an IBSS, then stop the IBSS...
6835 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6836 fComplete = (!HAL_STATUS_SUCCESS(status));
6837 }
6838 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6839 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006840 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 -07006841 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6842 //Restore AC weight in case we change it
6843 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6844 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6845 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6846 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6847 {
6848 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6849 }
6850 if( fDisassoc )
6851 {
6852 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6853 }
6854 else
6855 {
6856 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6857 }
6858 fComplete = (!HAL_STATUS_SUCCESS(status));
6859 }
6860 else if ( csrIsConnStateWds( pMac, sessionId ) )
6861 {
6862 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6863 {
6864 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6865 fComplete = (!HAL_STATUS_SUCCESS(status));
6866 }
6867 //This has to be WDS station
6868 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6869 {
6870
6871 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6872 if( fDisassoc )
6873 {
6874 status = csrRoamIssueDisassociate( pMac, sessionId,
6875 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6876 fComplete = (!HAL_STATUS_SUCCESS(status));
6877 }
6878 }
6879 } else {
6880 // we got a dis-assoc request while not connected to any peer
6881 // just complete the command
6882 fComplete = eANI_BOOLEAN_TRUE;
6883 status = eHAL_STATUS_FAILURE;
6884 }
6885 if(fComplete)
6886 {
6887 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6888 }
6889
6890 if(HAL_STATUS_SUCCESS(status))
6891 {
6892 if ( csrIsConnStateInfra( pMac, sessionId ) )
6893 {
6894 //Set the state to disconnect here
6895 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6896 }
6897 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006898 else
6899 {
6900 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6901 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006902 return (status);
6903}
6904
Jeff Johnson295189b2012-06-20 16:38:30 -07006905/* This is been removed from latest code base */
6906/*
6907static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6908{
6909 eHalStatus status;
6910 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006911 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6912 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006913 return ( status );
6914}
6915*/
6916
Jeff Johnson295189b2012-06-20 16:38:30 -07006917eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6918{
6919 eHalStatus status = eHAL_STATUS_SUCCESS;
6920 tSmeCmd *pCommand;
6921 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006922 do
6923 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006924 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006925 pCommand = csrGetCommandBuffer( pMac );
6926 if ( !pCommand )
6927 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006928 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006929 status = eHAL_STATUS_RESOURCES;
6930 break;
6931 }
6932 //Change the substate in case it is wait-for-key
6933 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6934 {
6935 csrRoamStopWaitForKeyTimer( pMac );
6936 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6937 }
6938 pCommand->command = eSmeCommandRoam;
6939 pCommand->sessionId = (tANI_U8)sessionId;
6940 switch ( reason )
6941 {
6942 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6943 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6944 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006945 case eCSR_DISCONNECT_REASON_DEAUTH:
6946 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6947 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006948 case eCSR_DISCONNECT_REASON_HANDOFF:
6949 fHighPriority = eANI_BOOLEAN_TRUE;
6950 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6951 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006952 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6953 case eCSR_DISCONNECT_REASON_DISASSOC:
6954 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6955 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006956 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6957 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6958 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006959 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6960 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6961 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006962 default:
6963 break;
6964 }
6965 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6966 if( !HAL_STATUS_SUCCESS( status ) )
6967 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006968 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006969 csrReleaseCommandRoam( pMac, pCommand );
6970 }
6971 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006972 return( status );
6973}
6974
Jeff Johnson295189b2012-06-20 16:38:30 -07006975eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6976{
6977 eHalStatus status = eHAL_STATUS_SUCCESS;
6978 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006979 pCommand = csrGetCommandBuffer( pMac );
6980 if ( NULL != pCommand )
6981 {
6982 //Change the substate in case it is wait-for-key
6983 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6984 {
6985 csrRoamStopWaitForKeyTimer( pMac );
6986 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6987 }
6988 pCommand->command = eSmeCommandRoam;
6989 pCommand->sessionId = (tANI_U8)sessionId;
6990 pCommand->u.roamCmd.roamReason = eCsrStopBss;
6991 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6992 if( !HAL_STATUS_SUCCESS( status ) )
6993 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006994 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006995 csrReleaseCommandRoam( pMac, pCommand );
6996 }
6997 }
6998 else
6999 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007000 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007001 status = eHAL_STATUS_RESOURCES;
7002 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007003 return ( status );
7004}
7005
Jeff Johnson295189b2012-06-20 16:38:30 -07007006eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7007{
7008 eHalStatus status = eHAL_STATUS_SUCCESS;
7009 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007010
7011 if(!pSession)
7012 {
7013 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7014 return eHAL_STATUS_FAILURE;
7015 }
7016
Jeff Johnson295189b2012-06-20 16:38:30 -07007017#ifdef FEATURE_WLAN_BTAMP_UT_RF
7018 //Stop te retry
7019 pSession->maxRetryCount = 0;
7020 csrRoamStopJoinRetryTimer(pMac, sessionId);
7021#endif
7022 //Not to call cancel roaming here
7023 //Only issue disconnect when necessary
7024 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7025 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7026 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7027
7028 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007029 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007030 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7031 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007032 return (status);
7033}
7034
Jeff Johnson295189b2012-06-20 16:38:30 -07007035eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7036{
7037 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007038
7039 if(!pSession)
7040 {
7041 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7042 return eHAL_STATUS_FAILURE;
7043 }
7044
Jeff Johnson295189b2012-06-20 16:38:30 -07007045 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007046 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7047
7048 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7049}
7050
Jeff Johnson295189b2012-06-20 16:38:30 -07007051eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7052 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7053{
7054 eHalStatus status = eHAL_STATUS_SUCCESS;
7055 tDot11fBeaconIEs *pIesTemp = pIes;
7056 tANI_U8 index;
7057 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7058 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007059
7060 if(!pSession)
7061 {
7062 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7063 return eHAL_STATUS_FAILURE;
7064 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007065 if(pConnectProfile->pAddIEAssoc)
7066 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307067 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007068 pConnectProfile->pAddIEAssoc = NULL;
7069 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307070 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007071 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7072 pConnectProfile->AuthInfo = pProfile->AuthType;
7073 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7074 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7075 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7076 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7077 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7078 pConnectProfile->BSSType = pProfile->BSSType;
7079 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7080 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007081 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
7082
Kiet Lam64c1b492013-07-12 13:56:44 +05307083 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007084 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7085 if(pProfile->nAddIEAssocLength)
7086 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307087 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7088 if ( NULL == pConnectProfile->pAddIEAssoc )
7089 status = eHAL_STATUS_FAILURE;
7090 else
7091 status = eHAL_STATUS_SUCCESS;
7092 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007093 {
7094 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7095 return eHAL_STATUS_FAILURE;
7096 }
7097 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307098 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7099 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007100 }
7101
Jeff Johnson295189b2012-06-20 16:38:30 -07007102 //Save bssid
7103 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7104#ifdef WLAN_FEATURE_VOWIFI_11R
7105 if (pSirBssDesc->mdiePresent)
7106 {
7107 pConnectProfile->MDID.mdiePresent = 1;
7108 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7109 }
7110#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007111 if( NULL == pIesTemp )
7112 {
7113 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007115#ifdef FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007116 if ((csrIsProfileCCX(pProfile) ||
7117 ((pIesTemp->CCXVersion.present)
7118 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7119 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7120 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7121 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07007122#ifdef WLAN_FEATURE_11W
7123 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
7124#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05307125 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007126 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007127 {
7128 pConnectProfile->isCCXAssoc = 1;
7129 }
7130#endif
7131 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007132 if(HAL_STATUS_SUCCESS(status))
7133 {
7134 if(pIesTemp->SSID.present)
7135 {
7136 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307137 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7138 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007139 }
7140
7141 //Save the bss desc
7142 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307143
7144 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007145 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307146 //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 -07007147 pConnectProfile->qap = TRUE;
7148 }
7149 else
7150 {
7151 pConnectProfile->qap = FALSE;
7152 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 if ( NULL == pIes )
7154 {
7155 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307156 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007157 }
7158 }
7159 //Save Qos connection
7160 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7161
7162 if(!HAL_STATUS_SUCCESS(status))
7163 {
7164 csrFreeConnectBssDesc(pMac, sessionId);
7165 }
7166 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7167 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307168 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7169 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7170 pConnectProfile->SSID.ssId,
7171 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007172 {
7173 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7174 break;
7175 }
7176 pConnectProfile->handoffPermitted = FALSE;
7177 }
7178
7179 return (status);
7180}
7181
Jeff Johnson295189b2012-06-20 16:38:30 -07007182static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7183{
7184 tListElem *pEntry = NULL;
7185 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007186 //The head of the active list is the request we sent
7187 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7188 if(pEntry)
7189 {
7190 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7191 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007192 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7193 {
7194 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7195 {
7196#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7197 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7198#endif
7199 }
7200 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7201 }
7202 else
7203 {
7204 tANI_U32 roamId = 0;
7205 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007206 if(!pSession)
7207 {
7208 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7209 return;
7210 }
7211
Jeff Johnson295189b2012-06-20 16:38:30 -07007212
7213 //The head of the active list is the request we sent
7214 //Try to get back the same profile and roam again
7215 if(pCommand)
7216 {
7217 roamId = pCommand->u.roamCmd.roamId;
7218 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007219 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7220 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007221 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007222#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7223 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7224 if (csrRoamIsHandoffInProgress(pMac))
7225 {
7226 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7227 /* Should indicate neighbor roam algorithm about the connect failure here */
7228 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7229 }
7230#endif
7231 if (pCommand)
7232 {
7233 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7234 {
7235 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7236 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7237 csrRoamReissueRoamCommand(pMac);
7238 }
7239 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7240 {
7241 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7242 }
7243 else
7244 {
7245 csrRoam(pMac, pCommand);
7246 }
7247 }
7248 else
7249 {
7250 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7251 }
7252 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7253}
7254
Jeff Johnson295189b2012-06-20 16:38:30 -07007255eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7256 tDot11fBeaconIEs *pIes,
7257 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7258{
7259 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007260 smsLog( pMac, LOG1, "Attempting to Join Bssid= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -07007261 pSirBssDesc->bssId[ 0 ],pSirBssDesc->bssId[ 1 ],pSirBssDesc->bssId[ 2 ],
7262 pSirBssDesc->bssId[ 3 ],pSirBssDesc->bssId[ 4 ],pSirBssDesc->bssId[ 5 ] );
7263
7264 // Set the roaming substate to 'join attempt'...
7265 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007267 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007268 return (status);
7269}
7270
Jeff Johnson295189b2012-06-20 16:38:30 -07007271static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7272 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7273{
7274 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 // Set the roaming substate to 'join attempt'...
7276 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7277
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007278 smsLog(pMac, LOGE, FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007279
7280 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007281 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007282}
7283
Jeff Johnson295189b2012-06-20 16:38:30 -07007284void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7285{
7286 tListElem *pEntry;
7287 tSmeCmd *pCommand;
7288 tCsrRoamInfo roamInfo;
7289 tANI_U32 sessionId;
7290 tCsrRoamSession *pSession;
7291
7292 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7293 if(pEntry)
7294 {
7295 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7296 if ( eSmeCommandRoam == pCommand->command )
7297 {
7298 sessionId = pCommand->sessionId;
7299 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007300
7301 if(!pSession)
7302 {
7303 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7304 return;
7305 }
7306
Jeff Johnson295189b2012-06-20 16:38:30 -07007307 if( pCommand->u.roamCmd.fStopWds )
7308 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307309 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007310 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7311 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7312 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007313 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007314 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7315 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7316 eCSR_ROAM_WDS_IND,
7317 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007318 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7319 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7320 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7321 eCSR_ROAM_INFRA_IND,
7322 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7323 }
7324
Jeff Johnson295189b2012-06-20 16:38:30 -07007325
Jeff Johnson295189b2012-06-20 16:38:30 -07007326 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7327 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007328 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007329 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7330 }
7331 }
7332 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7333 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007334 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007335 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7336 }
7337 }
7338 else
7339 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007340 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007341 }
7342 }
7343 else
7344 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007345 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007346 }
7347}
7348
Jeff Johnson295189b2012-06-20 16:38:30 -07007349tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7350{
7351 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7352 tListElem *pEntry;
7353 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007354 //alwasy lock active list before locking pending list
7355 csrLLLock( &pMac->sme.smeCmdActiveList );
7356 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7357 if(pEntry)
7358 {
7359 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7360 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7361 {
7362 fRet = eANI_BOOLEAN_TRUE;
7363 }
7364 }
7365 if(eANI_BOOLEAN_FALSE == fRet)
7366 {
7367 csrLLLock(&pMac->sme.smeCmdPendingList);
7368 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7369 while(pEntry)
7370 {
7371 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7372 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7373 {
7374 fRet = eANI_BOOLEAN_TRUE;
7375 break;
7376 }
7377 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7378 }
7379 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7380 }
7381 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007382 return (fRet);
7383}
7384
Jeff Johnson295189b2012-06-20 16:38:30 -07007385tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7386{
7387 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7388 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007389 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7390 {
7391 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7392 {
7393 break;
7394 }
7395 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007396 return ( fRet );
7397}
7398
Jeff Johnson295189b2012-06-20 16:38:30 -07007399tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7400{
7401 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007402 //alwasy lock active list before locking pending list
7403 csrLLLock( &pMac->sme.smeCmdActiveList );
7404 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7405 if(eANI_BOOLEAN_FALSE == fRet)
7406 {
7407 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7408 }
7409 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007410 return (fRet);
7411}
7412
Jeff Johnson295189b2012-06-20 16:38:30 -07007413tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7414{
7415 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7416 tListElem *pEntry;
7417 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007418 //alwasy lock active list before locking pending list
7419 csrLLLock( &pMac->sme.smeCmdActiveList );
7420 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7421 if( pEntry )
7422 {
7423 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7424 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7425 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7426 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7427 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7428 {
7429 fRet = eANI_BOOLEAN_TRUE;
7430 }
7431 }
7432 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007433 return (fRet);
7434}
Jeff Johnson295189b2012-06-20 16:38:30 -07007435eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7436{
7437 eHalStatus status = eHAL_STATUS_SUCCESS;
7438 tSmeCmd *pCommand = NULL;
7439 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7440 tANI_BOOLEAN fRemoveCmd = FALSE;
7441 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007442 // Delete the old assoc command. All is setup for reassoc to be serialized
7443 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7444 if ( pEntry )
7445 {
7446 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7447 if ( !pCommand )
7448 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007449 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007450 return eHAL_STATUS_RESOURCES;
7451 }
7452 if ( eSmeCommandRoam == pCommand->command )
7453 {
7454 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7455 {
7456 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7457 }
7458 else
7459 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007460 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007461 }
7462 if (fRemoveCmd == FALSE)
7463 {
7464 // Implies we did not get the serialized assoc command we
7465 // were expecting
7466 pCommand = NULL;
7467 }
7468 }
7469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007470 if(NULL == pCommand)
7471 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007472 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007473 return eHAL_STATUS_RESOURCES;
7474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007475 do
7476 {
7477 //Change the substate in case it is wait-for-key
7478 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7479 {
7480 csrRoamStopWaitForKeyTimer( pMac );
7481 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7482 }
7483 pCommand->command = eSmeCommandRoam;
7484 pCommand->sessionId = (tANI_U8)sessionId;
7485 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7487 if( !HAL_STATUS_SUCCESS( status ) )
7488 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007489 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 csrReleaseCommandRoam( pMac, pCommand );
7491 }
7492 } while( 0 );
7493
Jeff Johnson295189b2012-06-20 16:38:30 -07007494 return( status );
7495}
7496static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7497{
7498 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7499 tCsrScanResult *pScanResult = NULL;
7500 tSirBssDescription *pBssDesc = NULL;
7501 tSmeCmd *pCommand = NULL;
7502 tANI_U32 sessionId;
7503 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007504 if(NULL == pEntry)
7505 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007506 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007507 return;
7508 }
7509 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7510 sessionId = pCommand->sessionId;
7511 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007512
7513 if(!pSession)
7514 {
7515 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7516 return;
7517 }
7518
Jeff Johnson295189b2012-06-20 16:38:30 -07007519 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7520 {
7521 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007522 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007523 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7524 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007525 /* If the roaming has stopped, not to continue the roaming command*/
7526 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7527 {
7528 //No need to complete roaming here as it already completes
7529 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7530 pCommand->u.roamCmd.roamReason);
7531 csrSetAbortRoamingCommand( pMac, pCommand );
7532 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007534 else
7535 {
7536 if ( CCM_IS_RESULT_SUCCESS(result) )
7537 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007538 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007539 // Successfully set the configuration parameters for the new Bss. Attempt to
7540 // join the roaming Bss.
7541 if(pCommand->u.roamCmd.pRoamBssEntry)
7542 {
7543 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7544 pBssDesc = &pScanResult->Result.BssDescriptor;
7545 }
7546 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7547 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007548 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007549 )
7550 {
7551 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7552 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7553 pBssDesc, pCommand->u.roamCmd.roamId )))
7554 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007555 smsLog(pMac, LOGW, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007556 //We need to complete the command
7557 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7558 }
7559 }
7560 else
7561 {
7562 if (!pCommand->u.roamCmd.pRoamBssEntry)
7563 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007564 smsLog(pMac, LOGW, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007565 //We need to complete the command
7566 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7567 return;
7568 }
7569 // If we are roaming TO an Infrastructure BSS...
7570 VOS_ASSERT(pScanResult != NULL);
7571 if ( csrIsInfraBssDesc( pBssDesc ) )
7572 {
7573 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007574 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7575 {
7576 // ..and currently in an Infrastructure connection....
7577 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7578 {
7579 // ...and the SSIDs are equal, then we Reassoc.
7580 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7581 pIesLocal ) )
7582 // ..and currently in an infrastructure connection
7583 {
7584 // then issue a Reassoc.
7585 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7586 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7587 &pCommand->u.roamCmd.roamProfile );
7588 }
7589 else
7590 {
7591
7592 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7593 // previously associated AP.
7594 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7595 pIesLocal,
7596 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7597 {
7598 //try something else
7599 csrRoam( pMac, pCommand );
7600 }
7601 }
7602 }
7603 else
7604 {
7605 eHalStatus status = eHAL_STATUS_SUCCESS;
7606
7607 /* We need to come with other way to figure out that this is because of HO in BMP
7608 The below API will be only available for Android as it uses a different HO algorithm */
7609 /* Reassoc request will be used only for CCX and 11r handoff whereas other legacy roaming should
7610 * use join request */
7611#ifdef WLAN_FEATURE_VOWIFI_11R
7612 if (csrRoamIsHandoffInProgress(pMac) &&
7613 csrRoamIs11rAssoc(pMac))
7614 {
7615 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7616 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7617 }
7618 else
7619#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007620#ifdef FEATURE_WLAN_CCX
7621 if (csrRoamIsHandoffInProgress(pMac) &&
7622 csrRoamIsCCXAssoc(pMac))
7623 {
7624 // Now serialize the reassoc command.
7625 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7626 }
7627 else
7628#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007629#ifdef FEATURE_WLAN_LFR
7630 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307631 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007632 {
7633 // Now serialize the reassoc command.
7634 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7635 }
7636 else
7637#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007638 // else we are not connected and attempting to Join. Issue the
7639 // Join request.
7640 {
7641 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7642 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7643 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7644 }
7645 if(!HAL_STATUS_SUCCESS(status))
7646 {
7647 //try something else
7648 csrRoam( pMac, pCommand );
7649 }
7650 }
7651 if( !pScanResult->Result.pvIes )
7652 {
7653 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307654 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007655 }
7656 }
7657 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7658 else
7659 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007660 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007661 }
7662 }//else
7663 }//if ( WNI_CFG_SUCCESS == result )
7664 else
7665 {
7666 // In the event the configuration failed, for infra let the roam processor
7667 //attempt to join something else...
7668 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7669 {
7670 csrRoam(pMac, pCommand);
7671 }
7672 else
7673 {
7674 //We need to complete the command
7675 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7676 {
7677 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7678 }
7679 else
7680 {
7681 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7682 }
7683 }
7684 }
7685 }//we have active entry
7686}
7687
Jeff Johnson295189b2012-06-20 16:38:30 -07007688static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7689{
7690 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007691 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007692 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7693 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007694 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007695 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7696 // join the new one...
7697 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007698 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7699 }
7700 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007701 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08lX [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007702 /***profHandleLostLinkAfterReset(pAdapter);
7703 // In the event the authenticate fails, let the roam processor attempt to join something else...
7704 roamRoam( pAdapter );***/
7705 }
7706}
7707
Jeff Johnson295189b2012-06-20 16:38:30 -07007708static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7709{
7710 eCsrRoamCompleteResult result;
7711 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7712 tCsrRoamInfo roamInfo;
7713 tANI_U32 roamId = 0;
7714
7715 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7716 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007717 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007719 /* Defeaturize this part later if needed */
7720#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7721 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7722 * we need the response contents while processing the result in csrRoamProcessResults() */
7723 if (csrRoamIsHandoffInProgress(pMac))
7724 {
7725 /* Need to dig more on indicating events to SME QoS module */
7726 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7727 csrRoamComplete( pMac, result, pSmeJoinRsp);
7728 }
7729 else
7730#endif
7731 {
7732 csrRoamComplete( pMac, result, NULL );
7733 }
7734 }
7735 /* Should we handle this similar to handling the join failure? Is it ok
7736 * to call csrRoamComplete() with state as CsrJoinFailure */
7737 else
7738 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007739 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08lX [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007740 result = eCsrReassocFailure;
7741#ifdef WLAN_FEATURE_VOWIFI_11R
7742 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7743 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7744 {
7745 // Inform HDD to turn off FT flag in HDD
7746 if (pNeighborRoamInfo)
7747 {
7748 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7749 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7750 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007751 /*
7752 * Since the above callback sends a disconnect
7753 * to HDD, we should clean-up our state
7754 * machine as well to be in sync with the upper
7755 * layers. There is no need to send a disassoc
7756 * since: 1) we will never reassoc to the current
7757 * AP in LFR, and 2) there is no need to issue a
7758 * disassoc to the AP with which we were trying
7759 * to reassoc.
7760 */
7761 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7762 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007763 }
7764 }
7765#endif
7766 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7767 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7768 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7769 //The disassoc rsp message will remove the command from active list
7770 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7771 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7772 {
7773 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7774 }
7775 }
7776}
7777
Jeff Johnson295189b2012-06-20 16:38:30 -07007778static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7779{
Jeff Johnson295189b2012-06-20 16:38:30 -07007780#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7781 {
7782 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007783 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7784 if(pIbssLog)
7785 {
7786 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7787 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7788 {
7789 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7790 }
7791 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7792 }
7793 }
7794#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007795 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7796 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7797 {
7798 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7799 }
7800 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7801 {
7802 csrRoamReissueRoamCommand(pMac);
7803 }
7804}
7805
Jeff Johnson295189b2012-06-20 16:38:30 -07007806void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7807{
7808 tSirResultCodes statusCode;
7809#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7810 tScanResultHandle hBSSList;
7811 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7812 eHalStatus status;
7813 tCsrRoamInfo roamInfo;
7814 tCsrScanResultFilter *pScanFilter = NULL;
7815 tANI_U32 roamId = 0;
7816 tCsrRoamProfile *pCurRoamProfile = NULL;
7817 tListElem *pEntry = NULL;
7818 tSmeCmd *pCommand = NULL;
7819#endif
7820 tANI_U32 sessionId;
7821 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007822
Jeff Johnson295189b2012-06-20 16:38:30 -07007823 tSirSmeDisassocRsp SmeDisassocRsp;
7824
7825 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7826 sessionId = SmeDisassocRsp.sessionId;
7827 statusCode = SmeDisassocRsp.statusCode;
7828
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007829 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007830
7831 if ( csrIsConnStateInfra( pMac, sessionId ) )
7832 {
7833 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007835 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007836
7837 if(!pSession)
7838 {
7839 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7840 return;
7841 }
7842
Jeff Johnson295189b2012-06-20 16:38:30 -07007843 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7844 {
7845 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7846 }
7847 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7848 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7849 {
7850 if ( eSIR_SME_SUCCESS == statusCode )
7851 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007852 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007853 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7854 }
7855 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7856 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007857 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7858 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007859 smsLog( pMac, LOGE, "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007860#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007861 /*
7862 * First ensure if the roam profile is in the scan cache.
7863 * If not, post a reassoc failure and disconnect.
7864 */
Kiet Lam64c1b492013-07-12 13:56:44 +05307865 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7866 if ( NULL == pScanFilter )
7867 status = eHAL_STATUS_FAILURE;
7868 else
7869 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007870 if(HAL_STATUS_SUCCESS(status))
7871 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307872 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007873 status = csrRoamPrepareFilterFromProfile(pMac,
7874 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7875 if(!HAL_STATUS_SUCCESS(status))
7876 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007877 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007878 __func__, status);
7879 goto POST_ROAM_FAILURE;
7880 }
7881 else
7882 {
7883 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7884 if (!HAL_STATUS_SUCCESS(status))
7885 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007886 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007887 __func__, status);
7888 goto POST_ROAM_FAILURE;
7889 }
7890 }
7891 }
7892 else
7893 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007894 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007895 __func__, status);
7896 goto POST_ROAM_FAILURE;
7897 }
7898
7899 /*
7900 * After ensuring that the roam profile is in the scan result list,
7901 * dequeue the command from the active list.
7902 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007903 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7904 if ( pEntry )
7905 {
7906 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007907 /* If the head of the queue is Active and it is a ROAM command, remove
7908 * and put this on the Free queue.
7909 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007910 if ( eSmeCommandRoam == pCommand->command )
7911 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007912
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007913 /*
7914 * we need to process the result first before removing it from active list
7915 * because state changes still happening insides roamQProcessRoamResults so
7916 * no other roam command should be issued.
7917 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007918 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7919 if(pCommand->u.roamCmd.fReleaseProfile)
7920 {
7921 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7922 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7923 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007924 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007925 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007926 else
7927 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007928 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007929 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007930 }
7931 }
7932 else
7933 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007934 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007935 }
7936 }
7937 else
7938 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007939 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007940 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007941
7942 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007943 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7944
Kiet Lam64c1b492013-07-12 13:56:44 +05307945 vos_mem_copy(roamInfo.bssid,
7946 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7947 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007948
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007949 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7950 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007951
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007952 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05307953 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7954 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07007955 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307956 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007957 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
7958 //make sure to put it at the head of the cmd queue
7959 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
7960 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
7961 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
7962
Jeff Johnson295189b2012-06-20 16:38:30 -07007963 if(!HAL_STATUS_SUCCESS(status))
7964 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007965 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007966 __func__, status);
7967 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007968 }
7969
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007970 /* Notify sub-modules like QoS etc. that handoff happening */
7971 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08007972 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307973 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007974 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307975 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007976 return;
7977 }
7978
7979POST_ROAM_FAILURE:
7980 if (pScanFilter)
7981 {
7982 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307983 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007984 }
7985 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05307986 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007987
7988 /* Inform the upper layers that the reassoc failed */
7989 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7990 csrRoamCallCallback(pMac, sessionId,
7991 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
7992
7993 /*
7994 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
7995 * Upon success, we would re-enter this routine after receiving the disassoc
7996 * response and will fall into the reassoc fail sub-state. And, eventually
7997 * call csrRoamComplete which would remove the roam command from SME active
7998 * queue.
7999 */
8000 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8001 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008003 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008004 __func__, status);
8005 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008006 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008007#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008008
Jeff Johnson295189b2012-06-20 16:38:30 -07008009 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8010 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8011 {
8012 // Disassoc due to Reassoc failure falls into this codepath....
8013 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8014 }
8015 else
8016 {
8017 if ( eSIR_SME_SUCCESS == statusCode )
8018 {
8019 // Successfully disassociated from the 'old' Bss...
8020 //
8021 // We get Disassociate response in three conditions.
8022 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8023 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8024 // Infrastructure network.
8025 // - Third is where we are doing an Infra to Infra roam between networks with different
8026 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8027
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008028 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008029 }
8030 else
8031 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008032 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008033 }
8034 //We are not done yet. Get the data and continue roaming
8035 csrRoamReissueRoamCommand(pMac);
8036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008037}
8038
Jeff Johnson295189b2012-06-20 16:38:30 -07008039static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8040{
8041 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008042 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008043 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008044 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
8045 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8046 {
8047 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8048 }
8049 else
8050 {
8051 if ( eSIR_SME_SUCCESS == statusCode )
8052 {
8053 // Successfully deauth from the 'old' Bss...
8054 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008055 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008056 }
8057 else
8058 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008059 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08lX", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008060 }
8061 //We are not done yet. Get the data and continue roaming
8062 csrRoamReissueRoamCommand(pMac);
8063 }
8064}
8065
Jeff Johnson295189b2012-06-20 16:38:30 -07008066static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8067{
8068 eCsrRoamCompleteResult result;
8069
8070 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8071 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008072 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008073 result = eCsrStartBssSuccess;
8074 }
8075 else
8076 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008077 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08lX", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008078 //Let csrRoamComplete decide what to do
8079 result = eCsrStartBssFailure;
8080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008081 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008082}
8083
Jeff Johnson295189b2012-06-20 16:38:30 -07008084/*
8085 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8086 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8087 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8088 For the messages where sender allocates memory for specific structures, then it can be
8089 cast accordingly.
8090*/
8091void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8092{
8093 tSirSmeRsp *pSmeRsp;
8094 tSmeIbssPeerInd *pIbssPeerInd;
8095 tCsrRoamInfo roamInfo;
8096 // TODO Session Id need to be acquired in this function
8097 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008098 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008099 smsLog( pMac, LOG2, "Message %d[0x%04X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008100 pSmeRsp->messageType, pSmeRsp->messageType,
8101 pMac->roam.curSubState[pSmeRsp->sessionId] );
Jeff Johnson295189b2012-06-20 16:38:30 -07008102 pSmeRsp->messageType = (pSmeRsp->messageType);
8103 pSmeRsp->length = (pSmeRsp->length);
8104 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008105 switch (pSmeRsp->messageType)
8106 {
8107
8108 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8109 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8110 {
8111 //We sent a JOIN_REQ
8112 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8113 }
8114 break;
8115
8116 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8117 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8118 {
8119 //We sent a AUTH_REQ
8120 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8121 }
8122 break;
8123
8124 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8125 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8126 {
8127 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8128 }
8129 break;
8130
8131 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8132 {
8133 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8134 }
8135 break;
8136
8137 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8138 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8139 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8140 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8141 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8142 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8143//HO
8144 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8145 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008146 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %d"), pMac->roam.curSubState[pSmeRsp->sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008147 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
8148 }
8149 break;
8150
8151 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8152 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8153 {
8154 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8155 }
8156 break;
8157
8158 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8159 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8160 {
8161 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8162 }
8163 break;
8164
8165 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8166 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8167 {
8168 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8169 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008170 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008171 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8172 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8173 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008174 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308175 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8176 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008177 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8178 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308179 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8180 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008181 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8182 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8183 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8184 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008185 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008186 smsLog( pMac, LOG1, "Unexpected message type = %d[0x%X] received in substate %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07008187 pSmeRsp->messageType, pSmeRsp->messageType,
8188 pMac->roam.curSubState[pSmeRsp->sessionId] );
8189
8190 //If we are connected, check the link status change
8191 if(!csrIsConnStateDisconnected(pMac, sessionId))
8192 {
8193 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8194 }
8195 break;
8196 }
8197}
8198
Jeff Johnson295189b2012-06-20 16:38:30 -07008199void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8200{
8201 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008202 switch (pSirMsg->messageType)
8203 {
8204 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008205 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008206 csrRoamStatsRspProcessor( pMac, pSirMsg );
8207 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008208 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8209 {
8210 tCsrRoamSession *pSession;
8211 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8212 tCsrRoamInfo roamInfo;
8213 tCsrRoamInfo *pRoamInfo = NULL;
8214 tANI_U32 sessionId;
8215 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008216 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308217 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008218 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008219 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8220 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8221 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008222
8223 if(!pSession)
8224 {
8225 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8226 return;
8227 }
8228
Jeff Johnson295189b2012-06-20 16:38:30 -07008229 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8230 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008231 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8232 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8233 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008234 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8235 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308236 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8237 sizeof(tSirMacAddr));
8238 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8239 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008240 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008241 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8242 {
8243 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8244 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8245 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8246 }
8247 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8248 {
8249 vos_sleep( 100 );
8250 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8251 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8252 }
8253
Jeff Johnson295189b2012-06-20 16:38:30 -07008254 }
8255 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008256 default:
8257 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8258 break;
8259 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008260}
8261
Jeff Johnson295189b2012-06-20 16:38:30 -07008262eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8263 tSirBssDescription *pBssDescription,
8264 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8265 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8266 tANI_U8 keyId, tANI_U16 keyLength,
8267 tANI_U8 *pKey, tANI_U8 paeRole )
8268{
8269 eHalStatus status = eHAL_STATUS_SUCCESS;
8270 tAniEdType edType;
8271
8272 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8273 {
8274 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8275 }
8276
8277 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8278
8279 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8280 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8281 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8282 addKey )
8283 {
8284 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008285 setKey.encType = EncryptType;
8286 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308287 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008288 setKey.paeRole = paeRole; //0 for supplicant
8289 setKey.keyId = keyId; // Kye index
8290 setKey.keyLength = keyLength;
8291 if( keyLength )
8292 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308293 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008294 }
8295 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008297 return (status);
8298}
8299
Jeff Johnson295189b2012-06-20 16:38:30 -07008300static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8301 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8302{
8303 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8304 tSmeCmd *pCommand = NULL;
8305#ifdef FEATURE_WLAN_CCX
8306 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8307#endif /* FEATURE_WLAN_CCX */
8308
8309 do
8310 {
8311 pCommand = csrGetCommandBuffer(pMac);
8312 if(NULL == pCommand)
8313 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008314 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008315 status = eHAL_STATUS_RESOURCES;
8316 break;
8317 }
8318 pCommand->command = eSmeCommandSetKey;
8319 pCommand->sessionId = (tANI_U8)sessionId;
8320 // validate the key length, Adjust if too long...
8321 // for static WEP the keys are not set thru' SetContextReq
8322 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8323 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8324 {
8325 //KeyLength maybe 0 for static WEP
8326 if( pSetKey->keyLength )
8327 {
8328 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8329 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008330 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008331 break;
8332 }
8333
8334 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308335 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8336 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008337 }
8338 }
8339 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8340 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8341 {
8342 //KeyLength maybe 0 for static WEP
8343 if( pSetKey->keyLength )
8344 {
8345 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8346 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008347 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008348 break;
8349 }
8350
8351 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308352 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8353 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008354 }
8355 }
8356 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8357 {
8358 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8359 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008360 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008361 break;
8362 }
8363 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308364 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8365 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008366 }
8367 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8368 {
8369 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8370 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008371 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008372 break;
8373 }
8374 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308375 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8376 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008377 }
8378#ifdef FEATURE_WLAN_WAPI
8379 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8380 {
8381 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8382 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008383 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008384 break;
8385 }
8386 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308387 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8388 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008389 }
8390#endif /* FEATURE_WLAN_WAPI */
8391#ifdef FEATURE_WLAN_CCX
8392 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8393 {
8394 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8395 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008396 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008397 break;
8398 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308399 vos_mem_copy(pSession->ccxCckmInfo.krk, pSetKey->Key,
8400 CSR_KRK_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008401 pSession->ccxCckmInfo.reassoc_req_num=1;
8402 pSession->ccxCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
8403 status = eHAL_STATUS_SUCCESS;
8404 break;
8405 }
8406#endif /* FEATURE_WLAN_CCX */
Jeff Johnsone7245742012-09-05 17:12:55 -07008407
Jeff Johnson295189b2012-06-20 16:38:30 -07008408#ifdef WLAN_FEATURE_11W
8409 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008410 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008411 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008412 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008413 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008414 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008415 break;
8416 }
8417 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308418 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008419 }
8420#endif
8421 status = eHAL_STATUS_SUCCESS;
8422 pCommand->u.setKeyCmd.roamId = roamId;
8423 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8424 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308425 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8426 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008427 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8428 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308429 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008430 //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
8431
8432 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8433 if( !HAL_STATUS_SUCCESS( status ) )
8434 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008435 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008436 }
8437 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008438 // Free the command if there has been a failure, or it is a
8439 // "local" operation like the set CCX CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008440 if ( ( NULL != pCommand ) &&
8441 ( (!HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008442#ifdef FEATURE_WLAN_CCX
8443 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8444#endif /* FEATURE_WLAN_CCX */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008445 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008446 {
8447 csrReleaseCommandSetKey( pMac, pCommand );
8448 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008449 return( status );
8450}
8451
Jeff Johnson295189b2012-06-20 16:38:30 -07008452eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8453 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8454{
8455 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8456 tSmeCmd *pCommand = NULL;
8457 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008458 do
8459 {
8460 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8461 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008462 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008463 status = eHAL_STATUS_CSR_WRONG_STATE;
8464 break;
8465 }
8466 pCommand = csrGetCommandBuffer(pMac);
8467 if(NULL == pCommand)
8468 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008469 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008470 status = eHAL_STATUS_RESOURCES;
8471 break;
8472 }
8473 pCommand->command = eSmeCommandRemoveKey;
8474 pCommand->sessionId = (tANI_U8)sessionId;
8475 pCommand->u.removeKeyCmd.roamId = roamId;
8476 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308477 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8478 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008479 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8480 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8481 {
8482 //in this case, put it to the end of the Q incase there is a set key pending.
8483 fImediate = eANI_BOOLEAN_FALSE;
8484 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008485 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07008486 pRemoveKey->encType, pRemoveKey->keyId,
8487 pCommand->u.removeKeyCmd.peerMac[0],
8488 pCommand->u.removeKeyCmd.peerMac[1],
8489 pCommand->u.removeKeyCmd.peerMac[2],
8490 pCommand->u.removeKeyCmd.peerMac[3],
8491 pCommand->u.removeKeyCmd.peerMac[4],
8492 pCommand->u.removeKeyCmd.peerMac[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008493 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8494 if( !HAL_STATUS_SUCCESS( status ) )
8495 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008496 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008497 break;
8498 }
8499 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008500 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8501 {
8502 csrReleaseCommandRemoveKey( pMac, pCommand );
8503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008504 return (status );
8505}
8506
Jeff Johnson295189b2012-06-20 16:38:30 -07008507eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8508{
8509 eHalStatus status;
8510 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8511 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8512 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8513 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008514#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8515 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8516 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008517 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008518 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308519 vos_mem_set(&setKeyEvent,
8520 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008521 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8522 {
8523 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8524 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8525 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8526 }
8527 else
8528 {
8529 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8530 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8531 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8532 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308533 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008534 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008535 {
8536 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008537 //It has to be static WEP here
8538 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8539 {
8540 setKeyEvent.keyId = (v_U8_t)defKeyId;
8541 }
8542 }
8543 else
8544 {
8545 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8546 }
8547 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8548 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8549 }
8550#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008551 if( csrIsSetKeyAllowed(pMac, sessionId) )
8552 {
8553 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8554 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8555 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8556 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8557 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8558 pCommand->u.setKeyCmd.keyRsc);
8559 }
8560 else
8561 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008562 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008563 //Set this status so the error handling take care of the case.
8564 status = eHAL_STATUS_CSR_WRONG_STATE;
8565 }
8566 if( !HAL_STATUS_SUCCESS(status) )
8567 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008568 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008569 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008570#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008571 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008572 {
8573 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8574 {
8575 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8576 }
8577 else
8578 {
8579 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8580 }
8581 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8582 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8583 }
8584#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008585 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008586 return ( status );
8587}
8588
Jeff Johnson295189b2012-06-20 16:38:30 -07008589eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8590{
8591 eHalStatus status;
8592 tpSirSmeRemoveKeyReq pMsg = NULL;
8593 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8594 tANI_U8 *p;
8595 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008596#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8597 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8598 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05308599 vos_mem_set(&removeKeyEvent,
8600 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008601 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8602 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8603 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308604 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008605 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8606 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8607 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8608#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 if( csrIsSetKeyAllowed(pMac, sessionId) )
8610 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308611 pMsg = vos_mem_malloc(wMsgLen);
8612 if ( NULL == pMsg )
8613 status = eHAL_STATUS_FAILURE;
8614 else
8615 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008616 }
8617 else
8618 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008619 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008620 //Set the error status so error handling kicks in below
8621 status = eHAL_STATUS_CSR_WRONG_STATE;
8622 }
8623 if( HAL_STATUS_SUCCESS( status ) )
8624 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308625 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008626 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8627 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008628 pMsg->sessionId = (tANI_U8)sessionId;
8629 pMsg->transactionId = 0;
8630 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8631 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8632 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308633 vos_mem_copy(p,
8634 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8635 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008636 p += sizeof(tSirMacAddr);
8637 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308638 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008639 p += sizeof(tSirMacAddr);
8640 // edType
8641 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8642 p++;
8643 // weptype
8644 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8645 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8646 {
8647 *p = (tANI_U8)eSIR_WEP_STATIC;
8648 }
8649 else
8650 {
8651 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8652 }
8653 p++;
8654 //keyid
8655 *p = pCommand->u.removeKeyCmd.keyId;
8656 p++;
8657 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008658 status = palSendMBMessage(pMac->hHdd, pMsg);
8659 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008660 if( !HAL_STATUS_SUCCESS( status ) )
8661 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008662 smsLog( pMac, LOGE, FL(" error status "), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008663#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8664 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008665 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008666 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8667#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008668 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8669 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008670 return ( status );
8671}
8672
Jeff Johnson295189b2012-06-20 16:38:30 -07008673eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8674{
8675 eHalStatus status;
8676
8677 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8678 {
8679 status = eHAL_STATUS_CSR_WRONG_STATE;
8680 }
8681 else
8682 {
8683 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8684 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008685 return ( status );
8686}
8687
Jeff Johnson295189b2012-06-20 16:38:30 -07008688/*
8689 Prepare a filter base on a profile for parsing the scan results.
8690 Upon successful return, caller MUST call csrFreeScanFilter on
8691 pScanFilter when it is done with the filter.
8692*/
8693eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8694 tCsrScanResultFilter *pScanFilter)
8695{
8696 eHalStatus status = eHAL_STATUS_SUCCESS;
8697 tANI_U32 size = 0;
8698 tANI_U8 index = 0;
8699
8700 do
8701 {
8702 if(pProfile->BSSIDs.numOfBSSIDs)
8703 {
8704 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308705 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8706 if ( NULL == pScanFilter->BSSIDs.bssid )
8707 status = eHAL_STATUS_FAILURE;
8708 else
8709 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008710 if(!HAL_STATUS_SUCCESS(status))
8711 {
8712 break;
8713 }
8714 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308715 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008716 }
8717 if(pProfile->SSIDs.numOfSSIDs)
8718 {
8719 if( !CSR_IS_WDS_STA( pProfile ) )
8720 {
8721 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8722 }
8723 else
8724 {
8725 //For WDS station
8726 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8727 pScanFilter->SSIDs.numOfSSIDs = 1;
8728 }
8729 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308730 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8731 if ( NULL == pScanFilter->SSIDs.SSIDList )
8732 status = eHAL_STATUS_FAILURE;
8733 else
8734 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008735 if(!HAL_STATUS_SUCCESS(status))
8736 {
8737 break;
8738 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308739 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8740 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008741 }
8742 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8743 {
8744 pScanFilter->ChannelInfo.numOfChannels = 0;
8745 pScanFilter->ChannelInfo.ChannelList = NULL;
8746 }
8747 else if(pProfile->ChannelInfo.numOfChannels)
8748 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308749 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8750 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8751 pProfile->ChannelInfo.numOfChannels);
8752 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8753 status = eHAL_STATUS_FAILURE;
8754 else
8755 status = eHAL_STATUS_SUCCESS;
8756
Jeff Johnson295189b2012-06-20 16:38:30 -07008757 pScanFilter->ChannelInfo.numOfChannels = 0;
8758 if(HAL_STATUS_SUCCESS(status))
8759 {
8760 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8761 {
8762 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8763 {
8764 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8765 = pProfile->ChannelInfo.ChannelList[index];
8766 pScanFilter->ChannelInfo.numOfChannels++;
8767 }
8768 else
8769 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008770 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008772 }
8773 }
8774 else
8775 {
8776 break;
8777 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008778 }
8779 else
8780 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008781 smsLog(pMac, LOGW, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008782 status = eHAL_STATUS_FAILURE;
8783 break;
8784 }
8785 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8786 pScanFilter->authType = pProfile->AuthType;
8787 pScanFilter->EncryptionType = pProfile->EncryptionType;
8788 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8789 pScanFilter->BSSType = pProfile->BSSType;
8790 pScanFilter->phyMode = pProfile->phyMode;
8791#ifdef FEATURE_WLAN_WAPI
8792 //check if user asked for WAPI with 11n or auto mode, in that case modify
8793 //the phymode to 11g
8794 if(csrIsProfileWapi(pProfile))
8795 {
8796 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8797 {
8798 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8799 }
8800 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8801 {
8802 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8803 }
8804 if(!pScanFilter->phyMode)
8805 {
8806 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8807 }
8808 }
8809#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008810 /*Save the WPS info*/
8811 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008812 if( pProfile->countryCode[0] )
8813 {
8814 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05308815 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
8816 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008817 }
8818#ifdef WLAN_FEATURE_VOWIFI_11R
8819 if (pProfile->MDID.mdiePresent)
8820 {
8821 pScanFilter->MDID.mdiePresent = 1;
8822 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8823 }
8824#endif
8825
8826 }while(0);
8827
8828 if(!HAL_STATUS_SUCCESS(status))
8829 {
8830 csrFreeScanFilter(pMac, pScanFilter);
8831 }
8832
8833 return(status);
8834}
8835
Jeff Johnson295189b2012-06-20 16:38:30 -07008836tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8837 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8838{
8839 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8840 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008841 do
8842 {
8843 // Validate the type is ok...
8844 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8845 pCommand = csrGetCommandBuffer( pMac );
8846 if ( !pCommand )
8847 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008848 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 break;
8850 }
8851 //Change the substate in case it is waiting for key
8852 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8853 {
8854 csrRoamStopWaitForKeyTimer( pMac );
8855 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8856 }
8857 pCommand->command = eSmeCommandWmStatusChange;
8858 pCommand->sessionId = (tANI_U8)sessionId;
8859 pCommand->u.wmStatusChangeCmd.Type = Type;
8860 if ( eCsrDisassociated == Type )
8861 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308862 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
8863 pSmeRsp,
8864 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008865 }
8866 else
8867 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308868 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
8869 pSmeRsp,
8870 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008871 }
8872 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8873 {
8874 fCommandQueued = eANI_BOOLEAN_TRUE;
8875 }
8876 else
8877 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008878 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 csrReleaseCommandWmStatusChange( pMac, pCommand );
8880 }
8881
Jeff Johnson295189b2012-06-20 16:38:30 -07008882 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8883 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008884 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008885 return( fCommandQueued );
8886}
8887
Jeff Johnson295189b2012-06-20 16:38:30 -07008888static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8889{
8890 v_S7_t rssi = 0;
8891 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8892 if(pGetRssiReq)
8893 {
8894 if(NULL != pGetRssiReq->pVosContext)
8895 {
8896 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8897 }
8898 else
8899 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008900 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008901 return;
8902 }
8903
8904 if(NULL != pGetRssiReq->rssiCallback)
8905 {
8906 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8907 }
8908 else
8909 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008910 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008911 return;
8912 }
8913 }
8914 else
8915 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008916 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008917 }
8918 return;
8919}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308920
8921static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
8922{
8923 tANI_S8 snr = 0;
8924 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
8925
8926 if (pGetSnrReq)
8927 {
8928 if (VOS_STATUS_SUCCESS !=
8929 WDA_GetSnr(pGetSnrReq->staId, &snr))
8930 {
8931 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
8932 return;
8933 }
8934
8935 if (pGetSnrReq->snrCallback)
8936 {
8937 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
8938 pGetSnrReq->pDevContext);
8939 }
8940 else
8941 {
8942 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
8943 return;
8944 }
8945 }
8946 else
8947 {
8948 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
8949 }
8950 return;
8951}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008952#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
8953void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8954{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008955 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
8956
Jeff Johnson36d483b2013-04-08 11:08:53 -07008957 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008958 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07008959 /* Get roam Rssi request is backed up and passed back to the response,
8960 Extract the request message to fetch callback */
8961 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
8962 v_S7_t rssi = pRoamRssiRsp->rssi;
8963
8964 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008965 {
8966 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
8967 reqBkp->rssiCallback = NULL;
8968 vos_mem_free(reqBkp);
8969 }
8970 else
8971 {
8972 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
8973 if (NULL != reqBkp)
8974 {
8975 vos_mem_free(reqBkp);
8976 }
8977 }
8978 }
8979 else
8980 {
8981 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
8982 }
8983 return;
8984}
8985#endif
8986
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07008987
8988#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
8989void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8990{
8991 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
8992
8993 if (NULL != pTsmStatsRsp)
8994 {
8995 /* Get roam Rssi request is backed up and passed back to the response,
8996 Extract the request message to fetch callback */
8997 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
8998
8999 if (NULL != reqBkp)
9000 {
9001 if (NULL != reqBkp->tsmStatsCallback)
9002 {
9003 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9004 pTsmStatsRsp->staId, reqBkp->pDevContext);
9005 reqBkp->tsmStatsCallback = NULL;
9006 }
9007 vos_mem_free(reqBkp);
9008 }
9009 else
9010 {
9011 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9012 if (NULL != reqBkp)
9013 {
9014 vos_mem_free(reqBkp);
9015 }
9016 }
9017 }
9018 else
9019 {
9020 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9021 }
9022 return;
9023}
9024
9025void csrSendCcxAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
9026{
9027 tANI_U32 roamTS2 = 0;
9028 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009029 tpPESession pSessionEntry = NULL;
9030 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009031
9032 if (NULL == pSession)
9033 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009034 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009035 return;
9036 }
9037
9038 roamTS2 = vos_timer_get_system_time();
9039 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009040 smsLog(pMac, LOG1, "Bssid(%02X:%02X:%02X:%02X:%02X:%02X) Roaming Delay(%u ms)",
9041 pSession->connectedProfile.bssid[0], pSession->connectedProfile.bssid[1],
9042 pSession->connectedProfile.bssid[2], pSession->connectedProfile.bssid[3],
9043 pSession->connectedProfile.bssid[4], pSession->connectedProfile.bssid[5],
9044 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009045
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009046 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9047 if (NULL == pSessionEntry)
9048 {
9049 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9050 return;
9051 }
9052 pSessionEntry->ccxContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009053 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
9054 0, eCSR_ROAM_CCX_ADJ_AP_REPORT_IND, 0);
9055}
9056#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
9057
Jeff Johnsone7245742012-09-05 17:12:55 -07009058static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9059{
9060 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9061 if(pTlRssiInd)
9062 {
9063 if(NULL != pTlRssiInd->tlCallback)
9064 {
9065 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009066 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009067 }
9068 else
9069 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009070 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009071 }
9072 }
9073 else
9074 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009075 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009076 }
9077 return;
9078}
Jeff Johnson295189b2012-06-20 16:38:30 -07009079
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309080eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9081{
9082 tpSirResetAPCapsChange pMsg;
9083 tANI_U16 len;
9084 eHalStatus status = eHAL_STATUS_SUCCESS;
9085
9086 /* Create the message and send to lim */
9087 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309088 pMsg = vos_mem_malloc(len);
9089 if ( NULL == pMsg )
9090 status = eHAL_STATUS_FAILURE;
9091 else
9092 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309093 if (HAL_STATUS_SUCCESS(status))
9094 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309095 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309096 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9097 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309098 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309099 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= %02x-%02x-%02x-%02x-%02x-%02x"),
9100 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
9101 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ]);
9102 status = palSendMBMessage(pMac->hHdd, pMsg);
9103 }
9104 else
9105 {
9106 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9107 }
9108 return status;
9109}
9110
Jeff Johnson295189b2012-06-20 16:38:30 -07009111void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9112{
9113 tSirSmeAssocInd *pAssocInd;
9114 tSirSmeDisassocInd *pDisassocInd;
9115 tSirSmeDeauthInd *pDeauthInd;
9116 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9117 tSirSmeNewBssInfo *pNewBss;
9118 tSmeIbssPeerInd *pIbssPeerInd;
9119 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9120 tSirSmeApNewCaps *pApNewCaps;
9121 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9122 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9123 tCsrRoamInfo *pRoamInfo = NULL;
9124 tCsrRoamInfo roamInfo;
9125 eHalStatus status;
9126 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9127 tCsrRoamSession *pSession = NULL;
9128 tpSirSmeSwitchChannelInd pSwitchChnInd;
9129 tSmeMaxAssocInd *pSmeMaxAssocInd;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009130 tSmeCmd pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009131 pSirMsg->messageType = (pSirMsg->messageType);
9132 pSirMsg->length = (pSirMsg->length);
9133 pSirMsg->statusCode = (pSirMsg->statusCode);
Kiet Lam64c1b492013-07-12 13:56:44 +05309134 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009135 switch( pSirMsg->messageType )
9136 {
9137 case eWNI_SME_ASSOC_IND:
9138 {
9139 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009140 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009141 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9142 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9143 if( HAL_STATUS_SUCCESS( status ) )
9144 {
9145 pSession = CSR_GET_SESSION(pMac, sessionId);
9146
Jeff Johnson32d95a32012-09-10 13:15:23 -07009147 if(!pSession)
9148 {
9149 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9150 return;
9151 }
9152
Jeff Johnson295189b2012-06-20 16:38:30 -07009153 pRoamInfo = &roamInfo;
9154
9155 // Required for indicating the frames to upper layer
9156 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9157 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9158
9159 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9160 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9161 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9162 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9163
9164 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9165 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9166 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9167
9168 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9169 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309170 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9171 sizeof(tSirMacAddr));
9172 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9173 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009174 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9175 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009176 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009177 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9178 {
9179 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9180 {
9181 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9182 pSession->pConnectBssDesc,
9183 &(pRoamInfo->peerMac),
9184 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9185 pRoamInfo->fAuthRequired = FALSE;
9186 }
9187 else
9188 {
9189 pRoamInfo->fAuthRequired = TRUE;
9190 }
9191 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9192 if (!HAL_STATUS_SUCCESS(status))
9193 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9194 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009195 /* Send Association completion message to PE */
9196 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9197
9198 /* send a message to CSR itself just to avoid the EAPOL frames going
9199 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009200 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9201 {
9202 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9203 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009204 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9205 {
9206 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9207 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9208 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9209 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009210 }
9211 }
9212 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009213 case eWNI_SME_DISASSOC_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009214 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009215 // Check if AP dis-associated us because of MIC failure. If so,
9216 // then we need to take action immediately and not wait till the
9217 // the WmStatusChange requests is pushed and processed
9218 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9219 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9220 if( HAL_STATUS_SUCCESS( status ) )
9221 {
9222 // If we are in neighbor preauth done state then on receiving
9223 // disassoc or deauth we dont roam instead we just disassoc
9224 // from current ap and then go to disconnected state
9225 // This happens for CCX and 11r FT connections ONLY.
9226#ifdef WLAN_FEATURE_VOWIFI_11R
9227 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9228 {
9229 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9230 }
9231#endif
9232#ifdef FEATURE_WLAN_CCX
9233 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9234 {
9235 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9236 }
9237#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009238#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309239 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009240 {
9241 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9242 }
9243#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009244 pSession = CSR_GET_SESSION( pMac, sessionId );
9245
Jeff Johnson32d95a32012-09-10 13:15:23 -07009246 if(!pSession)
9247 {
9248 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9249 return;
9250 }
9251
Jeff Johnson295189b2012-06-20 16:38:30 -07009252 if ( csrIsConnStateInfra( pMac, sessionId ) )
9253 {
9254 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9255 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009256#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9257 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9258#endif
9259 csrRoamLinkDown(pMac, sessionId);
9260 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009261 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9262 {
9263
9264 pRoamInfo = &roamInfo;
9265
9266 pRoamInfo->statusCode = pDisassocInd->statusCode;
9267 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9268
9269 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
9270
Kiet Lam64c1b492013-07-12 13:56:44 +05309271 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9272 sizeof(tSirMacAddr));
9273 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9274 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009275
9276 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009277
9278 /*
9279 * STA/P2P client got disassociated so remove any pending deauth
9280 * commands in sme pending list
9281 */
9282 pCommand.command = eSmeCommandRoam;
9283 pCommand.sessionId = (tANI_U8)sessionId;
9284 pCommand.u.roamCmd.roamReason = eCsrForcedDeauthSta;
Kiet Lam64c1b492013-07-12 13:56:44 +05309285 vos_mem_copy(pCommand.u.roamCmd.peerMac,
9286 pDisassocInd->peerMacAddr,
9287 sizeof(tSirMacAddr));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08009288 csrRoamRemoveDuplicateCommand(pMac, sessionId, &pCommand, eCsrForcedDeauthSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07009289 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009290 }
9291 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009292 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009293 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009294 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9295 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9296 if( HAL_STATUS_SUCCESS( status ) )
9297 {
9298 // If we are in neighbor preauth done state then on receiving
9299 // disassoc or deauth we dont roam instead we just disassoc
9300 // from current ap and then go to disconnected state
9301 // This happens for CCX and 11r FT connections ONLY.
9302#ifdef WLAN_FEATURE_VOWIFI_11R
9303 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9304 {
9305 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9306 }
9307#endif
9308#ifdef FEATURE_WLAN_CCX
9309 if (csrRoamIsCCXAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9310 {
9311 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9312 }
9313#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009314#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309315 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009316 {
9317 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9318 }
9319#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009320 pSession = CSR_GET_SESSION( pMac, sessionId );
9321
Jeff Johnson32d95a32012-09-10 13:15:23 -07009322 if(!pSession)
9323 {
9324 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9325 return;
9326 }
9327
Jeff Johnson295189b2012-06-20 16:38:30 -07009328 if ( csrIsConnStateInfra( pMac, sessionId ) )
9329 {
9330 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009332#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9333 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9334#endif
9335 csrRoamLinkDown(pMac, sessionId);
9336 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009337 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9338 {
9339
9340 pRoamInfo = &roamInfo;
9341
9342 pRoamInfo->statusCode = pDeauthInd->statusCode;
9343 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9344
9345 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9346
Kiet Lam64c1b492013-07-12 13:56:44 +05309347 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9348 sizeof(tSirMacAddr));
9349 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9350 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009351
9352 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 }
9355 break;
9356
9357 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 -08009358 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009359 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9360 //Update with the new channel id.
9361 //The channel id is hidden in the statusCode.
9362 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9363 if( HAL_STATUS_SUCCESS( status ) )
9364 {
9365 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009366 if(!pSession)
9367 {
9368 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9369 return;
9370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009371 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9372 if(pSession->pConnectBssDesc)
9373 {
9374 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9375 }
9376 }
9377 break;
9378
9379 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009380 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009381 {
9382 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9383 sessionId = pDeauthRsp->sessionId;
9384 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9385 {
9386 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009387 if(!pSession)
9388 {
9389 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9390 return;
9391 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009392 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9393 {
9394 pRoamInfo = &roamInfo;
9395 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309396 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9397 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009398 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9399 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9400 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9401 }
9402 }
9403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009404 break;
9405
9406 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009407 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009408 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009409 {
9410 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9411 sessionId = pDisassocRsp->sessionId;
9412 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9413 {
9414 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07009415 if(!pSession)
9416 {
9417 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9418 return;
9419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009420 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9421 {
9422 pRoamInfo = &roamInfo;
9423 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309424 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9425 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009426 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9427 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9428 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9429 }
9430 }
9431 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009432 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009433 case eWNI_SME_MIC_FAILURE_IND:
9434 {
9435 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9436 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9437 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009438
9439 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9440 if( HAL_STATUS_SUCCESS( status ) )
9441 {
9442 palZeroMemory(pMac->hHdd, &roamInfo, sizeof(tCsrRoamInfo));
9443 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9444 pRoamInfo = &roamInfo;
9445 if(pMicInd->info.multicast)
9446 {
9447 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9448 }
9449 else
9450 {
9451 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9452 }
9453 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9454 }
9455
Jeff Johnson295189b2012-06-20 16:38:30 -07009456#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9457 {
lukez3c809222013-05-03 10:23:02 -07009458 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009459 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009460 if(!pSession)
9461 {
9462 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9463 return;
9464 }
lukez3c809222013-05-03 10:23:02 -07009465
Kiet Lam64c1b492013-07-12 13:56:44 +05309466 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009467 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9468 secEvent.encryptionModeMulticast =
9469 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9470 secEvent.encryptionModeUnicast =
9471 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9472 secEvent.authMode =
9473 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309474 vos_mem_copy(secEvent.bssid,
9475 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009476 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9477 }
9478#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009479 }
9480 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009481 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9482 {
9483 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9484 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009485 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009486
9487 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9488 if( HAL_STATUS_SUCCESS( status ) )
9489 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309490 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009491 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9492 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9493 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9494 }
9495 }
9496 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009497
Jeff Johnson295189b2012-06-20 16:38:30 -07009498 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9499 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9500 switch( pStatusChangeMsg->statusChangeCode )
9501 {
9502 case eSIR_SME_IBSS_ACTIVE:
9503 sessionId = csrFindIbssSession( pMac );
9504 if( CSR_SESSION_ID_INVALID != sessionId )
9505 {
9506 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009507 if(!pSession)
9508 {
9509 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9510 return;
9511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009512 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9513 if(pSession->pConnectBssDesc)
9514 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309515 vos_mem_copy(&roamInfo.bssid,
9516 pSession->pConnectBssDesc->bssId,
9517 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009518 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9519 pRoamInfo = &roamInfo;
9520 }
9521 else
9522 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009523 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009524 }
9525 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9526 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9527 }
9528 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 case eSIR_SME_IBSS_INACTIVE:
9530 sessionId = csrFindIbssSession( pMac );
9531 if( CSR_SESSION_ID_INVALID != sessionId )
9532 {
9533 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009534 if(!pSession)
9535 {
9536 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9537 return;
9538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009539 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9540 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9541 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9542 }
9543 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009544 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9545 sessionId = csrFindIbssSession( pMac );
9546 if( CSR_SESSION_ID_INVALID != sessionId )
9547 {
9548 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009549 if(!pSession)
9550 {
9551 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9552 return;
9553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 // update the connection state information
9555 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009556#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9557 {
9558 vos_log_ibss_pkt_type *pIbssLog;
9559 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009560 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9561 if(pIbssLog)
9562 {
9563 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9564 if(pNewBss)
9565 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309566 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009567 if(pNewBss->ssId.length)
9568 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309569 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9570 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009571 }
9572 pIbssLog->operatingChannel = pNewBss->channelNumber;
9573 }
9574 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9575 {
9576 //***U8 is not enough for beacon interval
9577 pIbssLog->beaconInterval = (v_U8_t)bi;
9578 }
9579 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9580 }
9581 }
9582#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009583 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009584
9585 if ((eCSR_ENCRYPT_TYPE_NONE ==
9586 pSession->connectedProfile.EncryptionType ))
9587 {
9588 csrRoamIssueSetContextReq( pMac, sessionId,
9589 pSession->connectedProfile.EncryptionType,
9590 pSession->pConnectBssDesc,
9591 &Broadcastaddr,
9592 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9593 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009594 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9595 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309596 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9597 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009598 pRoamInfo = &roamInfo;
9599 //This BSSID is th ereal BSSID, let's save it
9600 if(pSession->pConnectBssDesc)
9601 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309602 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9603 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009605 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009606 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009607 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009608 // detection by LIM that the capabilities of the associated AP have changed.
9609 case eSIR_SME_AP_CAPS_CHANGED:
9610 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009611 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009612 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9613 if( HAL_STATUS_SUCCESS( status ) )
9614 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009615 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9616 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309617 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009618 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9619 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9620 )
9621 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309622 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9623 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009624 }
9625 else
9626 {
9627 smsLog(pMac, LOGW,
9628 "Skipping csrScanForCapabilityChange as "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009629 "CSR is in state %d and sub-state %d",
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009630 pMac->roam.curState[sessionId],
9631 pMac->roam.curSubState[sessionId]);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309632 /* We ignore the caps change event if CSR is not in full connected state.
9633 * Send one event to PE to reset limSentCapsChangeNtf
9634 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9635 * otherwise lim cannot send any CAPS change events to SME */
9636 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009637 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009638 }
9639 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309640
Jeff Johnson295189b2012-06-20 16:38:30 -07009641 default:
9642 roamStatus = eCSR_ROAM_FAILED;
9643 result = eCSR_ROAM_RESULT_NONE;
9644 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009645 } // end switch on statusChangeCode
9646 if(eCSR_ROAM_RESULT_NONE != result)
9647 {
9648 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9649 }
9650 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009651 case eWNI_SME_IBSS_NEW_PEER_IND:
9652 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009653#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9654 {
9655 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009656 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9657 if(pIbssLog)
9658 {
9659 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309660 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009661 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9662 }
9663 }
9664#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009665 sessionId = csrFindIbssSession( pMac );
9666 if( CSR_SESSION_ID_INVALID != sessionId )
9667 {
9668 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009669
9670 if(!pSession)
9671 {
9672 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9673 return;
9674 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009675 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9676 if(pSession->pConnectBssDesc)
9677 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309678 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9679 sizeof(tCsrBssid));
9680 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9681 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009682 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9683 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309684 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9685 - sizeof(tSmeIbssPeerInd)));
9686 if ( NULL == roamInfo.pbFrames )
9687 status = eHAL_STATUS_FAILURE;
9688 else
9689 status = eHAL_STATUS_SUCCESS;
9690 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009691 {
9692 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309693 vos_mem_copy(roamInfo.pbFrames,
9694 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9695 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009696 }
9697 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9698 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9699 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309700 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9701 if ( NULL == roamInfo.pBssDesc )
9702 status = eHAL_STATUS_FAILURE;
9703 else
9704 status = eHAL_STATUS_SUCCESS;
9705 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009706 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309707 vos_mem_copy(roamInfo.pBssDesc,
9708 pSession->pConnectBssDesc,
9709 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009710 }
9711 if(HAL_STATUS_SUCCESS(status))
9712 {
9713 pRoamInfo = &roamInfo;
9714 }
9715 else
9716 {
9717 if(roamInfo.pbFrames)
9718 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309719 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009720 }
9721 if(roamInfo.pBssDesc)
9722 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309723 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009724 }
9725 }
9726 }
9727 else
9728 {
9729 pRoamInfo = &roamInfo;
9730 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009731 if ((eCSR_ENCRYPT_TYPE_NONE ==
9732 pSession->connectedProfile.EncryptionType ))
9733 {
9734 csrRoamIssueSetContextReq( pMac, sessionId,
9735 pSession->connectedProfile.EncryptionType,
9736 pSession->pConnectBssDesc,
9737 &(pIbssPeerInd->peerAddr),
9738 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9739 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009740 }
9741 else
9742 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009743 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009744 }
9745 //send up the sec type for the new peer
9746 if (pRoamInfo)
9747 {
9748 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9749 }
9750 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9751 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9752 if(pRoamInfo)
9753 {
9754 if(roamInfo.pbFrames)
9755 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309756 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009757 }
9758 if(roamInfo.pBssDesc)
9759 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309760 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009761 }
9762 }
9763 }
9764 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009765 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9766 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9767 sessionId = csrFindIbssSession( pMac );
9768 if( CSR_SESSION_ID_INVALID != sessionId )
9769 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009770#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9771 {
9772 vos_log_ibss_pkt_type *pIbssLog;
9773
9774 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9775 if(pIbssLog)
9776 {
9777 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9778 if(pIbssPeerInd)
9779 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309780 vos_mem_copy(pIbssLog->peerMacAddr,
9781 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009782 }
9783 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9784 }
9785 }
9786#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009787 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009788 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9789 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9790 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309791 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9792 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009793 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9794 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9795 }
9796 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009797 case eWNI_SME_SETCONTEXT_RSP:
9798 {
9799 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9800 tListElem *pEntry;
9801 tSmeCmd *pCommand;
9802
9803 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9804 if ( pEntry )
9805 {
9806 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9807 if ( eSmeCommandSetKey == pCommand->command )
9808 {
9809 sessionId = pCommand->sessionId;
9810 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009811
9812 if(!pSession)
9813 {
9814 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9815 return;
9816 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009817
9818#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9819 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9820 {
9821 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309822 vos_mem_set(&setKeyEvent,
9823 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009824 if( pRsp->peerMacAddr[0] & 0x01 )
9825 {
9826 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9827 }
9828 else
9829 {
9830 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9831 }
9832 setKeyEvent.encryptionModeMulticast =
9833 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9834 setKeyEvent.encryptionModeUnicast =
9835 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309836 vos_mem_copy(setKeyEvent.bssid,
9837 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009838 setKeyEvent.authMode =
9839 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009840 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009841 {
9842 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9843 }
9844 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9845 }
9846#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9847 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9848 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009849 csrRoamStopWaitForKeyTimer( pMac );
9850
Jeff Johnson295189b2012-06-20 16:38:30 -07009851 //We are done with authentication, whethere succeed or not
9852 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009853 //We do it here because this linkup function is not called after association
9854 //when a key needs to be set.
9855 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9856 {
9857 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9858 }
9859 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009860 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009861 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309862 vos_mem_copy(&roamInfo.peerMac,
9863 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07009864 //Make sure we install the GTK before indicating to HDD as authenticated
9865 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +05309866 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
9867 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009868 {
Yathish9f22e662012-12-10 14:21:35 -08009869#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9870 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9871 {
9872 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +05309873 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -08009874 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9875 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9876 pMsg->seesionId = sessionId;
9877 status = palSendMBMessage(pMac->hHdd, pMsg );
9878 }
9879#endif
9880 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009881 }
9882 else
9883 {
9884 result = eCSR_ROAM_RESULT_NONE;
9885 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009886 pRoamInfo = &roamInfo;
9887 }
9888 else
9889 {
9890 result = eCSR_ROAM_RESULT_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009891 smsLog( pMac, LOGE, "CSR: Roam Completion setkey command failed(%d) PeerMac %02X-%02X-%02X-%02X-%02X-%02X...",
Jeff Johnson295189b2012-06-20 16:38:30 -07009892 pRsp->statusCode, pRsp->peerMacAddr[0], pRsp->peerMacAddr[1], pRsp->peerMacAddr[2],
9893 pRsp->peerMacAddr[3], pRsp->peerMacAddr[4], pRsp->peerMacAddr[5] );
9894 }
9895 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9896 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009897 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9898 // can go ahead and initiate the TSPEC if any are pending
9899 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009900#ifdef FEATURE_WLAN_CCX
9901 //Send Adjacent AP repot to new AP.
9902 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9903 pSession->isPrevApInfoValid &&
9904 pSession->connectedProfile.isCCXAssoc)
9905 {
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009906#ifdef FEATURE_WLAN_CCX_UPLOAD
9907 csrSendCcxAdjacentApRepInd(pMac, pSession);
9908#else
Jeff Johnson295189b2012-06-20 16:38:30 -07009909 csrCcxSendAdjacentApRepMsg(pMac, pSession);
9910#endif
9911 pSession->isPrevApInfoValid = FALSE;
9912 }
9913#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009914 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9915 {
9916 csrReleaseCommandSetKey( pMac, pCommand );
9917 }
9918 }
9919 else
9920 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009921 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009922 }
9923 }
9924 else
9925 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009926 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009928 smeProcessPendingQueue( pMac );
9929 }
9930 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009931 case eWNI_SME_REMOVEKEY_RSP:
9932 {
9933 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
9934 tListElem *pEntry;
9935 tSmeCmd *pCommand;
9936
9937 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9938 if ( pEntry )
9939 {
9940 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9941 if ( eSmeCommandRemoveKey == pCommand->command )
9942 {
9943 sessionId = pCommand->sessionId;
9944 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009945
9946 if(!pSession)
9947 {
9948 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9949 return;
9950 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009951#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9952 {
9953 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309954 vos_mem_set(&removeKeyEvent,
9955 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009956 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
9957 removeKeyEvent.encryptionModeMulticast =
9958 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9959 removeKeyEvent.encryptionModeUnicast =
9960 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309961 vos_mem_copy( removeKeyEvent.bssid,
9962 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009963 removeKeyEvent.authMode =
9964 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009965 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009966 {
9967 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9968 }
9969 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9970 }
9971#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -07009972 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009973 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309974 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
9975 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009976 result = eCSR_ROAM_RESULT_NONE;
9977 pRoamInfo = &roamInfo;
9978 }
9979 else
9980 {
9981 result = eCSR_ROAM_RESULT_FAILURE;
9982 }
9983 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9984 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
9985 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9986 {
9987 csrReleaseCommandRemoveKey( pMac, pCommand );
9988 }
9989 }
9990 else
9991 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009992 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009993 }
9994 }
9995 else
9996 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009997 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07009998 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009999 smeProcessPendingQueue( pMac );
10000 }
10001 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010002 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010003 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010004 csrRoamStatsRspProcessor( pMac, pSirMsg );
10005 break;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010006#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
10007 case eWNI_SME_GET_ROAM_RSSI_RSP:
10008 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10009 csrRoamRssiRspProcessor( pMac, pSirMsg );
10010 break;
10011#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010012#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
10013 case eWNI_SME_GET_TSM_STATS_RSP:
10014 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10015 csrTsmStatsRspProcessor( pMac, pSirMsg );
10016 break;
10017#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010018 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010019 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010020 csrUpdateRssi( pMac, pSirMsg );
10021 break;
10022
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010023 case eWNI_SME_GET_SNR_REQ:
10024 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10025 csrUpdateSnr(pMac, pSirMsg);
10026 break;
10027
Jeff Johnson295189b2012-06-20 16:38:30 -070010028#ifdef WLAN_FEATURE_VOWIFI_11R
10029 case eWNI_SME_FT_PRE_AUTH_RSP:
10030 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10031 break;
10032#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010033 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10034 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010035 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 -070010036 sessionId = pSmeMaxAssocInd->sessionId;
10037 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010038 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10039 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010040 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10041 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10042 break;
10043
10044 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010045 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010046 btampEstablishLogLinkHdlr( pSirMsg );
10047 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010048 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010049 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010050 csrRoamRssiIndHdlr( pMac, pSirMsg );
10051 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010052#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10053 case eWNI_SME_CANDIDATE_FOUND_IND:
10054 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10055 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10056 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010057 case eWNI_SME_HANDOFF_REQ:
10058 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10059 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10060 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010061#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010062
10063 default:
10064 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010065 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010066}
10067
Jeff Johnson295189b2012-06-20 16:38:30 -070010068void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10069 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10070{
10071 if(pSession)
10072 {
10073 if(pSession->bRefAssocStartCnt)
10074 {
10075 pSession->bRefAssocStartCnt--;
10076 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10077 //Need to call association_completion because there is an assoc_start pending.
10078 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10079 eCSR_ROAM_ASSOCIATION_COMPLETION,
10080 eCSR_ROAM_RESULT_FAILURE);
10081 }
10082 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10083 }
10084 else
10085 {
10086 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10087 }
10088}
10089
10090
10091eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10092{
10093 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010094 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10095 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10096 {
10097 status = csrScanRequestLostLink1( pMac, sessionId );
10098 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010099 return(status);
10100}
10101
Jeff Johnson295189b2012-06-20 16:38:30 -070010102//return a boolean to indicate whether roaming completed or continue.
10103tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10104 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10105{
10106 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10107 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10108 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10109 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010110 if(!pSession)
10111 {
10112 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10113 return eANI_BOOLEAN_FALSE;
10114 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010115 //Check whether time is up
10116 if(pSession->fCancelRoaming || fForce ||
10117 ((curTime - pSession->roamingStartTime) > roamTime) ||
10118 eCsrReassocRoaming == pSession->roamingReason ||
10119 eCsrDynamicRoaming == pSession->roamingReason)
10120 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010121 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010122 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10123 {
10124 //roaming is cancelled, tell HDD to indicate disconnect
10125 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10126 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10127 //to be eSIR_BEACON_MISSED
10128 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10129 {
10130 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10131 }
10132 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10133 {
10134 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10135 }
10136 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10137 {
10138 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10139 }
10140 else
10141 {
10142 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10143 }
10144 }
10145 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10146 pSession->roamingReason = eCsrNotRoaming;
10147 }
10148 else
10149 {
10150 pSession->roamResult = roamResult;
10151 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10152 {
10153 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10154 pSession->roamingReason = eCsrNotRoaming;
10155 }
10156 else
10157 {
10158 fCompleted = eANI_BOOLEAN_FALSE;
10159 }
10160 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010161 return(fCompleted);
10162}
10163
Jeff Johnson295189b2012-06-20 16:38:30 -070010164void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10165{
10166 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010167
10168 if(!pSession)
10169 {
10170 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10171 return;
10172 }
10173
Jeff Johnson295189b2012-06-20 16:38:30 -070010174 if(CSR_IS_ROAMING(pSession))
10175 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010176 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010177 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10178 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10179 {
10180 //No need to do anything in here because the handler takes care of it
10181 }
10182 else
10183 {
10184 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10185 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10186 //Roaming is stopped after here
10187 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10188 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +053010189 csrScanAbortMacScan(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010190 csrRoamStopRoamingTimer(pMac, sessionId);
10191 }
10192 }
10193}
10194
Jeff Johnson295189b2012-06-20 16:38:30 -070010195void csrRoamRoamingTimerHandler(void *pv)
10196{
10197 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10198 tpAniSirGlobal pMac = pInfo->pMac;
10199 tANI_U32 sessionId = pInfo->sessionId;
10200 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010201
10202 if(!pSession)
10203 {
10204 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10205 return;
10206 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010207
10208 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10209 {
10210 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10211 {
10212 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10213 pSession->roamingReason = eCsrNotRoaming;
10214 }
10215 }
10216}
10217
Jeff Johnson295189b2012-06-20 16:38:30 -070010218eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10219{
10220 eHalStatus status;
10221 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010222
10223 if(!pSession)
10224 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010225 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010226 return eHAL_STATUS_FAILURE;
10227 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010228
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010229 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010230 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010231 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010232
10233 return (status);
10234}
10235
Jeff Johnson295189b2012-06-20 16:38:30 -070010236eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10237{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010238 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010239}
10240
Jeff Johnson295189b2012-06-20 16:38:30 -070010241void csrRoamWaitForKeyTimeOutHandler(void *pv)
10242{
10243 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10244 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010245 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
10246
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010247 smsLog(pMac, LOGW, "WaitForKey timer expired in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010248 pMac->roam.neighborRoamInfo.neighborRoamState,
10249 pMac->roam.curSubState[pInfo->sessionId]);
10250
Jeff Johnson295189b2012-06-20 16:38:30 -070010251 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10252 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010253#ifdef FEATURE_WLAN_LFR
10254 if (csrNeighborRoamIsHandoffInProgress(pMac))
10255 {
10256 /*
10257 * Enable heartbeat timer when hand-off is in progress
10258 * and Key Wait timer expired.
10259 */
10260 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010261 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010262 pMac->roam.configParam.HeartbeatThresh24);
10263 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10264 pMac->roam.configParam.HeartbeatThresh24,
10265 NULL, eANI_BOOLEAN_FALSE);
10266 }
10267#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010268 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010269
Jeff Johnson295189b2012-06-20 16:38:30 -070010270 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010271 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10272 {
10273 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10274 pInfo->sessionId);
10275 }
10276
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010277 if (pSession)
10278 {
10279 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10280 {
10281 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10282 smeProcessPendingQueue(pMac);
10283 }
10284 else
10285 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010286 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010287 __func__);
10288 }
10289 }
10290 else
10291 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010292 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010293 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010294 }
10295
10296}
10297
Jeff Johnson295189b2012-06-20 16:38:30 -070010298eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10299{
10300 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010301#ifdef FEATURE_WLAN_LFR
10302 if (csrNeighborRoamIsHandoffInProgress(pMac))
10303 {
10304 /* Disable heartbeat timer when hand-off is in progress */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010305 smsLog(pMac, LOG2, "%s: disabling HB timer in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010306 __func__,
10307 pMac->roam.neighborRoamInfo.neighborRoamState,
10308 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10309 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10310 }
10311#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010312 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010313 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010314
10315 return (status);
10316}
10317
Jeff Johnson295189b2012-06-20 16:38:30 -070010318eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10319{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010320 smsLog(pMac, LOG2, "WaitForKey timer stopped in state=%d sub-state=%d",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010321 pMac->roam.neighborRoamInfo.neighborRoamState,
10322 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]);
10323#ifdef FEATURE_WLAN_LFR
10324 if (csrNeighborRoamIsHandoffInProgress(pMac))
10325 {
10326 /*
10327 * Enable heartbeat timer when hand-off is in progress
10328 * and Key Wait timer got stopped for some reason
10329 */
10330 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010331 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010332 pMac->roam.configParam.HeartbeatThresh24);
10333 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10334 pMac->roam.configParam.HeartbeatThresh24,
10335 NULL, eANI_BOOLEAN_FALSE);
10336 }
10337#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010338 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010339}
10340
Jeff Johnson295189b2012-06-20 16:38:30 -070010341void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10342 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10343{
10344 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10345 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010346 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10347 /* To silence the KW tool Null chaeck is added */
10348 if(!pSession)
10349 {
10350 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10351 return;
10352 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010353
10354 if(pCommand)
10355 {
10356 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010357 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010358 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010359 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10360 {
10361 //if success, force roaming completion
10362 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10363 }
10364 else
10365 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010366 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010367 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010368 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10369 }
10370}
10371
Jeff Johnson295189b2012-06-20 16:38:30 -070010372eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10373{
10374 eHalStatus status = eHAL_STATUS_SUCCESS;
10375 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10376 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10377 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10378 tCsrRoamInfo *pRoamInfo = NULL;
10379 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010380 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010381 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010382 /* To silence the KW tool Null chaeck is added */
10383 if(!pSession)
10384 {
10385 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10386 return eHAL_STATUS_FAILURE;
10387 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010388 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010389 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010390 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10391 if ( eWNI_SME_DISASSOC_IND == type )
10392 {
10393 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10394 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10395 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010396 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010397 }
10398 else if ( eWNI_SME_DEAUTH_IND == type )
10399 {
10400 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10401 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10402 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010403 /* Convert into proper reason code */
10404 pSession->joinFailStatusCode.reasonCode =
10405 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010406 0 : pDeauthIndMsg->reasonCode;
10407 /* cfg layer expects 0 as reason code if
10408 the driver dosent know the reason code
10409 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010410 }
10411 else
10412 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010413 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010414 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010415 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010416 }
10417
10418 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010419 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010420 {
10421 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10422 }
10423
10424 if ( eWNI_SME_DISASSOC_IND == type )
10425 {
10426 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10427 }
10428 else if ( eWNI_SME_DEAUTH_IND == type )
10429 {
10430 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10431 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010432 if(!HAL_STATUS_SUCCESS(status))
10433 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010434 //If fail to send confirmation to PE, not to trigger roaming
10435 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010436 }
10437
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010438 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010439 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010440 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10441 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010442 if( eWNI_SME_DISASSOC_IND == type)
10443 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010444 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010445 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10446 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010447 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10448 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010449 else if( eWNI_SME_DEAUTH_IND == type )
10450 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010451 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010452 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10453 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010454 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10455 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010456 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010457
10458 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10459 that we are roaming. But if we cannot possibly roam, or if we are unable to
10460 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010461 if(fToRoam)
10462 {
10463 //Only remove the connected BSS in infrastructure mode
10464 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10465 //Not to do anying for lostlink with WDS
10466 if( pMac->roam.configParam.nRoamingTime )
10467 {
10468 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10469 ( eWNI_SME_DEAUTH_IND == type ) ?
10470 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10471 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010472 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010473 //For IBSS, we need to give some more info to HDD
10474 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10475 {
10476 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10477 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10478 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10479 }
10480 else
10481 {
10482 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10483 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010484 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010485 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10486 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10487 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10488 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10489 }
10490 else
10491 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010492 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010493 fToRoam = eANI_BOOLEAN_FALSE;
10494 }
10495 }
10496 else
10497 {
10498 //We are told not to roam, indicate lostlink
10499 fToRoam = eANI_BOOLEAN_FALSE;
10500 }
10501 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010502 if(!fToRoam)
10503 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010504 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010505 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010506 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010507 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10508 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10509 * csrRoamCheckForLinkStatusChange API.
10510 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010511 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10512 }
10513
10514 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010515 Still enable idle scan for polling in case concurrent sessions are running */
10516 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10517 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010518 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010519 }
10520 }
10521
10522 return (status);
10523}
10524
Jeff Johnson295189b2012-06-20 16:38:30 -070010525eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10526{
10527 eHalStatus status = eHAL_STATUS_SUCCESS;
10528 tListElem *pEntry = NULL;
10529 tSmeCmd *pCommand = NULL;
10530 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010531
10532 if(!pSession)
10533 {
10534 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10535 return eHAL_STATUS_FAILURE;
10536 }
10537
Jeff Johnson295189b2012-06-20 16:38:30 -070010538 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010539 //Only remove the connected BSS in infrastructure mode
10540 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10541 if(pMac->roam.configParam.nRoamingTime)
10542 {
10543 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10544 {
10545 //before starting the lost link logic release the roam command for handoff
10546 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10547 if(pEntry)
10548 {
10549 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10550 }
10551 if(pCommand)
10552 {
10553 if (( eSmeCommandRoam == pCommand->command ) &&
10554 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10555 {
10556 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10557 {
10558 csrReleaseCommandRoam( pMac, pCommand );
10559 }
10560 }
10561 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010562 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010563 }
10564 }
10565 else
10566 {
10567 //We are told not to roam, indicate lostlink
10568 status = eHAL_STATUS_FAILURE;
10569 }
10570
10571 return (status);
10572}
Jeff Johnson295189b2012-06-20 16:38:30 -070010573void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10574{
10575 tListElem *pEntry;
10576 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010577 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10578 if ( pEntry )
10579 {
10580 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10581 if ( eSmeCommandWmStatusChange == pCommand->command )
10582 {
10583 // Nothing to process in a Lost Link completion.... It just kicks off a
10584 // roaming sequence.
10585 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10586 {
10587 csrReleaseCommandWmStatusChange( pMac, pCommand );
10588 }
10589 else
10590 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010591 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010592 }
10593
10594 }
10595 else
10596 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010597 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010598 }
10599 }
10600 else
10601 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010602 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010603 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010604 smeProcessPendingQueue( pMac );
10605}
10606
Jeff Johnson295189b2012-06-20 16:38:30 -070010607void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10608{
10609 eHalStatus status = eHAL_STATUS_FAILURE;
10610 tSirSmeRsp *pSirSmeMsg;
10611 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010612
10613 if(!pSession)
10614 {
10615 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10616 return;
10617 }
10618
Jeff Johnson295189b2012-06-20 16:38:30 -070010619 switch ( pCommand->u.wmStatusChangeCmd.Type )
10620 {
10621 case eCsrDisassociated:
10622 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10623 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10624 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010625 case eCsrDeauthenticated:
10626 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10627 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10628 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010629 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010630 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010631 break;
10632 }
10633 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10634 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10635 {
10636 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10637 {
10638 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010639 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010640 }
10641 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010642 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10643 // command here since there is nothing else to do.
10644 csrRoamWmStatusChangeComplete( pMac );
10645}
10646
Jeff Johnson295189b2012-06-20 16:38:30 -070010647//This function returns band and mode information.
10648//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10649//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010650static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10651 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010652{
Jeff Johnson295189b2012-06-20 16:38:30 -070010653 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10654 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10655 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010656 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010657
Jeff Johnson295189b2012-06-20 16:38:30 -070010658 //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 -070010659 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10660 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10661 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10662 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010663 {
10664 switch( pMac->roam.configParam.uCfgDot11Mode )
10665 {
10666 case eCSR_CFG_DOT11_MODE_11A:
10667 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10668 eBand = eCSR_BAND_5G;
10669 break;
10670 case eCSR_CFG_DOT11_MODE_11B:
10671 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10672 eBand = eCSR_BAND_24;
10673 break;
10674 case eCSR_CFG_DOT11_MODE_11G:
10675 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10676 eBand = eCSR_BAND_24;
10677 break;
10678 case eCSR_CFG_DOT11_MODE_11N:
10679 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010680 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10681 break;
10682#ifdef WLAN_FEATURE_11AC
10683 case eCSR_CFG_DOT11_MODE_11AC:
10684 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10685 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010686 /* If the operating channel is in 2.4 GHz band, check for
10687 * INI item to disable VHT operation in 2.4 GHz band
10688 */
10689 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10690 !pMac->roam.configParam.enableVhtFor24GHz)
10691 {
10692 /* Disable 11AC operation */
10693 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10694 }
10695 else
10696 {
10697 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10698 }
10699 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010700 }
10701 else
10702 {
10703 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10704 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10705 }
10706 break;
10707 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10708 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10709 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010710 /* If the operating channel is in 2.4 GHz band, check for
10711 * INI item to disable VHT operation in 2.4 GHz band
10712 */
10713 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10714 !pMac->roam.configParam.enableVhtFor24GHz)
10715 {
10716 /* Disable 11AC operation */
10717 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10718 }
10719 else
10720 {
10721 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10722 }
10723 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010724 }
10725 else
10726 {
10727 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10728 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10729 }
10730 break;
10731#endif
10732 case eCSR_CFG_DOT11_MODE_AUTO:
10733 eBand = pMac->roam.configParam.eBand;
10734 if (eCSR_BAND_24 == eBand)
10735 {
10736 // WiFi tests require IBSS networks to start in 11b mode
10737 // without any change to the default parameter settings
10738 // on the adapter. We use ACU to start an IBSS through
10739 // creation of a startIBSS profile. This startIBSS profile
10740 // has Auto MACProtocol and the adapter property setting
10741 // for dot11Mode is also AUTO. So in this case, let's
10742 // start the IBSS network in 11b mode instead of 11g mode.
10743 // So this is for Auto=profile->MacProtocol && Auto=Global.
10744 // dot11Mode && profile->channel is < 14, then start the IBSS
10745 // in b mode.
10746 //
10747 // Note: we used to have this start as an 11g IBSS for best
10748 // performance... now to specify that the user will have to
10749 // set the do11Mode in the property page to 11g to force it.
10750 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10751 }
10752 else
10753 {
10754#ifdef WLAN_FEATURE_11AC
10755 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10756 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010757 /* If the operating channel is in 2.4 GHz band, check for
10758 * INI item to disable VHT operation in 2.4 GHz band
10759 */
10760 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10761 !pMac->roam.configParam.enableVhtFor24GHz)
10762 {
10763 /* Disable 11AC operation */
10764 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10765 }
10766 else
10767 {
10768 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10769 }
10770 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010771 }
10772 else
10773 {
10774 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10775 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10776 }
10777#else
10778 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10779 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10780#endif
10781 }
10782 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010783 default:
10784 // Global dot11 Mode setting is 11a/b/g.
10785 // use the channel number to determine the Mode setting.
10786 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10787 {
10788 eBand = pMac->roam.configParam.eBand;
10789 if(eCSR_BAND_24 == eBand)
10790 {
10791 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10792 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10793 }
10794 else
10795 {
10796 //prefer 5GHz
10797 eBand = eCSR_BAND_5G;
10798 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10799 }
10800 }
10801 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10802 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010803 // WiFi tests require IBSS networks to start in 11b mode
10804 // without any change to the default parameter settings
10805 // on the adapter. We use ACU to start an IBSS through
10806 // creation of a startIBSS profile. This startIBSS profile
10807 // has Auto MACProtocol and the adapter property setting
10808 // for dot11Mode is also AUTO. So in this case, let's
10809 // start the IBSS network in 11b mode instead of 11g mode.
10810 // So this is for Auto=profile->MacProtocol && Auto=Global.
10811 // dot11Mode && profile->channel is < 14, then start the IBSS
10812 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010813 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010814 // Note: we used to have this start as an 11g IBSS for best
10815 // performance... now to specify that the user will have to
10816 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010817 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10818 eBand = eCSR_BAND_24;
10819 }
10820 else
10821 {
10822 // else, it's a 5.0GHz channel. Set mode to 11a.
10823 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10824 eBand = eCSR_BAND_5G;
10825 }
10826 break;
10827 }//switch
10828 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10829 else
10830 {
10831 //dot11 mode is set, lets pick the band
10832 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10833 {
10834 // channel is Auto also.
10835 eBand = pMac->roam.configParam.eBand;
10836 if(eCSR_BAND_ALL == eBand)
10837 {
10838 //prefer 5GHz
10839 eBand = eCSR_BAND_5G;
10840 }
10841 }
10842 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10843 {
10844 eBand = eCSR_BAND_24;
10845 }
10846 else
10847 {
10848 eBand = eCSR_BAND_5G;
10849 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010850 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010851 if(pBand)
10852 {
10853 *pBand = eBand;
10854 }
10855
10856 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010857 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010858 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10859 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010860
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010861 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10862 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 -070010863 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010864#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010865 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010866#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010867 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10868 {
10869 //We cannot do 11n here
10870 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10871 {
10872 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10873 }
10874 else
10875 {
10876 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10877 }
10878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010879 return( cfgDot11Mode );
10880}
10881
Jeff Johnson295189b2012-06-20 16:38:30 -070010882eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10883{
10884 eHalStatus status;
10885 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010886
10887 if(!pSession)
10888 {
10889 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10890 return eHAL_STATUS_FAILURE;
10891 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010892
10893#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10894 {
10895 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010896 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10897 if(pIbssLog)
10898 {
10899 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
10900 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10901 }
10902 }
10903#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010904 // Set the roaming substate to 'stop Bss request'...
10905 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
10906
10907 // attempt to stop the Bss (reason code is ignored...)
10908 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080010909 if(!HAL_STATUS_SUCCESS(status))
10910 {
10911 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
10912 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010913 return (status);
10914}
10915
Jeff Johnson295189b2012-06-20 16:38:30 -070010916//pNumChan is a caller allocated space with the sizeof pChannels
10917eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
10918{
10919
10920 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
10921 (tANI_U8 *)pChannels,
10922 pNumChan));
10923}
10924
Kiran4a17ebe2013-01-31 10:43:43 -080010925tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
10926{
10927 tANI_U32 cfgLength = 0;
10928 tANI_U16 cfgId = 0;
10929 tPowerdBm maxTxPwr = 0;
10930 tANI_U8 *pCountryInfo = NULL;
10931 eHalStatus status;
10932 tANI_U8 count = 0;
10933 tANI_U8 firstChannel;
10934 tANI_U8 maxChannels;
10935
10936 if (CSR_IS_CHANNEL_5GHZ(channel))
10937 {
10938 cfgId = WNI_CFG_MAX_TX_POWER_5;
10939 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
10940 }
10941 else if (CSR_IS_CHANNEL_24GHZ(channel))
10942 {
10943 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
10944 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
10945 }
10946 else
10947 return maxTxPwr;
10948
Kiet Lam64c1b492013-07-12 13:56:44 +053010949 pCountryInfo = vos_mem_malloc(cfgLength);
10950 if ( NULL == pCountryInfo )
10951 status = eHAL_STATUS_FAILURE;
10952 else
10953 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080010954 if (status != eHAL_STATUS_SUCCESS)
10955 {
10956 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053010957 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080010958 __FUNCTION__, status);
10959 goto error;
10960 }
10961 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
10962 if (status != eHAL_STATUS_SUCCESS)
10963 {
10964 goto error;
10965 }
10966 /* Identify the channel and maxtxpower */
10967 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
10968 {
10969 firstChannel = pCountryInfo[count++];
10970 maxChannels = pCountryInfo[count++];
10971 maxTxPwr = pCountryInfo[count++];
10972
10973 if ((channel >= firstChannel) &&
10974 (channel < (firstChannel + maxChannels)))
10975 {
10976 break;
10977 }
10978 }
10979
10980error:
10981 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053010982 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080010983
10984 return maxTxPwr;
10985}
10986
10987
Jeff Johnson295189b2012-06-20 16:38:30 -070010988tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
10989{
10990 tANI_BOOLEAN fValid = FALSE;
10991 tANI_U32 idxValidChannels;
10992 tANI_U32 len = sizeof(pMac->roam.validChannelList);
10993
10994 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
10995 {
10996 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
10997 {
10998 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
10999 {
11000 fValid = TRUE;
11001 break;
11002 }
11003 }
11004 }
11005 pMac->roam.numValidChannels = len;
11006 return fValid;
11007}
11008
Jeff Johnson295189b2012-06-20 16:38:30 -070011009tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11010{
11011 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11012 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011013 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11014 {
11015 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11016 {
11017 fValid = eANI_BOOLEAN_TRUE;
11018 break;
11019 }
11020 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011021 return (fValid);
11022}
11023
Jeff Johnson295189b2012-06-20 16:38:30 -070011024//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011025 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011026{
Jeff Johnsone7245742012-09-05 17:12:55 -070011027 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011028 tANI_U8 centerChn;
11029 tANI_U32 ChannelBondingMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011030 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11031 {
11032 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11033 }
11034 else
11035 {
11036 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11037 }
11038 //Figure what the other side's CB mode
11039 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11040 {
11041 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11042 {
11043 if(pIes->HTInfo.present)
11044 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011045 /* This is called during INFRA STA/CLIENT and should use the merged value of
11046 * supported channel width and recommended tx width as per standard
11047 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011048 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011049 pIes->HTCaps.supportedChannelWidthSet,
11050 pIes->HTInfo.recommendedTxWidthSet,
11051 pIes->HTInfo.secondaryChannelOffset);
11052
11053 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11054 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011055 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011056 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11057 switch (eRet) {
11058 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11059 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11060 break;
11061 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11062 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11063 break;
11064 case PHY_SINGLE_CHANNEL_CENTERED:
11065 default:
11066 centerChn = primaryChn;
11067 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011068 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011069 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011070 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011071 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070011072 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011073 }
11074 }
11075 }
11076 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011077 return eRet;
11078}
Jeff Johnson295189b2012-06-20 16:38:30 -070011079tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11080{
11081 tANI_BOOLEAN fFound = FALSE;
11082 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011083 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11084 {
11085 if( pCipherList->encryptionType[idx] == encryptionType )
11086 {
11087 fFound = TRUE;
11088 break;
11089 }
11090 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011091 return fFound;
11092}
Jeff Johnson295189b2012-06-20 16:38:30 -070011093tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11094{
11095 tANI_BOOLEAN fFound = FALSE;
11096 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011097 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11098 {
11099 if( pAuthList->authType[idx] == authType )
11100 {
11101 fFound = TRUE;
11102 break;
11103 }
11104 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011105 return fFound;
11106}
Jeff Johnson295189b2012-06-20 16:38:30 -070011107tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11108{
11109 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11110 tCsrScanResultFilter *pScanFilter = NULL;
11111 eHalStatus status = eHAL_STATUS_SUCCESS;
11112
11113 if(pProfile1 && pProfile2)
11114 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011115 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11116 if ( NULL == pScanFilter )
11117 status = eHAL_STATUS_FAILURE;
11118 else
11119 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011120 if(HAL_STATUS_SUCCESS(status))
11121 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011122 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011123 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11124 if(HAL_STATUS_SUCCESS(status))
11125 {
11126 fCheck = eANI_BOOLEAN_FALSE;
11127 do
11128 {
11129 tANI_U32 i;
11130 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11131 {
11132 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11133 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11134 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11135 if ( fCheck ) break;
11136 }
11137 if(!fCheck)
11138 {
11139 break;
11140 }
11141 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11142 || pProfile2->BSSType != pProfile1->BSSType
11143 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11144 )
11145 {
11146 fCheck = eANI_BOOLEAN_FALSE;
11147 break;
11148 }
11149#ifdef WLAN_FEATURE_VOWIFI_11R
11150 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11151 {
11152 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11153 {
11154 fCheck = eANI_BOOLEAN_FALSE;
11155 break;
11156 }
11157 }
11158#endif
11159 //Match found
11160 fCheck = eANI_BOOLEAN_TRUE;
11161 }while(0);
11162 csrFreeScanFilter(pMac, pScanFilter);
11163 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011164 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011165 }
11166 }
11167
11168 return (fCheck);
11169}
11170
Jeff Johnson295189b2012-06-20 16:38:30 -070011171tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11172{
11173 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11174 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011175 do
11176 {
11177 //Only check for static WEP
11178 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11179 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11180 {
11181 fCheck = eANI_BOOLEAN_TRUE;
11182 break;
11183 }
11184 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11185 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11186 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11187 {
11188 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011189 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11190 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011191 {
11192 break;
11193 }
11194 }
11195 if( i == CSR_MAX_NUM_KEY)
11196 {
11197 fCheck = eANI_BOOLEAN_TRUE;
11198 }
11199 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011200 return (fCheck);
11201}
11202
Jeff Johnson295189b2012-06-20 16:38:30 -070011203//IBSS
11204
Jeff Johnson295189b2012-06-20 16:38:30 -070011205tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11206{
11207 tANI_U8 channel = 0;
11208 tANI_U32 idx;
11209 tANI_U32 idxValidChannels;
11210 tANI_BOOLEAN fFound = FALSE;
11211 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11212
11213 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11214 {
11215 channel = pMac->roam.configParam.AdHocChannel5G;
11216 if(!csrRoamIsChannelValid(pMac, channel))
11217 {
11218 channel = 0;
11219 }
11220 }
11221 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11222 {
11223 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11224 {
11225 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11226 {
11227 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11228 {
11229 fFound = TRUE;
11230 channel = csrStartIbssChannels50[ idx ];
11231 }
11232 }
11233 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011234 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11235 if (!fFound)
11236 {
11237 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11238 {
11239 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11240 {
11241 channel = csrStartIbssChannels50[ idx ];
11242 break;
11243 }
11244 }
11245 }
11246 }//if
11247
11248 return( channel );
11249}
11250
Jeff Johnson295189b2012-06-20 16:38:30 -070011251tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11252{
11253 tANI_U8 channel = 1;
11254 tANI_U32 idx;
11255 tANI_U32 idxValidChannels;
11256 tANI_BOOLEAN fFound = FALSE;
11257 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11258
11259 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11260 {
11261 channel = pMac->roam.configParam.AdHocChannel24;
11262 if(!csrRoamIsChannelValid(pMac, channel))
11263 {
11264 channel = 0;
11265 }
11266 }
11267
11268 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11269 {
11270 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11271 {
11272 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11273 {
11274 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11275 {
11276 fFound = TRUE;
11277 channel = csrStartIbssChannels24[ idx ];
11278 }
11279 }
11280 }
11281 }
11282
11283 return( channel );
11284}
11285
Jeff Johnson295189b2012-06-20 16:38:30 -070011286static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11287 tCsrRoamStartBssParams *pParam )
11288{
11289 eCsrCfgDot11Mode cfgDot11Mode;
11290 eCsrBand eBand;
11291 tANI_U8 channel = 0;
11292 tSirNwType nwType;
11293 tANI_U8 operationChannel = 0;
11294
11295 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11296 {
11297 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11298 }
11299
Jeff Johnson295189b2012-06-20 16:38:30 -070011300 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011301
Jeff Johnson295189b2012-06-20 16:38:30 -070011302 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11303 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11304 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11305 )
11306 {
11307 /* This should never happen */
11308 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011309 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011310 pProfile->csrPersona);
11311 VOS_ASSERT(0);
11312 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011313 switch( cfgDot11Mode )
11314 {
11315 case eCSR_CFG_DOT11_MODE_11G:
11316 nwType = eSIR_11G_NW_TYPE;
11317 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011318 case eCSR_CFG_DOT11_MODE_11B:
11319 nwType = eSIR_11B_NW_TYPE;
11320 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011321 case eCSR_CFG_DOT11_MODE_11A:
11322 nwType = eSIR_11A_NW_TYPE;
11323 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011324 default:
11325 case eCSR_CFG_DOT11_MODE_11N:
11326 case eCSR_CFG_DOT11_MODE_TAURUS:
11327 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11328 if(eCSR_BAND_24 == eBand)
11329 {
11330 nwType = eSIR_11G_NW_TYPE;
11331 }
11332 else
11333 {
11334 nwType = eSIR_11A_NW_TYPE;
11335 }
11336 break;
11337 }
11338
11339 pParam->extendedRateSet.numRates = 0;
11340
11341 switch ( nwType )
11342 {
11343 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011344 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011345 case eSIR_11A_NW_TYPE:
11346
11347 pParam->operationalRateSet.numRates = 8;
11348
11349 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11350 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11351 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11352 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11353 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11354 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11355 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11356 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11357
11358 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11359 {
11360 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11361 if( 0 == channel &&
11362 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11363 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11364 )
11365 {
11366 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11367 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11368 nwType = eSIR_11B_NW_TYPE;
11369 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11370 pParam->operationalRateSet.numRates = 4;
11371 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11372 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11373 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11374 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11375 }
11376 }
11377 else
11378 {
11379 channel = operationChannel;
11380 }
11381 break;
11382
11383 case eSIR_11B_NW_TYPE:
11384 pParam->operationalRateSet.numRates = 4;
11385 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11386 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11387 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11388 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011389 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11390 {
11391 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11392 }
11393 else
11394 {
11395 channel = operationChannel;
11396 }
11397
11398 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011399 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011400 /* For P2P Client and P2P GO, disable 11b rates */
11401 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11402 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11403 )
11404 {
11405 pParam->operationalRateSet.numRates = 8;
11406
11407 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11408 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11409 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11410 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11411 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11412 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11413 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11414 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11415 }
11416 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011417 {
11418 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011419 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11420 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11421 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11422 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11423
11424 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011425 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11426 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11427 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11428 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11429 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11430 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11431 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11432 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11433 }
11434
11435 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11436 {
11437 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11438 }
11439 else
11440 {
11441 channel = operationChannel;
11442 }
11443
11444 break;
11445 }
11446 pParam->operationChn = channel;
11447 pParam->sirNwType = nwType;
11448}
11449
Jeff Johnson295189b2012-06-20 16:38:30 -070011450static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11451 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11452{
11453
11454 if( pParam )
11455 {
11456 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011457 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011458 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011459 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011460
11461 if( pIes )
11462 {
11463 if(pIes->SuppRates.present)
11464 {
11465 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11466 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11467 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011468 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 -070011469 pIes->SuppRates.num_rates);
11470 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11471 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011472 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11473 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011474 }
11475 if( pIes->SSID.present )
11476 {
11477 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011478 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11479 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011480 }
11481 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011482 }
11483 else
11484 {
11485 pParam->ssId.length = 0;
11486 pParam->operationalRateSet.numRates = 0;
11487 }
11488 }
11489}
11490
Jeff Johnson295189b2012-06-20 16:38:30 -070011491static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11492{
11493 tANI_U8 MaxRate = 0;
11494 tANI_U32 i;
11495 tANI_U8 *pRate;
11496
11497 pRate = pSirRateSet->rate;
11498 for ( i = 0; i < pSirRateSet->numRates; i++ )
11499 {
11500 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11501 }
11502
11503 // Save the max rate in the connected state information...
11504
11505 // modify LastRates variable as well
11506
11507 return;
11508}
11509
Jeff Johnson295189b2012-06-20 16:38:30 -070011510eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11511 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11512{
11513 eHalStatus status = eHAL_STATUS_SUCCESS;
11514 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011515 // Set the roaming substate to 'Start BSS attempt'...
11516 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011517#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11518 //Need to figure out whether we need to log WDS???
11519 if( CSR_IS_IBSS( pProfile ) )
11520 {
11521 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011522 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11523 if(pIbssLog)
11524 {
11525 if(pBssDesc)
11526 {
11527 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011528 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011529 }
11530 else
11531 {
11532 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11533 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011534 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011535 if(pProfile->ChannelInfo.numOfChannels == 0)
11536 {
11537 pIbssLog->channelSetting = AUTO_PICK;
11538 }
11539 else
11540 {
11541 pIbssLog->channelSetting = SPECIFIED;
11542 }
11543 pIbssLog->operatingChannel = pParam->operationChn;
11544 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11545 }
11546 }
11547#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11548 //Put RSN information in for Starting BSS
11549 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11550 pParam->pRSNIE = pProfile->pRSNReqIE;
11551
Jeff Johnson295189b2012-06-20 16:38:30 -070011552 pParam->privacy = pProfile->privacy;
11553 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11554 pParam->authType = pProfile->csr80211AuthType;
11555 pParam->beaconInterval = pProfile->beaconInterval;
11556 pParam->dtimPeriod = pProfile->dtimPeriod;
11557 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11558 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11559 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11560 {
11561 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11562 {
11563 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11564 }
11565 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011566 pParam->protEnabled = pProfile->protEnabled;
11567 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11568 pParam->ht_protection = pProfile->cfg_protection;
11569 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011570
Jeff Johnson295189b2012-06-20 16:38:30 -070011571 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11572 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011573 pParam->bssPersona = pProfile->csrPersona;
11574 // When starting an IBSS, start on the channel from the Profile.
11575 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011576 return (status);
11577}
11578
Jeff Johnson295189b2012-06-20 16:38:30 -070011579static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011580 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011581{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011582 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011583 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011584 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011585
11586 if(!pSession)
11587 {
11588 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11589 return;
11590 }
11591
Jeff Johnson295189b2012-06-20 16:38:30 -070011592 if( pBssDesc )
11593 {
11594 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11595 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11596 //The following code has to be do after that.
11597 //For WDS station, use selfMac as the self BSSID
11598 if( CSR_IS_WDS_STA( pProfile ) )
11599 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011600 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11601 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011602 }
11603 }
11604 else
11605 {
11606 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011607 //Use the first SSID
11608 if(pProfile->SSIDs.numOfSSIDs)
11609 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011610 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11611 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011612 }
11613 //For WDS station, use selfMac as the self BSSID
11614 if( CSR_IS_WDS_STA( pProfile ) )
11615 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011616 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11617 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011618 }
11619 //Use the first BSSID
11620 else if( pProfile->BSSIDs.numOfBSSIDs )
11621 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011622 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11623 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011624 }
11625 else
11626 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011627 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011628 }
11629 }
11630 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011631 //Set operating channel in pProfile which will be used
11632 //in csrRoamSetBssConfigCfg() to determine channel bonding
11633 //mode and will be configured in CFG later
11634 pProfile->operationChannel = Channel;
11635
11636 if(Channel == 0)
11637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011638 smsLog(pMac, LOGW, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011639 }
11640 else
11641 {
11642
11643 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011644 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011645 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011646 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011647 {
11648 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11649 }
11650 else
11651 {
11652 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11653 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011654 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011655 pBssConfig->cbMode = cbMode;
11656 pSession->bssParams.cbMode = cbMode;
11657 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011658 }
11659}
11660
Jeff Johnson295189b2012-06-20 16:38:30 -070011661static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11662 tANI_BOOLEAN *pfSameIbss )
11663{
11664 eHalStatus status = eHAL_STATUS_SUCCESS;
11665 tANI_BOOLEAN fSameIbss = FALSE;
11666
11667 if ( csrIsConnStateIbss( pMac, sessionId ) )
11668 {
11669 // Check if any profile parameter has changed ? If any profile parameter
11670 // has changed then stop old BSS and start a new one with new parameters
11671 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11672 {
11673 fSameIbss = TRUE;
11674 }
11675 else
11676 {
11677 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11678 }
11679 }
11680 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11681 {
11682 // Disassociate from the connected Infrastructure network...
11683 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11684 }
11685 else
11686 {
11687 tBssConfigParam *pBssConfig;
11688
Kiet Lam64c1b492013-07-12 13:56:44 +053011689 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11690 if ( NULL == pBssConfig )
11691 status = eHAL_STATUS_FAILURE;
11692 else
11693 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011694 if(HAL_STATUS_SUCCESS(status))
11695 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011696 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011697 // there is no Bss description before we start an IBSS so we need to adopt
11698 // all Bss configuration parameters from the Profile.
11699 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11700 if(HAL_STATUS_SUCCESS(status))
11701 {
11702 //save dotMode
11703 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11704 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011705 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011706 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11707 NULL, pBssConfig,
11708 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011709 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011710
11711 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011712 }//Allocate memory
11713 }
11714
11715 if(pfSameIbss)
11716 {
11717 *pfSameIbss = fSameIbss;
11718 }
11719 return( status );
11720}
11721
Jeff Johnson295189b2012-06-20 16:38:30 -070011722static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11723 tSirSmeNewBssInfo *pNewBss )
11724{
11725 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011726
11727 if(!pSession)
11728 {
11729 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11730 return;
11731 }
11732
Jeff Johnson295189b2012-06-20 16:38:30 -070011733 if( pNewBss )
11734 {
11735 // Set the operating channel.
11736 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11737 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011738 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11739 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011740 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011741 return;
11742}
11743
Jeff Johnson295189b2012-06-20 16:38:30 -070011744#ifdef FEATURE_WLAN_WAPI
11745eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11746 tANI_U32 numItems )
11747{
11748 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11749 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011750 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11751 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011752 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011753 return status;
11754 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011755 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011756 pSession = CSR_GET_SESSION( pMac, sessionId );
11757 if(numItems <= CSR_MAX_BKID_ALLOWED)
11758 {
11759 status = eHAL_STATUS_SUCCESS;
11760 //numItems may be 0 to clear the cache
11761 pSession->NumBkidCache = (tANI_U16)numItems;
11762 if(numItems && pBKIDCache)
11763 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011764 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
11765 sizeof(tBkidCacheInfo) * numItems);
11766 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011767 }
11768 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011769 return (status);
11770}
Jeff Johnson295189b2012-06-20 16:38:30 -070011771eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11772 tBkidCacheInfo *pBkidCache)
11773{
11774 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11775 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011776 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11777 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011778 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011779 return status;
11780 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011781 pSession = CSR_GET_SESSION( pMac, sessionId );
11782 if(pNum && pBkidCache)
11783 {
11784 if(pSession->NumBkidCache == 0)
11785 {
11786 *pNum = 0;
11787 status = eHAL_STATUS_SUCCESS;
11788 }
11789 else if(*pNum >= pSession->NumBkidCache)
11790 {
11791 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11792 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011793 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 -070011794 pSession->NumBkidCache);
11795 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11796 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011797 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
11798 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011799 *pNum = pSession->NumBkidCache;
11800 status = eHAL_STATUS_SUCCESS;
11801 }
11802 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011803 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011804}
Jeff Johnson295189b2012-06-20 16:38:30 -070011805tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11806{
11807 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011808}
11809#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011810eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11811 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11812{
11813 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11814 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011815
11816 if(!pSession)
11817 {
11818 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11819 return eHAL_STATUS_FAILURE;
11820 }
11821
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011822 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011823 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11824 {
11825#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11826 {
11827 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053011828 vos_mem_set(&secEvent,
11829 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011830 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11831 secEvent.encryptionModeMulticast =
11832 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11833 secEvent.encryptionModeUnicast =
11834 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053011835 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011836 secEvent.authMode =
11837 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11838 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11839 }
11840#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011841 status = eHAL_STATUS_SUCCESS;
11842 //numItems may be 0 to clear the cache
11843 pSession->NumPmkidCache = (tANI_U16)numItems;
11844 if(numItems && pPMKIDCache)
11845 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011846 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
11847 sizeof(tPmkidCacheInfo) * numItems);
11848 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011849 }
11850 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011851 return (status);
11852}
11853
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011854eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11855 tANI_U8 *pBSSId )
11856{
11857 eHalStatus status = eHAL_STATUS_FAILURE;
11858 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11859 tANI_BOOLEAN fMatchFound = FALSE;
11860 tANI_U32 Index;
11861 if(!pSession)
11862 {
11863 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11864 return eHAL_STATUS_FAILURE;
11865 }
11866 do
11867 {
11868 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
11869 {
11870 smsLog(pMac, LOGW, "Delete PMKID for %02X-%02X-%02X-%02X-%02X-%02X ",
11871 pBSSId[0], pBSSId[1], pBSSId[2], pBSSId[3], pBSSId[4], pBSSId[5]);
11872 if( palEqualMemory( pMac->hHdd, pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
11873 {
11874 fMatchFound = TRUE;
11875 break;
11876 }
11877 }
11878 if( !fMatchFound ) break;
11879 palZeroMemory( pMac->hHdd, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tPmkidCacheInfo));
11880 status = eHAL_STATUS_SUCCESS;
11881 }
11882 while( 0 );
11883 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
11884 fMatchFound, status);
11885 return status;
11886}
Jeff Johnson295189b2012-06-20 16:38:30 -070011887tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11888{
11889 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
11890}
11891
Jeff Johnson295189b2012-06-20 16:38:30 -070011892eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
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
Jeff Johnson295189b2012-06-20 16:38:30 -070011903 if(pNum && pPmkidCache)
11904 {
11905 if(pSession->NumPmkidCache == 0)
11906 {
11907 *pNum = 0;
11908 status = eHAL_STATUS_SUCCESS;
11909 }
11910 else if(*pNum >= pSession->NumPmkidCache)
11911 {
11912 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
11913 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011914 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 -070011915 pSession->NumPmkidCache);
11916 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
11917 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011918 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
11919 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011920 *pNum = pSession->NumPmkidCache;
11921 status = eHAL_STATUS_SUCCESS;
11922 }
11923 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011924 return (status);
11925}
11926
Jeff Johnson295189b2012-06-20 16:38:30 -070011927eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11928{
11929 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11930 tANI_U32 len;
11931 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011932
11933 if(!pSession)
11934 {
11935 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11936 return eHAL_STATUS_FAILURE;
11937 }
11938
Jeff Johnson295189b2012-06-20 16:38:30 -070011939 if(pLen)
11940 {
11941 len = *pLen;
11942 *pLen = pSession->nWpaRsnReqIeLength;
11943 if(pBuf)
11944 {
11945 if(len >= pSession->nWpaRsnReqIeLength)
11946 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011947 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
11948 pSession->nWpaRsnReqIeLength);
11949 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011950 }
11951 }
11952 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011953 return (status);
11954}
11955
Jeff Johnson295189b2012-06-20 16:38:30 -070011956eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11957{
11958 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11959 tANI_U32 len;
11960 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011961
11962 if(!pSession)
11963 {
11964 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11965 return eHAL_STATUS_FAILURE;
11966 }
11967
Jeff Johnson295189b2012-06-20 16:38:30 -070011968 if(pLen)
11969 {
11970 len = *pLen;
11971 *pLen = pSession->nWpaRsnRspIeLength;
11972 if(pBuf)
11973 {
11974 if(len >= pSession->nWpaRsnRspIeLength)
11975 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011976 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
11977 pSession->nWpaRsnRspIeLength);
11978 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011979 }
11980 }
11981 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011982 return (status);
11983}
Jeff Johnson295189b2012-06-20 16:38:30 -070011984#ifdef FEATURE_WLAN_WAPI
11985eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
11986{
11987 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11988 tANI_U32 len;
11989 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011990
11991 if(!pSession)
11992 {
11993 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11994 return eHAL_STATUS_FAILURE;
11995 }
11996
Jeff Johnson295189b2012-06-20 16:38:30 -070011997 if(pLen)
11998 {
11999 len = *pLen;
12000 *pLen = pSession->nWapiReqIeLength;
12001 if(pBuf)
12002 {
12003 if(len >= pSession->nWapiReqIeLength)
12004 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012005 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12006 pSession->nWapiReqIeLength);
12007 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012008 }
12009 }
12010 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012011 return (status);
12012}
Jeff Johnson295189b2012-06-20 16:38:30 -070012013eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12014{
12015 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12016 tANI_U32 len;
12017 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012018
12019 if(!pSession)
12020 {
12021 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12022 return eHAL_STATUS_FAILURE;
12023 }
12024
Jeff Johnson295189b2012-06-20 16:38:30 -070012025 if(pLen)
12026 {
12027 len = *pLen;
12028 *pLen = pSession->nWapiRspIeLength;
12029 if(pBuf)
12030 {
12031 if(len >= pSession->nWapiRspIeLength)
12032 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012033 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12034 pSession->nWapiRspIeLength);
12035 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012036 }
12037 }
12038 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012039 return (status);
12040}
12041#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012042eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12043{
12044 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12045 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012046
12047 if(!pSession)
12048 {
12049 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12050 return (retStatus);
12051 }
12052
Jeff Johnson295189b2012-06-20 16:38:30 -070012053 if(CSR_IS_ROAMING(pSession))
12054 {
12055 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12056 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12057 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012058 return (retStatus);
12059}
12060
Jeff Johnson295189b2012-06-20 16:38:30 -070012061//This function remove the connected BSS from te cached scan result
12062eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12063 tCsrRoamConnectedProfile *pConnProfile)
12064{
12065 eHalStatus status = eHAL_STATUS_FAILURE;
12066 tCsrScanResultFilter *pScanFilter = NULL;
12067 tListElem *pEntry;
12068 tCsrScanResult *pResult;
12069 tDot11fBeaconIEs *pIes;
12070 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012071 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12072 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12073 {
12074 do
12075 {
12076 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012077 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12078 if ( NULL == pScanFilter )
12079 status = eHAL_STATUS_FAILURE;
12080 else
12081 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012082 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012083 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12084 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12085 if ( NULL == pScanFilter->BSSIDs.bssid )
12086 status = eHAL_STATUS_FAILURE;
12087 else
12088 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012089 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012090 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12091 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012092 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12093 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12094 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012095 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12096 if ( NULL == pScanFilter->SSIDs.SSIDList )
12097 status = eHAL_STATUS_FAILURE;
12098 else
12099 status = eHAL_STATUS_SUCCESS;
12100 if (!HAL_STATUS_SUCCESS(status)) break;
12101 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12102 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012103 }
12104 pScanFilter->authType.numEntries = 1;
12105 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12106 pScanFilter->BSSType = pConnProfile->BSSType;
12107 pScanFilter->EncryptionType.numEntries = 1;
12108 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12109 pScanFilter->mcEncryptionType.numEntries = 1;
12110 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12111 //We ignore the channel for now, BSSID should be enough
12112 pScanFilter->ChannelInfo.numOfChannels = 0;
12113 //Also ignore the following fields
12114 pScanFilter->uapsd_mask = 0;
12115 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
12116 pScanFilter->countryCode[0] = 0;
12117 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012118 csrLLLock(&pMac->scan.scanResultList);
12119 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12120 while( pEntry )
12121 {
12122 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12123 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12124 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12125 pScanFilter, NULL, NULL, NULL, &pIes);
12126 //Release the IEs allocated by csrMatchBSS is needed
12127 if( !pResult->Result.pvIes )
12128 {
12129 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012130 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012131 }
12132 if(fMatch)
12133 {
12134 //We found the one
12135 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12136 {
12137 //Free the memory
12138 csrFreeScanResultEntry( pMac, pResult );
12139 }
12140 break;
12141 }
12142 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12143 }//while
12144 csrLLUnlock(&pMac->scan.scanResultList);
12145 }while(0);
12146 if(pScanFilter)
12147 {
12148 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012149 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012150 }
12151 }
12152 return (status);
12153}
12154
Jeff Johnson295189b2012-06-20 16:38:30 -070012155//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012156eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12157{
12158 eHalStatus status = eHAL_STATUS_SUCCESS;
12159 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012160 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12161 {
12162 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12163 {
12164 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12165 {
12166 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012167 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012168 status = eHAL_STATUS_CSR_WRONG_STATE;
12169 break;
12170 }
12171 if( csrIsConnStateInfra( pMac, sessionId ) )
12172 {
12173 if( chnId &&
12174 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12175 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012176 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012177 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12178 status = eHAL_STATUS_CSR_WRONG_STATE;
12179 break;
12180 }
12181 }
12182 }
12183 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012184 return ( status );
12185}
12186
Jeff Johnson295189b2012-06-20 16:38:30 -070012187static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12188{
12189 eHalStatus status = eHAL_STATUS_SUCCESS;
12190 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12191 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012192
12193 if(!pSession)
12194 {
12195 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12196 return eHAL_STATUS_FAILURE;
12197 }
12198
Jeff Johnson295189b2012-06-20 16:38:30 -070012199 if ( csrIsConnStateIbss( pMac, sessionId ) )
12200 {
12201 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12202 }
12203 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12204 {
12205 // Disassociate from the connected Infrastructure network...
12206 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12207 }
12208 else
12209 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012210 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12211 //Otherwise we need to add code to handle the
12212 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12213 //send stop_bss to PE, before we can continue.
12214 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012215 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012216 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012217 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12218 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012219 // there is no Bss description before we start an WDS so we need
12220 // to adopt all Bss configuration parameters from the Profile.
12221 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12222 if(HAL_STATUS_SUCCESS(status))
12223 {
12224 //Save profile for late use
12225 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012226 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12227 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012228 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012229 vos_mem_set(pSession->pCurRoamProfile,
12230 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012231 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12232 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012233 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012234 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012235 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12236 NULL, &bssConfig,
12237 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012238 }
12239 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012240
Jeff Johnson295189b2012-06-20 16:38:30 -070012241 return( status );
12242}
12243
Jeff Johnson295189b2012-06-20 16:38:30 -070012244////////////////////Mail box
12245
Jeff Johnson295189b2012-06-20 16:38:30 -070012246//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12247//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012248static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12249 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012250 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12251{
12252 tCsrChannelSet channelGroup;
12253 tSirMacCapabilityInfo *pAP_capabilityInfo;
12254 tAniBool fTmp;
12255 tANI_BOOLEAN found = FALSE;
12256 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012257 tANI_S8 pwrLimit = 0;
12258 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012259 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12260 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12261 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12262 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012263 // 802.11h
12264 //We can do this because it is in HOST CPU order for now.
12265 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012266 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12267 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12268 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012269 fTmp = (tAniBool)pal_cpu_to_be32(1);
12270 }
12271 else
12272 fTmp = (tAniBool)0;
12273
12274 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012275 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012276 pBuf += sizeof(tAniBool);
12277 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012278 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012279 // This is required for 11k test VoWiFi Ent: Test 2.
12280 // We need the power capabilities for Assoc Req.
12281 // This macro is provided by the halPhyCfg.h. We pick our
12282 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012283 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12284 if (0 != pwrLimit)
12285 {
12286 *pBuf++ = pwrLimit;
12287 }
12288 else
12289 {
12290 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12291 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012292 size = sizeof(pMac->roam.validChannelList);
12293 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12294 {
12295 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12296 for ( i = 0; i < size; i++)
12297 {
12298 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12299
12300 }
12301 }
12302 else
12303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012304 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012305 *pBuf++ = 0; //tSirSupChnl->numChnl
12306 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012307 //Check whether it is ok to enter UAPSD
12308#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12309 if( btcIsReadyForUapsd(pMac) )
12310#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12311 {
12312 *pBuf++ = uapsdMask;
12313 }
12314#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12315 else
12316 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012317 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012318 *pBuf++ = 0;
12319 }
12320#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12321
Jeff Johnson295189b2012-06-20 16:38:30 -070012322 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012323 vos_mem_copy(pBuf, pBssDescription,
12324 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012325 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12326}
12327
Jeff Johnson295189b2012-06-20 16:38:30 -070012328/*
12329 * The communication between HDD and LIM is thru mailbox (MB).
12330 * Both sides will access the data structure "tSirSmeJoinReq".
12331 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12332 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12333 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12334 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12335 */
12336eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012337 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012338{
12339 eHalStatus status = eHAL_STATUS_SUCCESS;
12340 tSirSmeJoinReq *pMsg;
12341 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012342 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012343 tANI_U16 msgLen, wTmp, ieLen;
12344 tSirMacRateSet OpRateSet;
12345 tSirMacRateSet ExRateSet;
12346 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12347 tANI_U32 dwTmp;
12348 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012349 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012350
12351 if(!pSession)
12352 {
12353 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12354 return eHAL_STATUS_FAILURE;
12355 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012356 /* To satisfy klockworks */
12357 if (NULL == pBssDescription)
12358 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012359 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012360 return eHAL_STATUS_FAILURE;
12361 }
12362
Jeff Johnson295189b2012-06-20 16:38:30 -070012363 do {
12364 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12365 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012366 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012367 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12368 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12369 // IE fields, but the length field in the bssDescription needs to be interpreted to
12370 // determine length of the IE fields.
12371 //
12372 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12373 // add in the length from the bssDescription (then add the size of the 'length' field
12374 // itself because that is NOT included in the length field).
12375 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12376 pBssDescription->length + sizeof( pBssDescription->length ) +
12377 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 +053012378 pMsg = vos_mem_malloc(msgLen);
12379 if (NULL == pMsg)
12380 status = eHAL_STATUS_FAILURE;
12381 else
12382 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012383 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012384 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012385 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012386 pMsg->length = pal_cpu_to_be16(msgLen);
12387 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012388 // sessionId
12389 *pBuf = (tANI_U8)sessionId;
12390 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012391 // transactionId
12392 *pBuf = 0;
12393 *( pBuf + 1 ) = 0;
12394 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012395 // ssId
12396 if( pIes->SSID.present && pIes->SSID.num_ssid )
12397 {
12398 // ssId len
12399 *pBuf = pIes->SSID.num_ssid;
12400 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012401 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012402 pBuf += pIes->SSID.num_ssid;
12403 }
12404 else
12405 {
12406 *pBuf = 0;
12407 pBuf++;
12408 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012409 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012410 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12411 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012412 pBuf += sizeof(tSirMacAddr);
12413 // bsstype
12414 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12415 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012416 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012417 pBuf += sizeof(tSirBssType);
12418 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012419 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12420 if (pBssDescription->channelId <= 14 &&
12421 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12422 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12423 {
12424 //Need to disable VHT operation in 2.4 GHz band
12425 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12426 }
12427 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012428 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012429 //Persona
12430 *pBuf = (tANI_U8)pProfile->csrPersona;
12431 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012432 //CBMode
12433 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12434 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012435
12436 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012437 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12438
Jeff Johnson295189b2012-06-20 16:38:30 -070012439 // uapsdPerAcBitmask
12440 *pBuf = pProfile->uapsd_mask;
12441 pBuf++;
12442
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012443
12444
Jeff Johnson295189b2012-06-20 16:38:30 -070012445 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012446 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012447 {
12448 // OperationalRateSet
12449 if (OpRateSet.numRates) {
12450 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012451 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012452 pBuf += OpRateSet.numRates;
12453 } else *pBuf++ = 0;
12454 // ExtendedRateSet
12455 if (ExRateSet.numRates) {
12456 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012457 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012458 pBuf += ExRateSet.numRates;
12459 } else *pBuf++ = 0;
12460 }
12461 else
12462 {
12463 *pBuf++ = 0;
12464 *pBuf++ = 0;
12465 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012466 // rsnIE
12467 if ( csrIsProfileWpa( pProfile ) )
12468 {
12469 // Insert the Wpa IE into the join request
12470 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12471 (tCsrWpaIe *)( wpaRsnIE ) );
12472 }
12473 else if( csrIsProfileRSN( pProfile ) )
12474 {
12475 // Insert the RSN IE into the join request
12476 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12477 (tCsrRSNIe *)( wpaRsnIE ) );
12478 }
12479#ifdef FEATURE_WLAN_WAPI
12480 else if( csrIsProfileWapi( pProfile ) )
12481 {
12482 // Insert the WAPI IE into the join request
12483 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12484 (tCsrWapiIe *)( wpaRsnIE ) );
12485 }
12486#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012487 else
12488 {
12489 ieLen = 0;
12490 }
12491 //remember the IE for future use
12492 if( ieLen )
12493 {
12494 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12495 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012496 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 -070012497 ieLen = DOT11F_IE_RSN_MAX_LEN;
12498 }
12499#ifdef FEATURE_WLAN_WAPI
12500 if( csrIsProfileWapi( pProfile ) )
12501 {
12502 //Check whether we need to allocate more memory
12503 if(ieLen > pSession->nWapiReqIeLength)
12504 {
12505 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12506 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012507 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012508 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012509 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12510 if (NULL == pSession->pWapiReqIE)
12511 status = eHAL_STATUS_FAILURE;
12512 else
12513 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012514 if(!HAL_STATUS_SUCCESS(status)) break;
12515 }
12516 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012517 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012518 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012519 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012520 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012521 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012522 pBuf += ieLen;
12523 }
12524 else//should be WPA/WPA2 otherwise
12525#endif /* FEATURE_WLAN_WAPI */
12526 {
12527 //Check whether we need to allocate more memory
12528 if(ieLen > pSession->nWpaRsnReqIeLength)
12529 {
12530 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12531 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012532 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012533 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012534 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12535 if (NULL == pSession->pWpaRsnReqIE)
12536 status = eHAL_STATUS_FAILURE;
12537 else
12538 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012539 if(!HAL_STATUS_SUCCESS(status)) break;
12540 }
12541 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012542 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012543 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012544 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012545 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012546 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012547 pBuf += ieLen;
12548 }
12549 }
12550 else
12551 {
12552 //free whatever old info
12553 pSession->nWpaRsnReqIeLength = 0;
12554 if(pSession->pWpaRsnReqIE)
12555 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012556 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012557 pSession->pWpaRsnReqIE = NULL;
12558 }
12559#ifdef FEATURE_WLAN_WAPI
12560 pSession->nWapiReqIeLength = 0;
12561 if(pSession->pWapiReqIE)
12562 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012563 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012564 pSession->pWapiReqIE = NULL;
12565 }
12566#endif /* FEATURE_WLAN_WAPI */
12567 //length is two bytes
12568 *pBuf = 0;
12569 *(pBuf + 1) = 0;
12570 pBuf += 2;
12571 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012572#ifdef FEATURE_WLAN_CCX
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012573 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012575 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012576 //length is two bytes
12577 *pBuf = 0;
12578 *(pBuf + 1) = 0;
12579 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012580 }
12581 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012582 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012583 // cckmIE
12584 if( csrIsProfileCCX( pProfile ) )
12585 {
12586 // Insert the CCKM IE into the join request
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012587#ifdef FEATURE_WLAN_CCX_UPLOAD
12588 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
12589 palCopyMemory(pMac->hHdd, (void *) (wpaRsnIE),
12590 pSession->suppCckmIeInfo.cckmIe, ieLen);
12591#else
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012592 ieLen = csrConstructCcxCckmIe( pMac,
12593 pSession,
12594 pProfile,
12595 pBssDescription,
12596 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012597 pSession->nWpaRsnReqIeLength,
12598 (void *)( wpaRsnIE ) );
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012599#endif /* FEATURE_WLAN_CCX_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012600 }
12601 else
12602 {
12603 ieLen = 0;
12604 }
12605 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12606 if( ieLen )
12607 {
12608 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12609 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012610 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012611 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012612 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012613 pBuf += ieLen;
12614 }
12615 else
12616 {
12617 //Indicate you have no CCKM IE
12618 //length is two bytes
12619 *pBuf = 0;
12620 *(pBuf + 1) = 0;
12621 pBuf += 2;
12622 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012623 }
12624#endif /* FEATURE_WLAN_CCX */
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 // addIEScan
12626 if(pProfile->nAddIEScanLength && pProfile->pAddIEScan)
12627 {
12628 ieLen = pProfile->nAddIEScanLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012629 if(ieLen > pSession->nAddIEScanLength)
12630 {
12631 if(pSession->pAddIEScan && pSession->nAddIEScanLength)
12632 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012633 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070012634 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012635 pSession->pAddIEScan = vos_mem_malloc(ieLen);
12636 if (NULL == pSession->pAddIEScan)
12637 status = eHAL_STATUS_FAILURE;
12638 else
12639 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012640 if(!HAL_STATUS_SUCCESS(status)) break;
12641 }
12642 pSession->nAddIEScanLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012643 vos_mem_copy(pSession->pAddIEScan, pProfile->pAddIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012644 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012645 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012646 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012647 vos_mem_copy(pBuf, pProfile->pAddIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012648 pBuf += ieLen;
12649 }
12650 else
12651 {
12652 pSession->nAddIEScanLength = 0;
12653 if(pSession->pAddIEScan)
12654 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012655 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070012656 pSession->pAddIEScan = NULL;
12657 }
12658 *pBuf = 0;
12659 *(pBuf + 1) = 0;
12660 pBuf += 2;
12661 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012662 // addIEAssoc
12663 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12664 {
12665 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012666 if(ieLen > pSession->nAddIEAssocLength)
12667 {
12668 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012669 {
12670 vos_mem_free(pSession->pAddIEAssoc);
12671 }
12672 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12673 if (NULL == pSession->pAddIEAssoc)
12674 status = eHAL_STATUS_FAILURE;
12675 else
12676 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012677 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012678 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012679 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012680 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012681 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012682 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012683 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012684 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012685 pBuf += ieLen;
12686 }
12687 else
12688 {
12689 pSession->nAddIEAssocLength = 0;
12690 if(pSession->pAddIEAssoc)
12691 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012692 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012693 pSession->pAddIEAssoc = NULL;
12694 }
12695 *pBuf = 0;
12696 *(pBuf + 1) = 0;
12697 pBuf += 2;
12698 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012699
12700 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012701 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012702 //Unmask any AC in reassoc that is ACM-set
12703 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12704 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012705 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012706 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12707 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012708#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012709 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012710#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012711 uapsd_mask &= ~(acm_mask);
12712 }
12713 else
12714 {
12715 uapsd_mask = 0;
12716 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012717 }
12718 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012719
Jeff Johnson295189b2012-06-20 16:38:30 -070012720 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012721 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012722 pBuf += sizeof(tANI_U32);
12723
Jeff Johnson295189b2012-06-20 16:38:30 -070012724 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012725 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012726 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012727#ifdef WLAN_FEATURE_11W
12728 //MgmtEncryption
12729 if (pProfile->MFPEnabled)
12730 {
12731 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12732 }
12733 else
12734 {
12735 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12736 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012737 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012738 pBuf += sizeof(tANI_U32);
12739#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012740#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012741 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012742 if (csrIsProfile11r( pProfile )
12743#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012744 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
12745 (pIes->CCXVersion.present) && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012746#endif
12747 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012748 {
12749 // is11Rconnection;
12750 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012751 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012752 pBuf += sizeof(tAniBool);
12753 }
12754 else
12755 {
12756 // is11Rconnection;
12757 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012758 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012759 pBuf += sizeof(tAniBool);
12760 }
12761#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012762#ifdef FEATURE_WLAN_CCX
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012763
12764 // isCCXFeatureIniEnabled
12765 if (TRUE == pMac->roam.configParam.isCcxIniFeatureEnabled)
12766 {
12767 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012768 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012769 pBuf += sizeof(tAniBool);
12770 }
12771 else
12772 {
12773 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012774 vos_mem_copy(pMac->hHdd, pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012775 pBuf += sizeof(tAniBool);
12776 }
12777
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012778 /* A profile can not be both CCX and 11R. But an 802.11R AP
12779 * may be advertising support for CCX as well. So if we are
12780 * associating Open or explicitly CCX then we will get CCX.
12781 * If we are associating explictly 11R only then we will get
12782 * 11R.
12783 */
12784 if ((csrIsProfileCCX(pProfile) ||
12785 ((pIes->CCXVersion.present)
12786 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012787 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12788 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12789 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012790#ifdef WLAN_FEATURE_11W
12791 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12792#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012793 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012794 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
12795 {
12796 // isCCXconnection;
12797 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012798 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012799 pBuf += sizeof(tAniBool);
12800 }
12801 else
12802 {
12803 //isCCXconnection;
12804 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012805 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012806 pBuf += sizeof(tAniBool);
12807 }
12808
12809 if (eWNI_SME_JOIN_REQ == messageType)
12810 {
12811 tCCXTspecInfo ccxTspec;
12812 // CCX-Tspec IEs in the ASSOC request is presently not supported
12813 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012814 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12815 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012816 pBuf += sizeof(tCCXTspecInfo);
12817 }
12818 else if (eWNI_SME_REASSOC_REQ == messageType)
12819 {
12820 if ((csrIsProfileCCX(pProfile) ||
12821 ((pIes->CCXVersion.present)
12822 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012823 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12824 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12825 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012826#ifdef WLAN_FEATURE_11W
12827 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12828#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012829 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012830 && (pMac->roam.configParam.isCcxIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012831 {
12832 tCCXTspecInfo ccxTspec;
Jeff Johnson295189b2012-06-20 16:38:30 -070012833 // CCX Tspec information
Kiet Lam64c1b492013-07-12 13:56:44 +053012834 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012835 ccxTspec.numTspecs = sme_QosCCxRetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &ccxTspec.tspec[0]);
12836 *pBuf = ccxTspec.numTspecs;
12837 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 // Copy the TSPEC information only if present
12839 if (ccxTspec.numTspecs) {
Kiet Lam64c1b492013-07-12 13:56:44 +053012840 vos_mem_copy(pBuf, (void*)&ccxTspec.tspec[0],
12841 (ccxTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070012842 }
12843 pBuf += sizeof(ccxTspec.tspec);
12844 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012845 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012846 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012847 tCCXTspecInfo ccxTspec;
12848 // CCX-Tspec IEs in the ASSOC request is presently not supported
12849 // so nullify the TSPEC parameters
Kiet Lam64c1b492013-07-12 13:56:44 +053012850 vos_mem_set(&ccxTspec, sizeof(tCCXTspecInfo), 0);
12851 vos_mem_copy(pBuf, &ccxTspec, sizeof(tCCXTspecInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070012852 pBuf += sizeof(tCCXTspecInfo);
12853 }
12854 }
12855#endif // FEATURE_WLAN_CCX
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012856#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012857 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012858 if (pMac->roam.configParam.isFastTransitionEnabled
12859#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012860 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012861#endif
12862 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012863 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012864 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012865 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012866 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012867 }
12868 else
12869 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012870 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012871 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012872 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012873 }
12874#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012875#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012876 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012877 {
12878 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012879 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012880 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012881 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012882 }
12883 else
12884 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012885 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012886 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012887 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070012888 }
12889#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012890
12891 // txLdpcIniFeatureEnabled
12892 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
12893 pBuf++;
12894
Kiran4a17ebe2013-01-31 10:43:43 -080012895 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
12896 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
12897 {
12898 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
12899 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
12900 csrApplyPower2Current(pMac);
12901 }
12902
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012903#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080012904 // txBFIniFeatureEnabled
12905 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
12906 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080012907
12908 // txBFCsnValue
12909 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
12910 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080012911#endif
krunal soni5afa96c2013-09-06 22:19:02 -070012912 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
12913 pBuf++;
12914
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012915 //BssDesc
12916 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
12917 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070012918
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012919 status = palSendMBMessage(pMac->hHdd, pMsg );
12920 if(!HAL_STATUS_SUCCESS(status))
12921 {
12922 break;
12923 }
12924 else
12925 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012926#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012927 if (eWNI_SME_JOIN_REQ == messageType)
12928 {
12929 //Tush-QoS: notify QoS module that join happening
12930 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
12931 }
12932 else if (eWNI_SME_REASSOC_REQ == messageType)
12933 {
12934 //Tush-QoS: notify QoS module that reassoc happening
12935 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
12936 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012937#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012938 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012939 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070012940 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070012941}
12942
Jeff Johnson295189b2012-06-20 16:38:30 -070012943//
12944eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
12945{
12946 eHalStatus status = eHAL_STATUS_SUCCESS;
12947 tSirSmeDisassocReq *pMsg;
12948 tANI_U8 *pBuf;
12949 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070012950 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12951 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
12952 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012953 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053012954 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
12955 if (NULL == pMsg)
12956 status = eHAL_STATUS_FAILURE;
12957 else
12958 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012959 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012960 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012961 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
12962 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012963 pBuf = &pMsg->sessionId;
12964 // sessionId
12965 *pBuf++ = (tANI_U8)sessionId;
12966 // transactionId
12967 *pBuf = 0;
12968 *( pBuf + 1 ) = 0;
12969 pBuf += sizeof(tANI_U16);
12970
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053012971 if ( (pSession->pCurRoamProfile != NULL) &&
12972 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
12973 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012974 {
12975 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012976 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
12977 sizeof( tSirMacAddr ));
12978 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012979 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012980 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012981 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
12982 //perMacAddr is passed as bssId for softAP
12983 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012984 pBuf = pBuf + sizeof ( tSirMacAddr );
12985 }
12986 else
12987 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012988 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053012989 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
12990 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012991 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053012992 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
12993 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012994 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070012995 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012996 if(!HAL_STATUS_SUCCESS(status))
12997 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012998 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070012999 break;
13000 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013001 // reasonCode
13002 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013003 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13004 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013005 if(!HAL_STATUS_SUCCESS(status))
13006 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013007 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013008 break;
13009 }
13010 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013011 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13012 Here we should not send the disassoc over the air to the AP */
13013 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13014#ifdef WLAN_FEATURE_VOWIFI_11R
13015 && csrRoamIs11rAssoc(pMac)
13016#endif
13017 )
13018 {
13019 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13020 }
13021 pBuf += sizeof(tANI_U8);
13022 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013023 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013024 return( status );
13025}
Jeff Johnson295189b2012-06-20 16:38:30 -070013026eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13027{
13028 eHalStatus status = eHAL_STATUS_SUCCESS;
13029 tSirSmeTkipCntrMeasReq *pMsg;
13030 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013031 do
13032 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013033 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13034 if ( NULL == pMsg )
13035 status = eHAL_STATUS_FAILURE;
13036 else
13037 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013038 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013039 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013040 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13041 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013042 pBuf = &pMsg->sessionId;
13043 // sessionId
13044 *pBuf++ = (tANI_U8)sessionId;
13045 // transactionId
13046 *pBuf = 0;
13047 *( pBuf + 1 ) = 0;
13048 pBuf += sizeof(tANI_U16);
13049 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013050 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13051 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013052 pBuf = pBuf + sizeof ( tSirMacAddr );
13053 // bEnable
13054 *pBuf = (tANI_BOOLEAN)bEnable;
13055 if(!HAL_STATUS_SUCCESS(status))
13056 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013057 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013058 break;
13059 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013060 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013061 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013062 return( status );
13063}
Jeff Johnson295189b2012-06-20 16:38:30 -070013064eHalStatus
13065csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13066 VOS_MODULE_ID modId, tSirMacAddr bssId,
13067 void *pUsrContext, void *pfnSapEventCallback,
13068 tANI_U8 *pAssocStasBuf )
13069{
13070 eHalStatus status = eHAL_STATUS_SUCCESS;
13071 tSirSmeGetAssocSTAsReq *pMsg;
13072 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13073 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013074 do
13075 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013076 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13077 if ( NULL == pMsg )
13078 status = eHAL_STATUS_FAILURE;
13079 else
13080 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013081 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013082 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013083 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013084 pBuf = (tANI_U8 *)&pMsg->bssId;
13085 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013086 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013087 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013088 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013089 // modId
13090 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013091 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013092 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013093 // pUsrContext
13094 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013095 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013096 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013097 // pfnSapEventCallback
13098 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013099 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013100 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013101 // pAssocStasBuf
13102 dwTmp = pal_cpu_to_be32((tANI_U32)pAssocStasBuf);
Kiet Lam64c1b492013-07-12 13:56:44 +053013103 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013104 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013105 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013106 status = palSendMBMessage( pMac->hHdd, pMsg );
13107 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013108 return( status );
13109 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013110eHalStatus
13111csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13112 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13113 {
13114 eHalStatus status = eHAL_STATUS_SUCCESS;
13115 tSirSmeGetWPSPBCSessionsReq *pMsg;
13116 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13117 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013118 do
13119 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013120 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13121 if ( NULL == pMsg )
13122 status = eHAL_STATUS_FAILURE;
13123 else
13124 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013125 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013126 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013127 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013128 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013129 VOS_ASSERT(pBuf);
13130
Jeff Johnson295189b2012-06-20 16:38:30 -070013131 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013132 // pUsrContext
13133 dwTmp = pal_cpu_to_be32((tANI_U32)pUsrContext);
Kiet Lam64c1b492013-07-12 13:56:44 +053013134 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013135 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013136 // pSapEventCallback
13137 dwTmp = pal_cpu_to_be32((tANI_U32)pfnSapEventCallback);
Kiet Lam64c1b492013-07-12 13:56:44 +053013138 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013139 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013140 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013141 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013142 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013143 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013144 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013145 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013146 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013147 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013148 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013149 return( status );
13150}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013151
13152eHalStatus
13153csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13154{
13155 tpSirChangeBIParams pMsg;
13156 tANI_U16 len = 0;
13157 eHalStatus status = eHAL_STATUS_SUCCESS;
13158 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13159
13160 if(!pSession)
13161 {
13162 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13163 return eHAL_STATUS_FAILURE;
13164 }
13165
13166 //NO need to update the Beacon Params if update beacon parameter flag is not set
13167 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13168 return eHAL_STATUS_SUCCESS;
13169
13170 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13171
13172 /* Create the message and send to lim */
13173 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013174 pMsg = vos_mem_malloc(len);
13175 if ( NULL == pMsg )
13176 status = eHAL_STATUS_FAILURE;
13177 else
13178 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013179 if(HAL_STATUS_SUCCESS(status))
13180 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013181 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013182 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13183 pMsg->length = len;
13184
13185 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013186 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13187 sizeof(tSirMacAddr));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013188 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= %02x-%02x-%02x-%02x-%02x-%02x "),
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013189 pMsg->bssId[ 0 ], pMsg->bssId[ 1 ], pMsg->bssId[ 2 ],
13190 pMsg->bssId[ 3 ], pMsg->bssId[ 4 ], pMsg->bssId[ 5 ] );
13191 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013192 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013193 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13194 status = palSendMBMessage(pMac->hHdd, pMsg);
13195 }
13196 return status;
13197}
13198
Jeff Johnson295189b2012-06-20 16:38:30 -070013199eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13200{
13201 eHalStatus status = eHAL_STATUS_SUCCESS;
13202 tSirSmeDeauthReq *pMsg;
13203 tANI_U8 *pBuf;
13204 tANI_U16 wTmp;
13205 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13206 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13207 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013208 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013209 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13210 if ( NULL == pMsg )
13211 status = eHAL_STATUS_FAILURE;
13212 else
13213 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013214 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013215 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13217 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13218 //sessionId
13219 pBuf = &pMsg->sessionId;
13220 *pBuf++ = (tANI_U8)sessionId;
13221
13222 //tansactionId
13223 *pBuf = 0;
13224 *(pBuf + 1 ) = 0;
13225 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013226 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013227 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013228 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13229 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013230 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13231 sizeof( pMsg->peerMacAddr ) );
13232 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013233 pBuf = pBuf + sizeof(tSirMacAddr);
13234 }
13235 else
13236 {
13237 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013238 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13239 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013240 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013241 }
13242 if(!HAL_STATUS_SUCCESS(status))
13243 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013244 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 break;
13246 }
13247 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013248 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13249 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013250 pBuf = pBuf + sizeof(tSirMacAddr);
13251 if(!HAL_STATUS_SUCCESS(status))
13252 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013253 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013254 break;
13255 }
13256 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013257 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13258 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013259 if(!HAL_STATUS_SUCCESS(status))
13260 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013261 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013262 break;
13263 }
13264 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013265 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013266 return( status );
13267}
13268
Jeff Johnson295189b2012-06-20 16:38:30 -070013269eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13270{
13271 eHalStatus status = eHAL_STATUS_SUCCESS;
13272 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013273 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013274 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13275 if ( NULL == pMsg )
13276 status = eHAL_STATUS_FAILURE;
13277 else
13278 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013279 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013280 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013281 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13282 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13283 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013284 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13285 sizeof(pMsg->peerMacAddr));
13286 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013287 if(!HAL_STATUS_SUCCESS(status))
13288 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013289 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013290 break;
13291 }
13292//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013293 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13294 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013295 if(!HAL_STATUS_SUCCESS(status))
13296 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013297 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013298 break;
13299 }
13300//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013301 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013302 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013303 return( status );
13304}
13305
Jeff Johnson295189b2012-06-20 16:38:30 -070013306eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13307{
13308 eHalStatus status = eHAL_STATUS_SUCCESS;
13309 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013311 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13312 if ( NULL == pMsg )
13313 status = eHAL_STATUS_FAILURE;
13314 else
13315 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013317 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013318 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13319 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13320 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013321 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13322 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 if(!HAL_STATUS_SUCCESS(status))
13324 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013325 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013326 break;
13327 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013328 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13329 sizeof(pMsg->peerMacAddr));
13330 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013331 if(!HAL_STATUS_SUCCESS(status))
13332 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013333 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013334 break;
13335 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013336 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013337 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 return( status );
13339}
Jeff Johnson295189b2012-06-20 16:38:30 -070013340eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13341{
13342 eHalStatus status = eHAL_STATUS_SUCCESS;
13343 tSirSmeAssocCnf *pMsg;
13344 tANI_U8 *pBuf;
13345 tSirResultCodes statusCode;
13346 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013347 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013348 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13349 if ( NULL == pMsg )
13350 status = eHAL_STATUS_FAILURE;
13351 else
13352 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013353 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013354 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013355 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13356 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013357 pBuf = (tANI_U8 *)&pMsg->statusCode;
13358 if(HAL_STATUS_SUCCESS(Halstatus))
13359 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13360 else
13361 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013362 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013363 pBuf += sizeof(tSirResultCodes);
13364 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013365 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13366 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013367 pBuf += sizeof (tSirMacAddr);
13368 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013369 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13370 sizeof(tSirMacAddr));
13371 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013372 pBuf += sizeof (tSirMacAddr);
13373 // aid
13374 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013375 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013376 pBuf += sizeof (tANI_U16);
13377 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013378 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13379 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013380 pBuf += sizeof (tSirMacAddr);
13381 // alternateChannelId
13382 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013383 status = palSendMBMessage( pMac->hHdd, pMsg );
13384 if(!HAL_STATUS_SUCCESS(status))
13385 {
13386 //pMsg is freed by palSendMBMessage
13387 break;
13388 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013389 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013390 return( status );
13391}
Jeff Johnson295189b2012-06-20 16:38:30 -070013392eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13393 tpSirSmeAssocInd pAssocInd,
13394 eHalStatus Halstatus,
13395 tANI_U8 sessionId)
13396{
13397 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013398 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13399 tANI_U8 *pBuf;
13400 tSirResultCodes statusCode;
13401 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013402 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013403 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13404 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13405 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013406
Jeff Johnson295189b2012-06-20 16:38:30 -070013407 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13408 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13409
13410 pMsg->sessionId = sessionId;
13411
13412 pBuf = (tANI_U8 *)&pMsg->statusCode;
13413 if(HAL_STATUS_SUCCESS(Halstatus))
13414 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13415 else
13416 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013417 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013418 pBuf += sizeof(tSirResultCodes);
13419 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013420 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013421 pBuf += sizeof (tSirMacAddr);
13422 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013423 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13424 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013425 pBuf += sizeof (tSirMacAddr);
13426 // StaId
13427 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013428 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013429 pBuf += sizeof (tANI_U16);
13430 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013431 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013432 pBuf += sizeof (tSirMacAddr);
13433 // alternateChannelId
13434 *pBuf = 11;
13435 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013436 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013437 //Wmm
13438 *pBuf = pAssocInd->wmmEnabledSta;
13439 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013440 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013441 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013442 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013443 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013444 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013445 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013446 //reassocReq
13447 *pBuf = pAssocInd->reassocReq;
13448 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013449 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13450 msgQ.bodyptr = pMsg;
13451 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013452 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013453 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013454 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013455}
Jeff Johnson295189b2012-06-20 16:38:30 -070013456
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013457eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013458 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13459 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13460 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13461 tANI_U8 *pKeyRsc )
13462{
13463 tSirSmeSetContextReq *pMsg;
13464 tANI_U16 msgLen;
13465 eHalStatus status = eHAL_STATUS_FAILURE;
13466 tAniEdType tmpEdType;
13467 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013468 tANI_U8 *pBuf = NULL;
13469 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013470 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013471 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013472 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013473 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13474 // key set. Since we only support upto one key, we always allocate memory for 1 key
13475 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13476 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13477 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13478 ( sizeof( pMsg->keyMaterial.key ) );
13479
Kiet Lam64c1b492013-07-12 13:56:44 +053013480 pMsg = vos_mem_malloc(msgLen);
13481 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13482 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013483 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13484 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013485 //sessionId
13486 pBuf = &pMsg->sessionId;
13487 *pBuf = (tANI_U8)sessionId;
13488 pBuf++;
13489 // transactionId
13490 *pBuf = 0;
13491 *(pBuf + 1) = 0;
13492 pBuf += sizeof(tANI_U16);
13493 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013494 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013495
13496 pBuf += sizeof(tSirMacAddr);
13497
13498 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013499 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13500 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013501
13502 pBuf += sizeof(tSirMacAddr);
13503
13504 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013505 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13506 // in the tSirKeyMaterial keyMaterial; field).
13507 //
13508 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13509 // shorter than this max size. Is LIM interpreting this ok ?
13510 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 -070013511 // set pMsg->keyMaterial.edType
13512 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013513 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013514 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013515 // set the pMsg->keyMaterial.numKeys field
13516 *p = numKeys;
13517 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013518 // set pSirKey->keyId = keyId;
13519 *p = keyId;
13520 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013521 // set pSirKey->unicast = (tANI_U8)fUnicast;
13522 *p = (tANI_U8)fUnicast;
13523 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013524 // set pSirKey->keyDirection = aniKeyDirection;
13525 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013526 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013527 p += sizeof(tAniKeyDirection);
13528 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013529 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013530 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013531 // set pSirKey->paeRole
13532 *p = paeRole; // 0 is Supplicant
13533 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013534 // set pSirKey->keyLength = keyLength;
13535 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013536 if ( keyLength && pKey )
13537 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013538 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013539 if(keyLength == 16)
13540 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013541 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 -070013542 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13543 pKey[5], pKey[6], pKey[7], pKey[8],
13544 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13545 }
13546 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013547 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013548 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013549 return( status );
13550}
13551
Jeff Johnson295189b2012-06-20 16:38:30 -070013552eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13553 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13554{
13555 eHalStatus status;
13556 tSirSmeStartBssReq *pMsg;
13557 tANI_U8 *pBuf = NULL;
13558 tANI_U8 *wTmpBuf = NULL;
13559 tANI_U16 msgLen, wTmp;
13560 tANI_U32 dwTmp;
13561 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013562 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013563 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013564 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013565
13566 if(!pSession)
13567 {
13568 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13569 return eHAL_STATUS_FAILURE;
13570 }
13571
Jeff Johnson295189b2012-06-20 16:38:30 -070013572 do {
13573 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13574 pSession->joinFailStatusCode.reasonCode = 0;
13575 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013576 pMsg = vos_mem_malloc(msgLen);
13577 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13578 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013579 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013580 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013581 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013582 //sessionId
13583 *pBuf = (tANI_U8)sessionId;
13584 pBuf++;
13585 // transactionId
13586 *pBuf = 0;
13587 *(pBuf + 1) = 0;
13588 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013589 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013590 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013591 pBuf += sizeof(tSirMacAddr);
13592 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013593 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013594 pBuf += sizeof(tSirMacAddr);
13595 // beaconInterval
13596 if( pBssDesc && pBssDesc->beaconInterval )
13597 {
13598 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13599 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013600 else if(pParam->beaconInterval)
13601 {
13602 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13603 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013604 else
13605 {
13606 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13607 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013608 if(csrIsconcurrentsessionValid (pMac, sessionId,
13609 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013610 == eHAL_STATUS_SUCCESS )
13611 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013612 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013613 pParam->bssPersona);
13614 //Update the beacon Interval
13615 pParam->beaconInterval = wTmp;
13616 }
13617 else
13618 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013619 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013620 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013621 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013622 return status;
13623 }
13624
Kiet Lam64c1b492013-07-12 13:56:44 +053013625 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013626 pBuf += sizeof(tANI_U16);
13627 // dot11mode
13628 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13629 pBuf += 1;
13630 // bssType
13631 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013632 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013633 pBuf += sizeof(tSirBssType);
13634 // ssId
13635 if( pParam->ssId.length )
13636 {
13637 // ssId len
13638 *pBuf = pParam->ssId.length;
13639 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013640 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013641 pBuf += pParam->ssId.length;
13642 }
13643 else
13644 {
13645 *pBuf = 0;
13646 pBuf++;
13647 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 // set the channel Id
13649 *pBuf = pParam->operationChn;
13650 pBuf++;
13651 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013652 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013653 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013654 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013655
Jeff Johnson295189b2012-06-20 16:38:30 -070013656 // Set privacy
13657 *pBuf = pParam->privacy;
13658 pBuf++;
13659
13660 //Set Uapsd
13661 *pBuf = pParam->ApUapsdEnable;
13662 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013663 //Set SSID hidden
13664 *pBuf = pParam->ssidHidden;
13665 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013666 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13667 pBuf++;
13668
13669 //Ht protection Enable/Disable
13670 *pBuf = (tANI_U8)pParam->protEnabled;
13671 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013672 //Enable Beacons to Receive for OBSS protection Enable/Disable
13673 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13674 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013675 //set cfg related to protection
13676 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013677 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013678 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013679 // Set Auth type
13680 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013681 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013682 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013683 // Set DTIM
13684 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013685 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013686 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 // Set wps_state
13688 *pBuf = pParam->wps_state;
13689 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013690 //Persona
13691 *pBuf = (tANI_U8)pParam->bssPersona;
13692 pBuf++;
13693
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013694 //txLdpcIniFeatureEnabled
13695 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13696 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013697
krunal soni4f087d22013-07-29 16:32:26 -070013698 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013699 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13700 {
13701 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013702 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013703 break;
13704 }
13705 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013706 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013707 pBuf += sizeof(tANI_U16);
13708 if( wTmp )
13709 {
13710 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013711 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013712 pBuf += wTmp;
13713 }
13714 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013715 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013716 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013717 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13718 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013719 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13720 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013721 pBuf += pParam->operationalRateSet.numRates ;
13722 *pBuf++ = pParam->extendedRateSet.numRates;
13723 if(0 != pParam->extendedRateSet.numRates)
13724 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013725 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13726 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013727 pBuf += pParam->extendedRateSet.numRates;
13728 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013729 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13730 pMsg->length = pal_cpu_to_be16(msgLen);
13731
13732 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013733 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013734 return( status );
13735}
13736
Jeff Johnson295189b2012-06-20 16:38:30 -070013737eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13738{
13739 eHalStatus status = eHAL_STATUS_FAILURE;
13740 tSirSmeStopBssReq *pMsg;
13741 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13742 tANI_U8 *pBuf;
13743 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013744
13745 if(!pSession)
13746 {
13747 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13748 return eHAL_STATUS_FAILURE;
13749 }
13750
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013752 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13753 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13754 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013755 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13756 pBuf = &pMsg->sessionId;
13757 //sessionId
13758 *pBuf = (tANI_U8)sessionId;
13759 pBuf++;
13760 // transactionId
13761 *pBuf = 0;
13762 pBuf += sizeof(tANI_U16);
13763 //reason code
13764 *pBuf = 0;
13765 pBuf += sizeof(tSirResultCodes);
13766 // bssid
13767 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13768 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13769 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013770 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
13771 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 }
13773 else
13774 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013775 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13776 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013777 }
13778 pBuf += sizeof(tSirMacAddr);
13779 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13780 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013781 status = palSendMBMessage( pMac->hHdd, pMsg );
13782#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053013783 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13784 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13785 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013786 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13787 pMsg->reasonCode = 0;
13788 // bssid
13789 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13790 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13791 {
13792 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13793 }
13794 else
13795 {
13796 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13797 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013798 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013799 pMsg->transactionId = 0;
13800 pMsg->sessionId = (tANI_U8)sessionId;
13801 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13802 status = palSendMBMessage( pMac->hHdd, pMsg );
13803#endif
13804 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013805 return( status );
13806}
13807
Jeff Johnson295189b2012-06-20 16:38:30 -070013808eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13809 tCsrRoamModifyProfileFields *pModProfileFields,
13810 tANI_U32 *pRoamId, v_BOOL_t fForce)
13811{
Jeff Johnson295189b2012-06-20 16:38:30 -070013812 eHalStatus status = eHAL_STATUS_FAILURE;
13813 tANI_U32 roamId = 0;
13814 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053013816 (fForce || (!vos_mem_compare( &pModProfileFields,
13817 &pSession->connectedProfile.modifyProfileFields,
13818 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013819 {
13820 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13821 if(pRoamId)
13822 {
13823 *pRoamId = roamId;
13824 }
13825
Jeff Johnson295189b2012-06-20 16:38:30 -070013826 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13827 eCsrSmeIssuedReassocToSameAP, roamId,
13828 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013829 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013830 return status;
13831}
Jeff Johnson295189b2012-06-20 16:38:30 -070013832static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13833{
13834 eHalStatus status = eHAL_STATUS_SUCCESS;
13835 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053013836 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013837 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13838 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13839 return (status);
13840}
Jeff Johnson295189b2012-06-20 16:38:30 -070013841eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13842{
13843 eHalStatus status = eHAL_STATUS_SUCCESS;
13844 tListElem *pEntry = NULL;
13845 tSmeCmd *pCommand = NULL;
13846 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013847 do
13848 {
13849 if(pMsg == NULL)
13850 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013851 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013852 status = eHAL_STATUS_FAILURE;
13853 break;
13854 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013855 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
13856 if(pEntry)
13857 {
13858 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
13859 if(eSmeCommandAddStaSession == pCommand->command)
13860 {
13861 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013862 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013863 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070013864 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070013865 //Remove this command out of the active list
13866 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
13867 {
13868 //Now put this command back on the avilable command list
13869 csrReleaseCommand(pMac, pCommand);
13870 }
13871 smeProcessPendingQueue( pMac );
13872 }
13873 else
13874 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013875 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 -070013876 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013877 status = eHAL_STATUS_FAILURE;
13878 break;
13879 }
13880 }
13881 else
13882 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013883 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 -070013884 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070013885 status = eHAL_STATUS_FAILURE;
13886 break;
13887 }
13888 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013889 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070013890}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013891eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
13892 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070013893{
13894 tSirSmeAddStaSelfReq *pMsg;
13895 tANI_U16 msgLen;
13896 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013897 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013898 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013899 pMsg = vos_mem_malloc(msgLen);
13900 if ( NULL == pMsg ) break;
13901 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013902 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
13903 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013904 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053013905 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013906 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
13907
13908 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
13909
13910 smsLog( pMac, LOG1, FL("selfMac=%02x, %02x, %02x, %02x, %02x, %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -070013911 pMsg->selfMacAddr[0],
13912 pMsg->selfMacAddr[1],
13913 pMsg->selfMacAddr[2],
13914 pMsg->selfMacAddr[3],
13915 pMsg->selfMacAddr[4],
13916 pMsg->selfMacAddr[5]);
13917 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013919 return( status );
13920}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013921eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
13922 tANI_U32 sessionId,
13923 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070013924{
13925 eHalStatus status = eHAL_STATUS_SUCCESS;
13926 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070013927 pCommand = csrGetCommandBuffer(pMac);
13928 if(NULL == pCommand)
13929 {
13930 status = eHAL_STATUS_RESOURCES;
13931 }
13932 else
13933 {
13934 pCommand->command = eSmeCommandAddStaSession;
13935 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053013936 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
13937 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013938 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013939 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
13940 if( !HAL_STATUS_SUCCESS( status ) )
13941 {
13942 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013943 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013944 }
13945 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013946 return (status);
13947}
Jeff Johnson295189b2012-06-20 16:38:30 -070013948eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
13949{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013950 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070013951}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013952eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
13953 csrRoamCompleteCallback callback,
13954 void *pContext, tANI_U8 *pSelfMacAddr,
13955 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070013956{
13957 eHalStatus status = eHAL_STATUS_SUCCESS;
13958 tANI_U32 i;
13959 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070013960 *pbSessionId = CSR_SESSION_ID_INVALID;
13961 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
13962 {
13963 if( !CSR_IS_SESSION_VALID( pMac, i ) )
13964 {
13965 pSession = CSR_GET_SESSION( pMac, i );
13966 status = eHAL_STATUS_SUCCESS;
13967 pSession->sessionActive = eANI_BOOLEAN_TRUE;
13968 pSession->sessionId = (tANI_U8)i;
13969 pSession->callback = callback;
13970 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053013971 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013972 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013973 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
13974 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013975 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013976 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013977 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013978 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013979 break;
13980 }
13981#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013982 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
13983 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070013984 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013985 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070013986 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013987 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 break;
13989 }
13990#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070013991 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013992 break;
13993 }
13994 }
13995 if( CSR_ROAM_SESSION_MAX == i )
13996 {
13997 //No session is available
13998 status = eHAL_STATUS_RESOURCES;
13999 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014000 return ( status );
14001}
Jeff Johnson295189b2012-06-20 16:38:30 -070014002eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14003{
14004 eHalStatus status = eHAL_STATUS_SUCCESS;
14005 tListElem *pEntry = NULL;
14006 tSmeCmd *pCommand = NULL;
14007 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014008 do
14009 {
14010 if(pMsg == NULL)
14011 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014012 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 status = eHAL_STATUS_FAILURE;
14014 break;
14015 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014016 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14017 if(pEntry)
14018 {
14019 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14020 if(eSmeCommandDelStaSession == pCommand->command)
14021 {
14022 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014023 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014024 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014025 //This session is done.
14026 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 if(pCommand->u.delStaSessionCmd.callback)
14028 {
14029
14030 status = sme_ReleaseGlobalLock( &pMac->sme );
14031 if ( HAL_STATUS_SUCCESS( status ) )
14032 {
14033 pCommand->u.delStaSessionCmd.callback(
14034 pCommand->u.delStaSessionCmd.pContext);
14035 status = sme_AcquireGlobalLock( &pMac->sme );
14036 if (! HAL_STATUS_SUCCESS( status ) )
14037 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014038 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014039 return status;
14040 }
14041 }
14042 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014043 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014044 }
14045 }
14046
14047 //Remove this command out of the active list
14048 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14049 {
14050 //Now put this command back on the avilable command list
14051 csrReleaseCommand(pMac, pCommand);
14052 }
14053 smeProcessPendingQueue( pMac );
14054 }
14055 else
14056 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014057 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 -070014058 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014059 status = eHAL_STATUS_FAILURE;
14060 break;
14061 }
14062 }
14063 else
14064 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014065 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 -070014066 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014067 status = eHAL_STATUS_FAILURE;
14068 break;
14069 }
14070 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014071 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014072}
Jeff Johnson295189b2012-06-20 16:38:30 -070014073eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14074{
14075 tSirSmeDelStaSelfReq *pMsg;
14076 tANI_U16 msgLen;
14077 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014078 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014079 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14080 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014081 pMsg = vos_mem_malloc(msgLen);
14082 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14083 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014084 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14085 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014086 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014087 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14088 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014089 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014090 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014091 return( status );
14092}
Jeff Johnson295189b2012-06-20 16:38:30 -070014093eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14094 tSirMacAddr sessionMacAddr,
14095 csrRoamSessionCloseCallback callback,
14096 void *pContext)
14097{
14098 eHalStatus status = eHAL_STATUS_SUCCESS;
14099 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 pCommand = csrGetCommandBuffer(pMac);
14101 if(NULL == pCommand)
14102 {
14103 status = eHAL_STATUS_RESOURCES;
14104 }
14105 else
14106 {
14107 pCommand->command = eSmeCommandDelStaSession;
14108 pCommand->sessionId = (tANI_U8)sessionId;
14109 pCommand->u.delStaSessionCmd.callback = callback;
14110 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014111 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14112 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014113 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14114 if( !HAL_STATUS_SUCCESS( status ) )
14115 {
14116 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014117 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014118 }
14119 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014120 return (status);
14121}
Jeff Johnson295189b2012-06-20 16:38:30 -070014122eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14123{
14124 return csrSendMBDelSelfStaReqMsg( pMac,
14125 pCommand->u.delStaSessionCmd.selfMacAddr );
14126}
Jeff Johnson295189b2012-06-20 16:38:30 -070014127static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14128{
14129 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14130 tListElem *pEntry, *pNext;
14131 tSmeCmd *pCommand;
14132 tDblLinkList localList;
14133
14134 vos_mem_zero(&localList, sizeof(tDblLinkList));
14135 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14136 {
14137 smsLog(pMac, LOGE, FL(" failed to open list"));
14138 return;
14139 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014140 csrLLLock(pList);
14141 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14142 while(pEntry != NULL)
14143 {
14144 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14145 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14146 if(pCommand->sessionId == sessionId)
14147 {
14148 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14149 {
14150 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14151 }
14152 }
14153 pEntry = pNext;
14154 }
14155 csrLLUnlock(pList);
14156
14157 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14158 {
14159 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14160 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14161 }
14162 csrLLClose(&localList);
14163}
14164
Jeff Johnson295189b2012-06-20 16:38:30 -070014165void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14166{
14167 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14168 {
14169 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014170 csrRoamStop(pMac, sessionId);
14171 csrFreeConnectBssDesc(pMac, sessionId);
14172 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14173 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014174 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014175#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014176 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014177#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014178 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14179 if (pMac->fScanOffload)
14180 {
14181 purgeSmeSessionCmdList(pMac, sessionId,
14182 &pMac->sme.smeScanCmdPendingList);
14183 }
14184
Jeff Johnson295189b2012-06-20 16:38:30 -070014185 purgeCsrSessionCmdList(pMac, sessionId);
14186 csrInitSession(pMac, sessionId);
14187 }
14188}
14189
Jeff Johnson295189b2012-06-20 16:38:30 -070014190eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14191 tANI_BOOLEAN fSync,
14192 csrRoamSessionCloseCallback callback,
14193 void *pContext )
14194{
14195 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014196 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14197 {
14198 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14199 if(fSync)
14200 {
14201 csrCleanupSession(pMac, sessionId);
14202 }
14203 else
14204 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014205 purgeSmeSessionCmdList(pMac, sessionId,
14206 &pMac->sme.smeCmdPendingList);
14207 if (pMac->fScanOffload)
14208 {
14209 purgeSmeSessionCmdList(pMac, sessionId,
14210 &pMac->sme.smeScanCmdPendingList);
14211 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014212 purgeCsrSessionCmdList(pMac, sessionId);
14213 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14214 pSession->selfMacAddr, callback, pContext);
14215 }
14216 }
14217 else
14218 {
14219 status = eHAL_STATUS_INVALID_PARAMETER;
14220 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014221 return ( status );
14222}
14223
Jeff Johnson295189b2012-06-20 16:38:30 -070014224static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14225{
14226 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014227
14228 if(!pSession)
14229 {
14230 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14231 return;
14232 }
14233
Jeff Johnson295189b2012-06-20 16:38:30 -070014234 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14235 pSession->sessionId = CSR_SESSION_ID_INVALID;
14236 pSession->callback = NULL;
14237 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014238 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14239 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14240 csrFreeRoamProfile( pMac, sessionId );
14241 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14242 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14243 csrFreeConnectBssDesc(pMac, sessionId);
14244 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014245 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14246 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014247 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014248 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014249 pSession->pWpaRsnReqIE = NULL;
14250 }
14251 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014252 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014253 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014254 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014255 pSession->pWpaRsnRspIE = NULL;
14256 }
14257 pSession->nWpaRsnRspIeLength = 0;
14258#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014259 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014260 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014261 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014262 pSession->pWapiReqIE = NULL;
14263 }
14264 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014265 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014266 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014267 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014268 pSession->pWapiRspIE = NULL;
14269 }
14270 pSession->nWapiRspIeLength = 0;
14271#endif /* FEATURE_WLAN_WAPI */
Kiet Lam64c1b492013-07-12 13:56:44 +053014272 if (pSession->pAddIEScan)
Jeff Johnson295189b2012-06-20 16:38:30 -070014273 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014274 vos_mem_free(pSession->pAddIEScan);
Jeff Johnson295189b2012-06-20 16:38:30 -070014275 pSession->pAddIEScan = NULL;
14276 }
14277 pSession->nAddIEScanLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014278 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014279 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014280 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014281 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014282 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014283 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014284}
14285
Jeff Johnson295189b2012-06-20 16:38:30 -070014286eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14287{
14288 eHalStatus status = eHAL_STATUS_FAILURE;
14289 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014290 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14291 {
14292 if( CSR_IS_SESSION_VALID( pMac, i ) )
14293 {
14294 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14295 {
14296 //Found it
14297 status = eHAL_STATUS_SUCCESS;
14298 *pSessionId = i;
14299 break;
14300 }
14301 }
14302 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014303 return( status );
14304}
14305
Jeff Johnson295189b2012-06-20 16:38:30 -070014306//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14307//session because for IBSS, the bssid changes.
14308static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14309{
14310 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14311 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014312 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14313 {
14314 if( CSR_IS_SESSION_VALID( pMac, i ) )
14315 {
14316 pSession = CSR_GET_SESSION( pMac, i );
14317 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14318 {
14319 //Found it
14320 nRet = i;
14321 break;
14322 }
14323 }
14324 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014325 return (nRet);
14326}
Jeff Johnson295189b2012-06-20 16:38:30 -070014327static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14328{
14329 /* Update the current BSS info in ho control block based on connected
14330 profile info from pmac global structure */
14331
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014332 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= %02x-%02x-%02x-%02x-%02x-%02x",
Jeff Johnson295189b2012-06-20 16:38:30 -070014333 bssid[ 0 ], bssid[ 1 ], bssid[ 2 ],
14334 bssid[ 3 ], bssid[ 4 ], bssid[ 5 ] );
Jeff Johnson295189b2012-06-20 16:38:30 -070014335 /* Check for user misconfig of RSSI trigger threshold */
14336 pMac->roam.configParam.vccRssiThreshold =
14337 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14338 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14339 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014340 /* Check for user misconfig of UL MAC Loss trigger threshold */
14341 pMac->roam.configParam.vccUlMacLossThreshold =
14342 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14343 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014344#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14345 {
14346 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014347 /* Indicate the neighbor roal algorithm about the connect indication */
14348 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14349 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14350 }
14351#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014352}
14353
Jeff Johnson295189b2012-06-20 16:38:30 -070014354static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14355{
14356 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014357
14358 if(!pSession)
14359 {
14360 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14361 return;
14362 }
14363
Jeff Johnson295189b2012-06-20 16:38:30 -070014364 //Only to handle the case for Handover on infra link
14365 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14366 {
14367 return;
14368 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014369 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14370 csrRoamDeregStatisticsReq(pMac);
14371 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14372#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14373 /* Indicate the neighbor roal algorithm about the disconnect indication */
14374 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14375#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014376
14377 //Remove this code once SLM_Sessionization is supported
14378 //BMPS_WORKAROUND_NOT_NEEDED
14379 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014380 csrIsInfraApStarted( pMac ) &&
14381 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014382 {
14383 pMac->roam.configParam.doBMPSWorkaround = 0;
14384 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014385}
14386
Jeff Johnson295189b2012-06-20 16:38:30 -070014387void csrRoamTlStatsTimerHandler(void *pv)
14388{
14389 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14390 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014391 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14392
Jeff Johnsone7245742012-09-05 17:12:55 -070014393 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14394
Jeff Johnson295189b2012-06-20 16:38:30 -070014395#if 0
14396 // TODO Persession .???
14397 //req TL for stats
14398 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14399 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014400 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014401 }
14402 else
14403 {
14404 //save in SME
14405 csrRoamSaveStatsFromTl(pMac, tlStats);
14406 }
14407#endif
14408 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14409 {
14410 if(pMac->roam.tlStatsReqInfo.periodicity)
14411 {
14412 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014413 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14414 pMac->roam.tlStatsReqInfo.periodicity);
14415 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014416 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014417 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014418 return;
14419 }
14420 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14421 }
14422 }
14423}
Jeff Johnson295189b2012-06-20 16:38:30 -070014424void csrRoamPeStatsTimerHandler(void *pv)
14425{
14426 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14427 eHalStatus status;
14428 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14429 VOS_STATUS vosStatus;
14430 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014431 pPeStatsReqListEntry->timerRunning = FALSE;
14432 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14433 {
14434 // If we entered here, meaning the timer could not be successfully
14435 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14436
14437 /* Destroy the timer */
14438 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14439 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14440 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014441 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014442 }
14443
14444 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014445 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014446 pPeStatsReqListEntry = NULL;
14447 }
14448 else
14449 {
14450 if(!pPeStatsReqListEntry->rspPending)
14451 {
14452 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14453 pPeStatsReqListEntry->staId);
14454 if(!HAL_STATUS_SUCCESS(status))
14455 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014456 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014457 }
14458 else
14459 {
14460 pPeStatsReqListEntry->rspPending = TRUE;
14461 }
14462 }
14463
14464 //send down a req
14465 if(pPeStatsReqListEntry->periodicity &&
14466 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14467 {
14468 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14469 if(ePMC_FULL_POWER == powerState)
14470 {
14471 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14472 {
14473 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14474 }
14475 }
14476 else
14477 {
14478 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14479 {
14480 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14481 }
14482 }
14483 //start timer
14484 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14485 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14486 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014487 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014488 return;
14489 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014490 pPeStatsReqListEntry->timerRunning = TRUE;
14491
14492 }
14493
14494 }
14495}
Jeff Johnson295189b2012-06-20 16:38:30 -070014496void csrRoamStatsClientTimerHandler(void *pv)
14497{
14498 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014499 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14500 {
14501#if 0
14502 // TODO Stats fix for multisession
14503 //start the timer
14504 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14505
14506 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14507 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014508 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014509 }
14510#endif
14511 }
14512#if 0
14513 //send up the stats report
14514 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14515 pStaEntry->staId, pStaEntry->pContext);
14516#endif
14517}
14518
14519
14520
Jeff Johnson295189b2012-06-20 16:38:30 -070014521eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14522{
14523 tAniGetPEStatsReq *pMsg;
14524 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014525 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14526 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014527 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014528 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to allocate mem for stats req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014529 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014530 }
14531 // need to initiate a stats request to PE
14532 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14533 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14534 pMsg->staId = staId;
14535 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014536 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014537 if(!HAL_STATUS_SUCCESS(status))
14538 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014539 smsLog(pMac, LOG1, " csrSendMBStatsReqMsg: failed to send down the stats req ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014540 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014541 return status;
14542}
Jeff Johnson295189b2012-06-20 16:38:30 -070014543void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14544{
14545 tAniGetPEStatsRsp *pSmeStatsRsp;
14546 eHalStatus status = eHAL_STATUS_FAILURE;
14547 tListElem *pEntry = NULL;
14548 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14549 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14550 tANI_U32 tempMask = 0;
14551 tANI_U8 counter = 0;
14552 tANI_U8 *pStats = NULL;
14553 tANI_U32 length = 0;
14554 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014555 v_S7_t rssi = 0, snr = 0;
14556 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014557 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014558 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14559 if(pSmeStatsRsp->rc)
14560 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014561 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014562 goto post_update;
14563 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014564 tempMask = pSmeStatsRsp->statsMask;
14565 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014566 /* subtract all statistics from this length, and after processing the entire
14567 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14568 * in this 'stats' message.
14569 */
14570 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014571 //new stats info from PE, fill up the stats strucutres in PMAC
14572 while(tempMask)
14573 {
14574 if(tempMask & 1)
14575 {
14576 switch(counter)
14577 {
14578 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014579 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014580 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14581 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014582 pStats += sizeof(tCsrSummaryStatsInfo);
14583 length -= sizeof(tCsrSummaryStatsInfo);
14584 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014585 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014586 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014587 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14588 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014589 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14590 length -= sizeof(tCsrGlobalClassAStatsInfo);
14591 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014592 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014593 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014594 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14595 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014596 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14597 length -= sizeof(tCsrGlobalClassBStatsInfo);
14598 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014599 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014600 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014601 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14602 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014603 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14604 length -= sizeof(tCsrGlobalClassCStatsInfo);
14605 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014606 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014607 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014608 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14609 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014610 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14611 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014612 }
14613 else
14614 {
14615 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014616 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014617 VOS_ASSERT( 0 );
14618 }
14619 if(!HAL_STATUS_SUCCESS(status))
14620 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014621 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014622 }
14623 pStats += sizeof(tCsrPerStaStatsInfo);
14624 length -= sizeof(tCsrPerStaStatsInfo);
14625 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014626 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014627 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014628 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014629 }
14630 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014631 tempMask >>=1;
14632 counter++;
14633 }
14634 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14635 if (length != 0)
14636 {
14637 pRssi = (tANI_U32*)pStats;
14638 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014639 pStats += sizeof(tANI_U32);
14640 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014641 }
14642 else
14643 {
14644 /* If riva is not sending rssi, continue to use the hack */
14645 rssi = RSSI_HACK_BMPS;
14646 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014647
Jeff Johnson295189b2012-06-20 16:38:30 -070014648 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014649
14650 if (length != 0)
14651 {
14652 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014653 pStats += sizeof(tANI_U32);
14654 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014655 }
14656 else
14657 {
14658 linkCapacity = 0;
14659 }
14660
14661 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014662
14663 if (length != 0)
14664 {
14665 pSnr = (tANI_U32*)pStats;
14666 snr = (v_S7_t)*pSnr;
14667 }
14668 else
14669 {
14670 snr = SNR_HACK_BMPS;
14671 }
14672
14673 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014674post_update:
14675 //make sure to update the pe stats req list
14676 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14677 if(pEntry)
14678 {
14679 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14680 pPeStaEntry->rspPending = FALSE;
14681
14682 }
14683 //check the one timer cases
14684 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14685 if(pEntry)
14686 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014687 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014688 if(pTempStaEntry->timerExpired)
14689 {
14690 //send up the stats report
14691 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14692 pTempStaEntry->staId, pTempStaEntry->pContext);
14693 //also remove from the client list
14694 csrRoamRemoveStatListEntry(pMac, pEntry);
14695 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014696 }
14697 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014698}
Jeff Johnson295189b2012-06-20 16:38:30 -070014699tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14700{
14701 tListElem *pEntry = NULL;
14702 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014703 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014704 if(!pEntry)
14705 {
14706 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014707 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014708 return NULL;
14709 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014710 while( pEntry )
14711 {
14712 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014713 if(pTempStaEntry->statsMask == statsMask)
14714 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014715 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014716 break;
14717 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014718 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14719 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014720 return pEntry;
14721}
14722
Jeff Johnson295189b2012-06-20 16:38:30 -070014723tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14724 tANI_BOOLEAN update)
14725{
14726 tListElem *pEntry;
14727 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014728 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014729 if(!pEntry)
14730 {
14731 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014732 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014733 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014734 return NULL;
14735 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014736 while( pEntry )
14737 {
14738 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014739 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14740 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14741 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014742 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014743 if(update)
14744 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014745 pTempStaEntry->periodicity = pStaEntry->periodicity;
14746 pTempStaEntry->callback = pStaEntry->callback;
14747 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014748 }
14749 break;
14750 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014751 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14752 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014753 return pEntry;
14754}
Jeff Johnson295189b2012-06-20 16:38:30 -070014755tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14756{
14757 tListElem *pEntry;
14758 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014759 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014760 if(!pEntry)
14761 {
14762 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014763 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014764 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014765 return NULL;
14766 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014767 while( pEntry )
14768 {
14769 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014770 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14771 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014772 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014773 break;
14774 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014775 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14776 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014777 return pEntry;
14778}
Jeff Johnson295189b2012-06-20 16:38:30 -070014779eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14780 csrRoamLinkQualityIndCallback callback,
14781 void *pContext)
14782{
14783 pMac->roam.linkQualityIndInfo.callback = callback;
14784 pMac->roam.linkQualityIndInfo.context = pContext;
14785 if( NULL == callback )
14786 {
14787 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14788 }
14789 else
14790 {
14791 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014792 /* do we need to invoke the callback to notify client of initial value ?? */
14793 }
14794 return eHAL_STATUS_SUCCESS;
14795}
Jeff Johnson295189b2012-06-20 16:38:30 -070014796void csrRoamVccTrigger(tpAniSirGlobal pMac)
14797{
14798 eCsrRoamLinkQualityInd newVccLinkQuality;
14799 tANI_U32 ul_mac_loss = 0;
14800 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014801 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14802 /*-------------------------------------------------------------------------
14803 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014804 Check for a change in link quality and notify client if necessary
14805 -------------------------------------------------------------------------*/
14806 ul_mac_loss_trigger_threshold =
14807 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014808 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014809 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014810 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014811 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14812 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014813 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014814 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14815 }
14816 else
14817 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014818 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014819 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14820 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014821 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14822 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014823 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14824 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014825 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014826 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14827 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014828 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014829 newVccLinkQuality );
14830
14831 /* we now invoke the callback once to notify client of initial value */
14832 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14833 pMac->roam.linkQualityIndInfo.context );
14834 //event: EVENT_WLAN_VCC
14835 }
14836 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014837 pMac->roam.vccLinkQuality = newVccLinkQuality;
14838
Jeff Johnson295189b2012-06-20 16:38:30 -070014839}
Jeff Johnson295189b2012-06-20 16:38:30 -070014840VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14841 v_U8_t rssiNotification,
14842 void * context)
14843{
14844 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14845 eCsrRoamLinkQualityInd newVccLinkQuality;
14846 // TODO : Session info unavailable
14847 tANI_U32 sessionId = 0;
14848 VOS_STATUS status = VOS_STATUS_SUCCESS;
14849 /*-------------------------------------------------------------------------
14850 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014851 Check for a change in link quality and notify client if necessary
14852 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014853 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014854 pMac->roam.configParam.vccRssiThreshold);
14855 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
14856 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014857 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070014858 return VOS_STATUS_SUCCESS;
14859 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014860 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
14861 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014862 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070014863 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14864 }
14865 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
14866 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014867 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014868 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14869 }
14870 else
14871 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014872 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070014873 //Set to this so the code below won't do anything
14874 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014875 VOS_ASSERT(0);
14876 }
14877
Jeff Johnson295189b2012-06-20 16:38:30 -070014878 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14879 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014880 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014881 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14882 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014883 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014884 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070014885 /* we now invoke the callback once to notify client of initial value */
14886 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14887 pMac->roam.linkQualityIndInfo.context );
14888 //event: EVENT_WLAN_VCC
14889 }
14890 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014891 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070014892 return status;
14893}
Jeff Johnson295189b2012-06-20 16:38:30 -070014894tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
14895 tDblLinkList *pStaList,
14896 tCsrStatsClientReqInfo *pStaEntry)
14897{
14898 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014899 //if same entity requested for same set of stats with different periodicity &
14900 // callback update it
14901 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
14902 {
14903
Kiet Lam64c1b492013-07-12 13:56:44 +053014904 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
14905 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014906 {
14907 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014908 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014909 return NULL;
14910 }
14911
Jeff Johnson295189b2012-06-20 16:38:30 -070014912 pNewStaEntry->callback = pStaEntry->callback;
14913 pNewStaEntry->pContext = pStaEntry->pContext;
14914 pNewStaEntry->periodicity = pStaEntry->periodicity;
14915 pNewStaEntry->requesterId = pStaEntry->requesterId;
14916 pNewStaEntry->statsMask = pStaEntry->statsMask;
14917 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
14918 pNewStaEntry->pMac = pStaEntry->pMac;
14919 pNewStaEntry->staId = pStaEntry->staId;
14920 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
14921
14922 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
14923 }
14924 return pNewStaEntry;
14925}
14926
Jeff Johnson295189b2012-06-20 16:38:30 -070014927tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
14928 tDblLinkList *pStaList,
14929 tCsrPeStatsReqInfo *pStaEntry)
14930{
14931 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014932 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
14933 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070014934 {
14935 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014936 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070014937 return NULL;
14938 }
14939
Jeff Johnson295189b2012-06-20 16:38:30 -070014940 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
14941 pNewStaEntry->numClient = pStaEntry->numClient;
14942 pNewStaEntry->periodicity = pStaEntry->periodicity;
14943 pNewStaEntry->statsMask = pStaEntry->statsMask;
14944 pNewStaEntry->pMac = pStaEntry->pMac;
14945 pNewStaEntry->staId = pStaEntry->staId;
14946 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
14947 pNewStaEntry->rspPending = pStaEntry->rspPending;
14948
14949 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014950 return pNewStaEntry;
14951}
Jeff Johnson295189b2012-06-20 16:38:30 -070014952eHalStatus csrGetRssi(tpAniSirGlobal pMac,
14953 tCsrRssiCallback callback,
14954 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
14955{
14956 eHalStatus status = eHAL_STATUS_SUCCESS;
14957 vos_msg_t msg;
14958 tANI_U32 sessionId;
14959
14960 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014961 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014962 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
14963 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014964 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014965 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014966 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014967 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014968 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
14969
14970 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
14971 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
14972 pMsg->sessionId = sessionId;
14973 pMsg->staId = staId;
14974 pMsg->rssiCallback = callback;
14975 pMsg->pDevContext = pContext;
14976 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014977 msg.type = eWNI_SME_GET_RSSI_REQ;
14978 msg.bodyptr = pMsg;
14979 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014980 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
14981 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014982 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053014983 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014984 status = eHAL_STATUS_FAILURE;
14985 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014986 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014987 return status;
14988}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080014989
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014990eHalStatus csrGetSnr(tpAniSirGlobal pMac,
14991 tCsrSnrCallback callback,
14992 tANI_U8 staId, tCsrBssid bssId,
14993 void *pContext)
14994{
14995 eHalStatus status = eHAL_STATUS_SUCCESS;
14996 vos_msg_t msg;
14997 tANI_U32 sessionId;
14998
14999 tAniGetSnrReq *pMsg;
15000
15001 smsLog(pMac, LOG2, FL("called"));
15002
15003 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15004 if (NULL == pMsg )
15005 {
15006 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15007 return status;
15008 }
15009
15010 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15011
15012 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15013 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15014 pMsg->sessionId = sessionId;
15015 pMsg->staId = staId;
15016 pMsg->snrCallback = callback;
15017 pMsg->pDevContext = pContext;
15018 msg.type = eWNI_SME_GET_SNR_REQ;
15019 msg.bodyptr = pMsg;
15020 msg.reserved = 0;
15021
15022 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15023 {
15024 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15025 vos_mem_free((v_VOID_t *)pMsg);
15026 status = eHAL_STATUS_FAILURE;
15027 }
15028
15029 smsLog(pMac, LOG2, FL("returned"));
15030 return status;
15031}
15032
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015033#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
15034eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15035 tCsrRssiCallback callback,
15036 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15037{
15038 eHalStatus status = eHAL_STATUS_SUCCESS;
15039 tAniGetRssiReq *pMsg;
15040
Kiet Lam64c1b492013-07-12 13:56:44 +053015041 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15042 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015043 {
15044 smsLog(pMac, LOGE, " csrGetRoamRssi: failed to allocate mem for req");
Kiet Lam64c1b492013-07-12 13:56:44 +053015045 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015046 }
15047 // need to initiate a stats request to PE
15048 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15049 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15050 pMsg->staId = staId;
15051 pMsg->rssiCallback = callback;
15052 pMsg->pDevContext = pContext;
15053 pMsg->pVosContext = pVosContext;
15054 status = palSendMBMessage(pMac->hHdd, pMsg );
15055 if(!HAL_STATUS_SUCCESS(status))
15056 {
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015057 smsLog(pMac, LOG1, " csrGetRoamRssi: failed to send down the rssi req");
15058 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015059 status = eHAL_STATUS_FAILURE;
15060 }
15061 return status;
15062}
15063#endif
15064
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015065
15066
15067#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
15068eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15069 tCsrTsmStatsCallback callback,
15070 tANI_U8 staId,
15071 tCsrBssid bssId,
15072 void *pContext,
15073 void* pVosContext,
15074 tANI_U8 tid)
15075{
15076 eHalStatus status = eHAL_STATUS_SUCCESS;
15077 tAniGetTsmStatsReq *pMsg = NULL;
15078
15079 status = palAllocateMemory(pMac->hHdd, (void **)&pMsg, sizeof(tAniGetTsmStatsReq));
15080 if ( !HAL_STATUS_SUCCESS(status) )
15081 {
15082 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
15083 return status;
15084 }
15085 // need to initiate a stats request to PE
15086 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15087 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15088 pMsg->staId = staId;
15089 pMsg->tid = tid;
15090 palCopyMemory(pMac->hHdd, pMsg->bssId, bssId, sizeof(tSirMacAddr));
15091 pMsg->tsmStatsCallback = callback;
15092 pMsg->pDevContext = pContext;
15093 pMsg->pVosContext = pVosContext;
15094 status = palSendMBMessage(pMac->hHdd, pMsg );
15095 if(!HAL_STATUS_SUCCESS(status))
15096 {
15097 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15098 //pMsg is freed by palSendMBMessage
15099 status = eHAL_STATUS_FAILURE;
15100 }
15101 return status;
15102}
15103#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
15104
15105
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015106/* ---------------------------------------------------------------------------
15107 \fn csrGetTLSTAState
15108 \helper function to get teh TL STA State whenever the function is called.
15109
15110 \param staId - The staID to be passed to the TL
15111 to get the relevant TL STA State
15112 \return the state as tANI_U16
15113 ---------------------------------------------------------------------------*/
15114tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15115{
15116 WLANTL_STAStateType tlSTAState;
15117 tlSTAState = WLANTL_STA_INIT;
15118
15119 //request TL for STA State
15120 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15121 {
15122 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15123 }
15124
15125 return tlSTAState;
15126}
15127
Jeff Johnson295189b2012-06-20 16:38:30 -070015128eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15129 tANI_U32 statsMask,
15130 tCsrStatsCallback callback,
15131 tANI_U32 periodicity, tANI_BOOLEAN cache,
15132 tANI_U8 staId, void *pContext)
15133{
15134 tCsrStatsClientReqInfo staEntry;
15135 tCsrStatsClientReqInfo *pStaEntry = NULL;
15136 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15137 tListElem *pEntry = NULL;
15138 tANI_BOOLEAN found = FALSE;
15139 eHalStatus status = eHAL_STATUS_SUCCESS;
15140 tANI_BOOLEAN insertInClientList = FALSE;
15141 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015142 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015143
15144 if( csrIsAllSessionDisconnected(pMac) )
15145 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015146 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015147 return eHAL_STATUS_FAILURE;
15148 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015149 if((!statsMask) && (!callback))
15150 {
15151 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015152 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015153 return eHAL_STATUS_FAILURE;
15154 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015155 //for the search list method for deregister
15156 staEntry.requesterId = requesterId;
15157 staEntry.statsMask = statsMask;
15158 //requester wants to deregister or just an error
15159 if((statsMask) && (!callback))
15160 {
15161 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15162 if(!pEntry)
15163 {
15164 //msg
15165 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015166 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015167 return eHAL_STATUS_FAILURE;
15168 }
15169 else
15170 {
15171 //clean up & return
15172 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015173 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015174 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015175 pStaEntry->pPeStaEntry->numClient--;
15176 //check if we need to delete the entry from peStatsReqList too
15177 if(!pStaEntry->pPeStaEntry->numClient)
15178 {
15179 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15180 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015181 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015182
Jeff Johnson295189b2012-06-20 16:38:30 -070015183 //check if we need to stop the tl stats timer too
15184 pMac->roam.tlStatsReqInfo.numClient--;
15185 if(!pMac->roam.tlStatsReqInfo.numClient)
15186 {
15187 if(pMac->roam.tlStatsReqInfo.timerRunning)
15188 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015189 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15190 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015191 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015192 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015193 return eHAL_STATUS_FAILURE;
15194 }
15195 }
15196 pMac->roam.tlStatsReqInfo.periodicity = 0;
15197 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15198 }
15199 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015200 // Destroy the vos timer...
15201 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15202 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15203 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015204 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015205 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015206 csrRoamRemoveStatListEntry(pMac, pEntry);
15207 pStaEntry = NULL;
15208 return eHAL_STATUS_SUCCESS;
15209 }
15210 }
15211
15212 if(cache && !periodicity)
15213 {
15214 //return the cached stats
15215 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15216 }
15217 else
15218 {
15219 //add the request in the client req list
15220 staEntry.callback = callback;
15221 staEntry.pContext = pContext;
15222 staEntry.periodicity = periodicity;
15223 staEntry.pPeStaEntry = NULL;
15224 staEntry.staId = staId;
15225 staEntry.pMac = pMac;
15226 staEntry.timerExpired = FALSE;
15227
15228
Jeff Johnson295189b2012-06-20 16:38:30 -070015229 //if periodic report requested with non cached result from PE/TL
15230 if(periodicity)
15231 {
15232
15233 //if looking for stats from PE
15234 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15235 {
15236
15237 //check if same request made already & waiting for rsp
15238 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15239 periodicity, &found, staId);
15240 if(!pPeStaEntry)
15241 {
15242 //bail out, maxed out on number of req for PE
15243 return eHAL_STATUS_FAILURE;
15244 }
15245 else
15246 {
15247 staEntry.pPeStaEntry = pPeStaEntry;
15248 }
15249
15250 }
15251 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15252 if(statsMask & (1 << eCsrGlobalClassDStats))
15253 {
15254 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15255 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015256 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015257 }
15258 else
15259 {
15260
15261 //update periodicity
15262 if(pMac->roam.tlStatsReqInfo.periodicity)
15263 {
15264 pMac->roam.tlStatsReqInfo.periodicity =
15265 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15266 }
15267 else
15268 {
15269 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15270 }
15271 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15272 {
15273 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15274 }
15275
15276 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15277 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015278 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015279 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015280 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015281 //req TL for class D stats
15282 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15283 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015284 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015285 }
15286 else
15287 {
15288 //save in SME
15289 csrRoamSaveStatsFromTl(pMac, pTlStats);
15290 }
15291 vos_mem_free(pTlStats);
15292 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015293 }
15294 else
15295 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015296 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015297 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015298
Jeff Johnson295189b2012-06-20 16:38:30 -070015299 if(pMac->roam.tlStatsReqInfo.periodicity)
15300 {
15301 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015302 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15303 pMac->roam.tlStatsReqInfo.periodicity);
15304 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015305 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015306 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015307 return eHAL_STATUS_FAILURE;
15308 }
15309 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15310 }
15311 }
15312 }
15313 pMac->roam.tlStatsReqInfo.numClient++;
15314 }
15315
15316 insertInClientList = TRUE;
15317 }
15318 //if one time report requested with non cached result from PE/TL
15319 else if(!cache && !periodicity)
15320 {
15321 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15322 {
15323 //send down a req
15324 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15325 if(!HAL_STATUS_SUCCESS(status))
15326 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015327 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015328 }
15329 //so that when the stats rsp comes back from PE we respond to upper layer
15330 //right away
15331 staEntry.timerExpired = TRUE;
15332 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015333 }
15334 if(statsMask & (1 << eCsrGlobalClassDStats))
15335 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015336 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015337 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015338 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015339 //req TL for class D stats
15340 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15341 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015342 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015343 }
15344 else
15345 {
15346 //save in SME
15347 csrRoamSaveStatsFromTl(pMac, pTlStats);
15348 }
15349 vos_mem_free(pTlStats);
15350 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015351 }
15352 else
15353 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015354 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015355 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015356
15357 }
15358 //if looking for stats from TL only
15359 if(!insertInClientList)
15360 {
15361 //return the stats
15362 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15363 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015364 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015365 if(insertInClientList)
15366 {
15367 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15368 if(!pStaEntry)
15369 {
15370 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015371 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015372 return eHAL_STATUS_FAILURE;
15373 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015374 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015375 //Init & start timer if needed
15376 if(periodicity)
15377 {
15378 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15379 csrRoamStatsClientTimerHandler, pStaEntry );
15380 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15381 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015382 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015383 return eHAL_STATUS_FAILURE;
15384 }
15385 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15386 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15387 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015388 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015389 return eHAL_STATUS_FAILURE;
15390 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015391 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015392 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015393 }
15394 return eHAL_STATUS_SUCCESS;
15395}
15396
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015397#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15398
15399static tSirRetStatus
15400csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15401 tANI_U8* pBD,
15402 tANI_U8 type,
15403 tANI_U8 subType,
15404 tSirMacAddr peerAddr,
15405 tSirMacAddr selfMacAddr)
15406{
15407 tSirRetStatus statusCode = eSIR_SUCCESS;
15408 tpSirMacMgmtHdr pMacHdr;
15409
15410 /* Prepare MAC management header */
15411 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15412
15413 /* Prepare FC */
15414 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15415 pMacHdr->fc.type = type;
15416 pMacHdr->fc.subType = subType;
15417
15418 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015419 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15420 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015421
15422 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15423
15424 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015425 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15426 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015427 return statusCode;
15428} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15429
15430static tSirRetStatus
15431csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15432 tANI_U8 nChannelNum,
15433 tANI_U32 dot11mode,
15434 tSirMacAddr selfMacAddr,
15435 tANI_U8 *pFrame,
15436 tANI_U16 *pusLen)
15437{
15438 tDot11fProbeRequest pr;
15439 tANI_U32 nStatus, nBytes, nPayload;
15440 tSirRetStatus nSirStatus;
15441 /*Bcast tx*/
15442 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15443 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15444
15445
Kiet Lam64c1b492013-07-12 13:56:44 +053015446 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015447
15448 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15449
15450 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15451 {
15452 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15453 }
15454
15455
15456 if (IS_DOT11_MODE_HT(dot11mode))
15457 {
15458 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15459 }
15460
15461
15462 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15463 if ( DOT11F_FAILED( nStatus ) )
15464 {
15465 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15466 "Failed to calculate the packed size f"
15467 "or a Probe Request (0x%08x).\n", nStatus );
15468
15469
15470 nPayload = sizeof( tDot11fProbeRequest );
15471 }
15472 else if ( DOT11F_WARNED( nStatus ) )
15473 {
15474 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15475 "There were warnings while calculating"
15476 "the packed size for a Probe Request ("
15477 "0x%08x).\n", nStatus );
15478 }
15479
15480 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15481
15482 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015483 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015484
15485
15486 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015487 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015488
15489 if ( eSIR_SUCCESS != nSirStatus )
15490 {
15491 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15492 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15493 nSirStatus );
15494 return nSirStatus;
15495 }
15496
15497
15498 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15499 sizeof( tSirMacMgmtHdr ),
15500 nPayload, &nPayload );
15501 if ( DOT11F_FAILED( nStatus ) )
15502 {
15503 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15504 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15505 return eSIR_FAILURE;
15506 }
15507 else if ( DOT11F_WARNED( nStatus ) )
15508 {
15509 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15510 "There were warnings while packing a Probe Request (0x%08x).\n" );
15511 }
15512
15513 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15514 return eSIR_SUCCESS;
15515}
15516
15517eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15518{
15519 vos_msg_t msg;
15520 tSirRoamOffloadScanReq *pRequestBuf;
15521 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15522 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015523 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015524 tANI_U8 *ChannelList = NULL;
15525 tANI_U32 sessionId;
15526 eHalStatus status = eHAL_STATUS_SUCCESS;
15527 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015528 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015529 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015530 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15531
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015532 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015533 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015534 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015535 return eHAL_STATUS_FAILURE;
15536 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015537
15538 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15539 {
15540 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15541 return eHAL_STATUS_FAILURE;
15542 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015543 status = csrRoamGetSessionIdFromBSSID(pMac,
15544 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15545 &sessionId);
15546 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15547 * It is important to ensure that the command is passed down to the FW only
15548 * if the Infra Station is in a connected state.A connected station could also be
15549 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15550 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15551 * irrespective of whichever state we are in.*/
15552 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15553 (command != ROAM_SCAN_OFFLOAD_STOP))
15554 {
15555 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Scan Command not sent to FW with state = %d and cmd = %d\n",
15556 pMac->roam.neighborRoamInfo.neighborRoamState, command);
15557 return eHAL_STATUS_FAILURE;
15558 }
15559
15560 if ( !HAL_STATUS_SUCCESS( status ) )
15561 {
15562 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15563 return eHAL_STATUS_FAILURE;
15564 }
15565 pSession = CSR_GET_SESSION( pMac, sessionId );
15566 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15567 if (NULL == pRequestBuf)
15568 {
15569 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15570 return eHAL_STATUS_FAILED_ALLOC;
15571 }
15572
Kiet Lam64c1b492013-07-12 13:56:44 +053015573 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015574 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15575 * host driver reloads, but Riva still up and running*/
15576 if(command == ROAM_SCAN_OFFLOAD_STOP)
15577 pRequestBuf->RoamScanOffloadEnabled = 0;
15578 else
15579 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015580 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15581 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015582 sizeof(tCsrBssid));
15583 pRequestBuf->ConnectedNetwork.ssId.length =
15584 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15585 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15586 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15587 pRequestBuf->ConnectedNetwork.ssId.length);
15588 pRequestBuf->ConnectedNetwork.authentication =
15589 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15590 pRequestBuf->ConnectedNetwork.encryption =
15591 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15592 pRequestBuf->ConnectedNetwork.mcencryption =
15593 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
15594 pRequestBuf->LookupThreshold =
15595 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
15596 pRequestBuf->RoamRssiDiff =
15597 pMac->roam.configParam.RoamRssiDiff;
15598 pRequestBuf->Command = command;
15599 pRequestBuf->StartScanReason = reason;
15600 pRequestBuf->NeighborScanTimerPeriod =
15601 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
15602 pRequestBuf->NeighborRoamScanRefreshPeriod =
15603 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
15604 pRequestBuf->NeighborScanChannelMinTime =
15605 pNeighborRoamInfo->cfgParams.minChannelScanTime;
15606 pRequestBuf->NeighborScanChannelMaxTime =
15607 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
15608 pRequestBuf->EmptyRefreshScanPeriod =
15609 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
15610#ifdef FEATURE_WLAN_CCX
15611 pRequestBuf->IsCCXEnabled = pMac->roam.configParam.isCcxIniFeatureEnabled;
15612#endif
15613 if (
15614#ifdef FEATURE_WLAN_CCX
15615 ((pNeighborRoamInfo->isCCXAssoc) &&
15616 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
15617 eANI_BOOLEAN_FALSE)) ||
15618 (pNeighborRoamInfo->isCCXAssoc == eANI_BOOLEAN_FALSE) ||
15619#endif // CCX
15620 currChannelListInfo->numOfChannels == 0)
15621 {
15622
15623 /*Retreive the Channel Cache either from ini or from the Occupied Channels list.
15624 * Give Preference to INI Channels.*/
15625 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
15626 {
15627 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
15628 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels ;i++)
15629 {
15630 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15631 {
15632 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15633 }
15634 ChannelList++;
15635 }
15636 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15637 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
15638 }
15639 else{
15640 ChannelList = pMac->scan.occupiedChannels.channelList;
15641 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
15642 {
15643 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15644 {
15645 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15646 }
15647 ChannelList++;
15648 }
15649 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15650 /* If the profile changes as to what it was earlier, inform the FW through
15651 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
15652 * for the earlier profile and try to learn them afresh.*/
15653 if (reason == REASON_FLUSH_CHANNEL_LIST)
15654 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
15655 else {
15656 if (csrNeighborRoamIsNewConnectedProfile(pMac))
15657 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
15658 else
15659 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15660 }
15661 }
15662 }
15663#ifdef FEATURE_WLAN_CCX
15664 else
15665 {
15666 /* If CCX is enabled, and a neighbor Report is received,then
15667 * Ignore the INI Channels or the Occupied Channel List. Consider
15668 * the channels in the neighbor list sent by the CCX AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015669 if (currChannelListInfo->numOfChannels != 0)
15670 {
15671 ChannelList = currChannelListInfo->ChannelList;
15672 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015673 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015674 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15675 {
15676 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15677 }
15678 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015679 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015680 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15681 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
15682 }
15683 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015684#endif
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015685 for (i = 0, j = 0; i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
15686 {
15687 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
15688 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
15689 }
15690 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15691 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
15692 pRequestBuf->ChannelCacheType,
15693 pRequestBuf->ConnectedNetwork.ChannelCount,
15694 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015695 num_channels = 0;
15696 ChannelList = NULL;
15697
15698 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070015699 host_channels = sizeof(pMac->roam.validChannelList);
15700 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015701 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070015702 ChannelList = pMac->roam.validChannelList;
15703 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015704 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070015705 else
15706 {
15707 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15708 "%s:Failed to get the valid channel list", __func__);
15709 return eHAL_STATUS_FAILURE;
15710 }
15711 for(i=0; i<pMac->roam.numValidChannels; i++)
15712 {
15713 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
15714 {
15715 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
15716 }
15717 ChannelList++;
15718 }
15719 pRequestBuf->ValidChannelCount = num_channels;
15720
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015721 pRequestBuf->MDID.mdiePresent =
15722 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
15723 pRequestBuf->MDID.mobilityDomain =
15724 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015725 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
15726
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015727 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070015728
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015729 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
15730 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
15731 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
15732 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15733 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
15734
15735 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
15736 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070015737 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015738 msg.reserved = 0;
15739 msg.bodyptr = pRequestBuf;
15740 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
15741 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015742 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
15743 vos_mem_free(pRequestBuf);
15744 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015745 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015746 else
15747 {
15748 if (ROAM_SCAN_OFFLOAD_START == command)
15749 bRoamScanOffloadStarted = VOS_TRUE;
15750 else if (ROAM_SCAN_OFFLOAD_STOP == command)
15751 bRoamScanOffloadStarted = VOS_FALSE;
15752 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015753
15754 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
15755 return status;
15756}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070015757
15758eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
15759{
15760 switch(reason)
15761 {
15762 case 0:
15763 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
15764 break;
15765 case REASON_OS_REQUESTED_ROAMING_NOW:
15766 csrNeighborRoamProceedWithHandoffReq(pMac);
15767 break;
15768 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070015769 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 -070015770 }
15771 return eHAL_STATUS_SUCCESS;
15772}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015773#endif
15774
Jeff Johnson295189b2012-06-20 16:38:30 -070015775tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
15776 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
15777{
15778 tANI_BOOLEAN found = FALSE;
15779 eHalStatus status = eHAL_STATUS_SUCCESS;
15780 tCsrPeStatsReqInfo staEntry;
15781 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
15782 tListElem *pStaEntry = NULL;
15783 VOS_STATUS vosStatus;
15784 tPmcPowerState powerState;
15785 *pFound = FALSE;
15786
15787 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
15788 if(pStaEntry)
15789 {
15790 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
15791 if(pTempStaEntry->periodicity)
15792 {
15793 pTempStaEntry->periodicity =
15794 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
15795 }
15796 else
15797 {
15798 pTempStaEntry->periodicity = periodicity;
15799 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015800 pTempStaEntry->numClient++;
15801 found = TRUE;
15802 }
15803 else
15804 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015805 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015806 staEntry.numClient = 1;
15807 staEntry.periodicity = periodicity;
15808 staEntry.pMac = pMac;
15809 staEntry.rspPending = FALSE;
15810 staEntry.staId = staId;
15811 staEntry.statsMask = statsMask;
15812 staEntry.timerRunning = FALSE;
15813 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
15814 if(!pTempStaEntry)
15815 {
15816 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015817 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015818 return NULL;
15819 }
15820 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015821 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15822 if(ePMC_FULL_POWER == powerState)
15823 {
15824 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15825 {
15826 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15827 }
15828 }
15829 else
15830 {
15831 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15832 {
15833 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15834 }
15835 }
15836 if(!pTempStaEntry->timerRunning)
15837 {
15838 //send down a req in case of one time req, for periodic ones wait for timer to expire
15839 if(!pTempStaEntry->rspPending &&
15840 !pTempStaEntry->periodicity)
15841 {
15842 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15843 if(!HAL_STATUS_SUCCESS(status))
15844 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015845 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015846 }
15847 else
15848 {
15849 pTempStaEntry->rspPending = TRUE;
15850 }
15851 }
15852 if(pTempStaEntry->periodicity)
15853 {
15854 if(!found)
15855 {
15856
15857 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
15858 csrRoamPeStatsTimerHandler, pTempStaEntry );
15859 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15860 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015861 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015862 return NULL;
15863 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015864 }
15865 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015866 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070015867 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
15868 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15869 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015870 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015871 return NULL;
15872 }
15873 pTempStaEntry->timerRunning = TRUE;
15874 }
15875 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015876 *pFound = found;
15877 return pTempStaEntry;
15878}
15879
Jeff Johnson295189b2012-06-20 16:38:30 -070015880/*
15881 pStaEntry is no longer invalid upon the return of this function.
15882*/
15883static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
15884{
15885 if(pEntry)
15886 {
15887 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
15888 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015889 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070015890 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015891 }
15892 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015893
15894void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
15895{
15896 tListElem *pEntry;
15897 tCsrPeStatsReqInfo *pTempStaEntry;
15898 VOS_STATUS vosStatus;
15899 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015900 if(!pEntry)
15901 {
15902 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015903 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: List empty, no stats req for PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015904 return;
15905 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015906 while( pEntry )
15907 {
15908 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015909 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
15910 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015911 smsLog(pMac, LOGW, "csrRoamRemoveEntryFromPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015912 if(pTempStaEntry->timerRunning)
15913 {
15914 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
15915 /* If we are not able to stop the timer here, just remove
15916 * the entry from the linked list. Destroy the timer object
15917 * and free the memory in the timer CB
15918 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015919 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070015920 {
15921 /* the timer is successfully stopped */
15922 pTempStaEntry->timerRunning = FALSE;
15923
15924 /* Destroy the timer */
15925 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
15926 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15927 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015928 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015929 }
15930 }
15931 else
15932 {
15933 // the timer could not be stopped. Hence destroy and free the
15934 // memory for the PE stat entry in the timer CB.
15935 pTempStaEntry->timerStopFailed = TRUE;
15936 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015937 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015938
15939 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
15940 {
15941 // Only free the memory if we could stop the timer successfully
15942 if(!pTempStaEntry->timerStopFailed)
15943 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015944 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070015945 pTempStaEntry = NULL;
15946 }
15947 break;
15948 }
15949
15950 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15951 }
15952 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015953 return;
15954}
15955
15956
Jeff Johnsone7245742012-09-05 17:12:55 -070015957void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015958{
15959
Jeff Johnsone7245742012-09-05 17:12:55 -070015960 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
15961 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
15962 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
15963 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
15964 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
15965 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
15966 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070015967 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015968 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
15969 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
15970 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
15971 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
15972 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
15973 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015974 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070015975 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
15976 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070015977
15978}
15979
Jeff Johnson295189b2012-06-20 16:38:30 -070015980void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
15981 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
15982{
15983 tANI_U8 stats[500];
15984 tANI_U8 *pStats = NULL;
15985 tANI_U32 tempMask = 0;
15986 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015987 if(!callback)
15988 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015989 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015990 return;
15991 }
15992 if(!statsMask)
15993 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015994 smsLog(pMac, LOGE, FL("csrRoamReportStatistics:cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015995 return;
15996 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015997 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015998 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015999 while(tempMask)
16000 {
16001 if(tempMask & 1)
16002 {
16003 //new stats info from PE, fill up the stats strucutres in PMAC
16004 switch(counter)
16005 {
16006 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016007 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016008 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16009 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016010 pStats += sizeof(tCsrSummaryStatsInfo);
16011 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016012 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016013 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016014 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16015 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016016 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016017 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016018 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016019 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016020 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16021 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016022 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016023 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016024 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016025 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016026 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16027 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016028 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016029 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016030 case eCsrGlobalClassDStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016031 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016032 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16033 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016034 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016035 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016036 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016037 smsLog( pMac, LOG2, FL("csrRoamReportStatistics:PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016038 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16039 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016040 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016041 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016042 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016043 smsLog( pMac, LOG1, FL("csrRoamReportStatistics:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016044 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016045 }
16046 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016047 tempMask >>=1;
16048 counter++;
16049 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016050 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016051}
16052
Jeff Johnson295189b2012-06-20 16:38:30 -070016053eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16054{
16055 tListElem *pEntry = NULL;
16056 tListElem *pPrevEntry = NULL;
16057 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16058 eHalStatus status = eHAL_STATUS_SUCCESS;
16059 VOS_STATUS vosStatus;
16060 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016061 if(!pEntry)
16062 {
16063 //list empty
16064 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016065 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016066 return status;
16067 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016068 while( pEntry )
16069 {
16070 if(pPrevEntry)
16071 {
16072 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16073 //send up the stats report
16074 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16075 pTempStaEntry->staId, pTempStaEntry->pContext);
16076 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16077 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016078 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016079 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16080 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016081 pTempStaEntry->pPeStaEntry->numClient--;
16082 //check if we need to delete the entry from peStatsReqList too
16083 if(!pTempStaEntry->pPeStaEntry->numClient)
16084 {
16085 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16086 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016087 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016088 //check if we need to stop the tl stats timer too
16089 pMac->roam.tlStatsReqInfo.numClient--;
16090 if(!pMac->roam.tlStatsReqInfo.numClient)
16091 {
16092 if(pMac->roam.tlStatsReqInfo.timerRunning)
16093 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016094 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16095 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016096 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016097 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016098 //we will continue
16099 }
16100 }
16101 pMac->roam.tlStatsReqInfo.periodicity = 0;
16102 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16103 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016104 if (pTempStaEntry->periodicity)
16105 {
16106 //While creating StaEntry in csrGetStatistics,
16107 //Initializing and starting timer only when periodicity is set.
16108 //So Stop and Destroy timer only when periodicity is set.
16109
Jeff Johnsone7245742012-09-05 17:12:55 -070016110 vos_timer_stop( &pTempStaEntry->timer );
16111 // Destroy the vos timer...
16112 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16113 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16114 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016115 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016116 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016117 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016118
Jeff Johnson295189b2012-06-20 16:38:30 -070016119
16120 pPrevEntry = pEntry;
16121 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16122 }
16123 //the last one
16124 if(pPrevEntry)
16125 {
16126 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16127 //send up the stats report
16128 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16129 pTempStaEntry->staId, pTempStaEntry->pContext);
16130 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16131 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016132 return status;
16133
16134}
16135
Jeff Johnson295189b2012-06-20 16:38:30 -070016136eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16137 tRequestFullPowerReason *pReason,
16138 tANI_BOOLEAN *pfNeedPower )
16139{
16140 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16141 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16142 tPmcState pmcState;
16143 eHalStatus status = eHAL_STATUS_SUCCESS;
16144 // TODO : Session info unavailable
16145 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016146 if( pfNeedPower )
16147 {
16148 *pfNeedPower = eANI_BOOLEAN_FALSE;
16149 }
16150 //We only handle CSR commands
16151 if( !(eSmeCsrCommandMask & pCommand->command) )
16152 {
16153 return eHAL_STATUS_SUCCESS;
16154 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016155 //Check PMC state first
16156 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016157 switch( pmcState )
16158 {
16159 case REQUEST_IMPS:
16160 case IMPS:
16161 if( eSmeCommandScan == pCommand->command )
16162 {
16163 switch( pCommand->u.scanCmd.reason )
16164 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016165#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16166 case eCsrScanGetLfrResult:
16167#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016168 case eCsrScanGetResult:
16169 case eCsrScanBGScanAbort:
16170 case eCsrScanBGScanEnable:
16171 case eCsrScanGetScanChnInfo:
16172 //Internal process, no need for full power
16173 fNeedFullPower = eANI_BOOLEAN_FALSE;
16174 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016175 default:
16176 //Other scans are real scan, ask for power
16177 fNeedFullPower = eANI_BOOLEAN_TRUE;
16178 break;
16179 } //switch
16180 }
16181 else
16182 {
16183 //ask for power for roam and status change
16184 fNeedFullPower = eANI_BOOLEAN_TRUE;
16185 }
16186 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016187 case REQUEST_BMPS:
16188 case BMPS:
16189 case REQUEST_START_UAPSD:
16190 case UAPSD:
16191 //We treat WOWL same as BMPS
16192 case REQUEST_ENTER_WOWL:
16193 case WOWL:
16194 if( eSmeCommandRoam == pCommand->command )
16195 {
16196 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16197 tCsrScanResult *pScanResult;
16198 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016199 switch ( pCommand->u.roamCmd.roamReason )
16200 {
16201 case eCsrForcedDisassoc:
16202 case eCsrForcedDisassocMICFailure:
16203 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16204 fNeedFullPower = eANI_BOOLEAN_TRUE;
16205 break;
16206 case eCsrSmeIssuedDisassocForHandoff:
16207 case eCsrForcedDeauth:
16208 case eCsrHddIssuedReassocToSameAP:
16209 case eCsrSmeIssuedReassocToSameAP:
16210 fNeedFullPower = eANI_BOOLEAN_TRUE;
16211 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016212 case eCsrCapsChange:
16213 fNeedFullPower = eANI_BOOLEAN_TRUE;
16214 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016215 default:
16216 //Check whether the profile is already connected. If so, no need for full power
16217 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16218 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16219 {
16220 //Only need to check the first one
16221 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16222 if( pEntry )
16223 {
16224 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16225#if 0
16226 // TODO : Session Specific info pConnectBssDesc
16227 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16228 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16229 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16230 {
16231 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16232 // with Authenticating first. To force this, stop the current association (Disassociate) and
16233 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16234 // a new Association.
16235 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16236 {
16237 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16238 {
16239 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16240 //No need for full power
16241 //Set the flag so the code later can avoid to do the above
16242 //check again.
16243 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16244 break;
16245 }
16246 }
16247 }
16248#endif
16249 }
16250 }
16251 //If we are here, full power is needed
16252 fNeedFullPower = eANI_BOOLEAN_TRUE;
16253 break;
16254 }
16255 }
16256 else if( eSmeCommandWmStatusChange == pCommand->command )
16257 {
16258 //need full power for all
16259 fNeedFullPower = eANI_BOOLEAN_TRUE;
16260 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16261 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016262#ifdef FEATURE_WLAN_TDLS
16263 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16264 {
16265 //TDLS link is getting established. need full power
16266 fNeedFullPower = eANI_BOOLEAN_TRUE;
16267 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16268 }
16269#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016270 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016271 case REQUEST_STOP_UAPSD:
16272 case REQUEST_EXIT_WOWL:
16273 if( eSmeCommandRoam == pCommand->command )
16274 {
16275 fNeedFullPower = eANI_BOOLEAN_TRUE;
16276 switch ( pCommand->u.roamCmd.roamReason )
16277 {
16278 case eCsrForcedDisassoc:
16279 case eCsrForcedDisassocMICFailure:
16280 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16281 break;
16282 default:
16283 break;
16284 }
16285 }
16286 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016287 case STOPPED:
16288 case REQUEST_STANDBY:
16289 case STANDBY:
16290 case LOW_POWER:
16291 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016292 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016293 status = eHAL_STATUS_FAILURE;
16294 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016295 case FULL_POWER:
16296 case REQUEST_FULL_POWER:
16297 default:
16298 //No need to ask for full power. This has to be FULL_POWER state
16299 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016300 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016301 if( pReason )
16302 {
16303 *pReason = reason;
16304 }
16305 if( pfNeedPower )
16306 {
16307 *pfNeedPower = fNeedFullPower;
16308 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016309 return ( status );
16310}
16311
Jeff Johnson295189b2012-06-20 16:38:30 -070016312static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16313{
16314 eHalStatus status = eHAL_STATUS_SUCCESS;
16315 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16316 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016317 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016318 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16319 {
16320 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16321 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016322 return ( status );
16323}
16324
Jeff Johnson295189b2012-06-20 16:38:30 -070016325tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16326{
16327 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016328 if( pCmd )
16329 {
16330 pMac->roam.sPendingCommands++;
16331 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016332 return ( pCmd );
16333}
16334
Jeff Johnson295189b2012-06-20 16:38:30 -070016335void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16336{
16337 if (pMac->roam.sPendingCommands > 0)
16338 {
16339 //All command allocated through csrGetCommandBuffer need to
16340 //decrement the pending count when releasing.
16341 pMac->roam.sPendingCommands--;
16342 smeReleaseCommand( pMac, pCommand );
16343 }
16344 else
16345 {
16346 smsLog(pMac, LOGE, FL( "no pending commands"));
16347 VOS_ASSERT(0);
16348 }
16349}
16350
Jeff Johnson295189b2012-06-20 16:38:30 -070016351//Return SUCCESS is the command is queued, failed
16352eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16353{
16354 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016355 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16356 {
16357 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16358 pCommand->u.scanCmd.reason);
16359 return eHAL_STATUS_CSR_WRONG_STATE;
16360 }
16361
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016362 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16363 {
16364 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16365 &pCommand->Link, LL_ACCESS_LOCK);
16366 // process the command queue...
16367 smeProcessPendingQueue(pMac);
16368 status = eHAL_STATUS_SUCCESS;
16369 goto end;
16370 }
16371
Jeff Johnson295189b2012-06-20 16:38:30 -070016372 //We can call request full power first before putting the command into pending Q
16373 //because we are holding SME lock at this point.
16374 status = csrRequestFullPower( pMac, pCommand );
16375 if( HAL_STATUS_SUCCESS( status ) )
16376 {
16377 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016378 //make sure roamCmdPendingList is not empty first
16379 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16380 if( fNoCmdPending )
16381 {
16382 smePushCommand( pMac, pCommand, fHighPriority );
16383 }
16384 else
16385 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016386 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016387 //no list lock is needed since SME lock is held
16388 if( !fHighPriority )
16389 {
16390 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16391 }
16392 else {
16393 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16394 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016395 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016396 }
16397 else if( eHAL_STATUS_PMC_PENDING == status )
16398 {
16399 //no list lock is needed since SME lock is held
16400 if( !fHighPriority )
16401 {
16402 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16403 }
16404 else {
16405 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16406 }
16407 //Let caller know the command is queue
16408 status = eHAL_STATUS_SUCCESS;
16409 }
16410 else
16411 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016412 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016413 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016414 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016415 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016416end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016417 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016418}
Jeff Johnson295189b2012-06-20 16:38:30 -070016419eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16420{
16421 eHalStatus status = eHAL_STATUS_SUCCESS;
16422 tSirUpdateAPWPSIEsReq *pMsg;
16423 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16424
16425 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16426 if (NULL == pSession)
16427 {
16428 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16429 return eHAL_STATUS_FAILURE;
16430 }
16431
Jeff Johnson295189b2012-06-20 16:38:30 -070016432 do
16433 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016434 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
16435 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16436 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016437 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
16438
16439 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070016440 VOS_ASSERT(pBuf);
16441
Jeff Johnson295189b2012-06-20 16:38:30 -070016442 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016443 // transactionId
16444 *pBuf = 0;
16445 *( pBuf + 1 ) = 0;
16446 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070016447 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016448 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16449 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016450 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016451 //sessionId
16452 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016453 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016454 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070016455 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070016456 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016457 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016458 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016459 return ( status );
16460}
Jeff Johnson295189b2012-06-20 16:38:30 -070016461eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
16462{
16463 eHalStatus status = eHAL_STATUS_SUCCESS;
16464 tSirUpdateAPWPARSNIEsReq *pMsg;
16465 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016466 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16467 if (NULL == pSession)
16468 {
16469 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16470 return eHAL_STATUS_FAILURE;
16471 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016472 do
16473 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016474 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
16475 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16476 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016477 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016478 pBuf = (tANI_U8 *)&pMsg->transactionId;
16479 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016480 // transactionId
16481 *pBuf = 0;
16482 *( pBuf + 1 ) = 0;
16483 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070016484 VOS_ASSERT(pBuf);
16485
Jeff Johnson295189b2012-06-20 16:38:30 -070016486 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016487 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16488 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016489 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016490 // sessionId
16491 *pBuf++ = (tANI_U8)sessionId;
16492
16493 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016494 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070016495 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070016496 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016497 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016498 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016499 return ( status );
16500}
Jeff Johnson295189b2012-06-20 16:38:30 -070016501
16502#ifdef WLAN_FEATURE_VOWIFI_11R
16503//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
16504eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
16505{
16506 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16507 tpSirFTPreAuthReq pftPreAuthReq;
16508 tANI_U16 auth_req_len = 0;
16509 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016510 auth_req_len = sizeof(tSirFTPreAuthReq);
16511 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053016512 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070016513 {
16514 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
16515 return eHAL_STATUS_RESOURCES;
16516 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016517 // Save the SME Session ID here. We need it while processing the preauth response
16518 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016519 vos_mem_zero(pftPreAuthReq, auth_req_len);
16520
16521 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
16522 sizeof(pBssDescription->length) + pBssDescription->length);
16523
16524 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
16525
16526 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
16527
Kiet Lam64c1b492013-07-12 13:56:44 +053016528 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
16529 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
16530 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
16531 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016532
Jeff Johnson295189b2012-06-20 16:38:30 -070016533#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080016534 if (csrRoamIs11rAssoc(pMac) &&
16535 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070016536 {
16537 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053016538 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
16539 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070016540 }
16541 else
16542#endif
16543 {
16544 pftPreAuthReq->ft_ies_length = 0;
16545 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070016546 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
16547 sizeof(pBssDescription->length) + pBssDescription->length);
16548 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070016549 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
16550}
Jeff Johnson295189b2012-06-20 16:38:30 -070016551/*--------------------------------------------------------------------------
16552 * This will receive and process the FT Pre Auth Rsp from the current
16553 * associated ap.
16554 *
16555 * This will invoke the hdd call back. This is so that hdd can now
16556 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
16557 ------------------------------------------------------------------------*/
16558void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
16559{
16560 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16561 eHalStatus status = eHAL_STATUS_SUCCESS;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016562#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_CCX_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016563 tCsrRoamInfo roamInfo;
16564#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016565
16566#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016567 smsLog( pMac, LOGE, FL("Preauth response status code 0x%x"), pFTPreAuthRsp->status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016568#endif
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016569#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016570 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016571 if (status != eHAL_STATUS_SUCCESS) {
16572 /*
16573 * Bail out if pre-auth was not even processed.
16574 */
16575 smsLog(pMac, LOGW, FL("Preauth was not processed: %d"), status);
16576 return;
16577 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016578#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016579 /* The below function calls/timers should be invoked only if the pre-auth is successful */
16580 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
16581 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070016582 // Implies a success
16583 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016584 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
16585 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070016586 /* No need to notify qos module if this is a non 11r roam*/
16587 if (csrRoamIs11rAssoc(pMac))
16588 {
16589 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
16590 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016591 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
16592 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016593 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
16594 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070016595 if (eHAL_STATUS_SUCCESS != status)
16596 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016597 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016598 return;
16599 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016600 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016601 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
16602 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016603 if (csrRoamIs11rAssoc(pMac))
16604 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
16605 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
16606
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016607#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16608 if (csrRoamIsCCXAssoc(pMac))
16609 {
16610 /* read TSF */
16611 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
16612
16613 // Save the bssid from the received response
16614 palCopyMemory(pMac->hHdd, (void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
16615 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
16616 }
16617#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016618#ifdef FEATURE_WLAN_LFR
16619 // If Legacy Fast Roaming is enabled, signal the supplicant
16620 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053016621 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016622 {
16623 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016624 vos_mem_copy((void *)&roamInfo.bssid,
16625 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016626 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
16627 }
16628
16629#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016630
16631 // Done with it, init it.
16632 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
16633}
16634#endif
16635#ifdef FEATURE_WLAN_BTAMP_UT_RF
16636void csrRoamJoinRetryTimerHandler(void *pv)
16637{
16638 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
16639 tpAniSirGlobal pMac = pInfo->pMac;
16640 tANI_U32 sessionId = pInfo->sessionId;
16641 tCsrRoamSession *pSession;
16642
16643 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16644 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016645 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016646 pSession = CSR_GET_SESSION( pMac, sessionId );
16647 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
16648 {
16649 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
16650 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016651 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016652 }
16653 }
16654 }
16655}
Jeff Johnson295189b2012-06-20 16:38:30 -070016656eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
16657{
16658 eHalStatus status = eHAL_STATUS_FAILURE;
16659 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16660
16661 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
16662 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016663 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070016664 pSession->maxRetryCount--;
16665 pSession->joinRetryTimerInfo.pMac = pMac;
16666 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016667 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
16668 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016669 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016670 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016671 }
16672 }
16673 else
16674 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016675 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070016676 pSession->maxRetryCount);
16677 }
16678
16679 return (status);
16680}
Jeff Johnson295189b2012-06-20 16:38:30 -070016681eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
16682{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016683 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070016684 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
16685 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016686 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070016687 }
16688
16689 return eHAL_STATUS_SUCCESS;
16690}
16691#endif
16692
16693
16694/*
16695 pBuf points to the beginning of the message
16696 LIM packs disassoc rsp as below,
16697 messageType - 2 bytes
16698 messageLength - 2 bytes
16699 sessionId - 1 byte
16700 transactionId - 2 bytes (tANI_U16)
16701 reasonCode - 4 bytes (sizeof(tSirResultCodes))
16702 peerMacAddr - 6 bytes
16703 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
16704*/
16705static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
16706{
16707 if(pBuf && pRsp)
16708 {
16709 pBuf += 4; //skip type and length
16710 pRsp->sessionId = *pBuf++;
16711 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
16712 pBuf += 2;
16713 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
16714 pBuf += 4;
16715 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
16716 }
16717}
16718
Jeff Johnsond13512a2012-07-17 11:42:19 -070016719eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16720{
16721 static uNvTables nvTables;
16722 eHalStatus status = eHAL_STATUS_SUCCESS;
16723 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
16724
16725 /* read the country code from NV and use it */
16726 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
16727 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016728 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
16729 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016730 return status;
16731 }
16732 else
16733 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016734 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016735 status = eHAL_STATUS_FAILURE;
16736 return status;
16737 }
16738}
16739
16740eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
16741{
Kiet Lam64c1b492013-07-12 13:56:44 +053016742 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070016743 return eHAL_STATUS_SUCCESS;
16744}
schang86c22c42013-03-13 18:41:24 -070016745
16746eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
16747{
16748 tSirSetTxPowerReq *pMsg = NULL;
16749 eHalStatus status = eHAL_STATUS_SUCCESS;
16750 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16751
16752 if (!pSession)
16753 {
16754 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16755 return eHAL_STATUS_FAILURE;
16756 }
16757
Kiet Lam64c1b492013-07-12 13:56:44 +053016758 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
16759 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16760 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
16761 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
16762 pMsg->length = sizeof(tSirSetTxPowerReq);
16763 pMsg->mwPower = mW;
16764 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
16765 sizeof(tSirMacAddr));
16766 status = palSendMBMessage(pMac->hHdd, pMsg);
16767 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070016768 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016769 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
16770 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070016771 }
16772 return status;
16773}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016774
16775/* Returns whether a session is in VOS_STA_MODE...or not */
16776tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
16777{
16778 tCsrRoamSession *pSession = NULL;
16779 pSession = CSR_GET_SESSION ( pMac, sessionId );
16780 if(!pSession)
16781 {
16782 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
16783 return eANI_BOOLEAN_FALSE;
16784 }
16785 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
16786 {
16787 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
16788 return eANI_BOOLEAN_FALSE;
16789 }
16790 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
16791 {
16792 return eANI_BOOLEAN_FALSE;
16793 }
16794 /* There is a possibility that the above check may fail,because
16795 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
16796 * when it is connected.So,we may sneak through the above check even
16797 * if we are not a STA mode INFRA station. So, if we sneak through
16798 * the above condition, we can use the following check if we are
16799 * really in STA Mode.*/
16800
16801 if ( NULL != pSession->pCurRoamProfile )
16802 {
16803 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
16804 {
16805 return eANI_BOOLEAN_TRUE;
16806 } else {
16807 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
16808 return eANI_BOOLEAN_FALSE;
16809 }
16810 }
16811
16812 return eANI_BOOLEAN_FALSE;
16813}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016814
16815#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16816eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
16817 tCsrHandoffRequest *pHandoffInfo)
16818{
16819 eHalStatus status = eHAL_STATUS_SUCCESS;
16820 vos_msg_t msg;
16821
16822 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053016823 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
16824 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016825 {
16826 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016827 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016828 }
16829 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
16830 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
16831 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
16832 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053016833 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016834 pHandoffInfo->bssid,
16835 6);
16836 msg.type = eWNI_SME_HANDOFF_REQ;
16837 msg.bodyptr = pMsg;
16838 msg.reserved = 0;
16839 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16840 {
16841 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016842 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016843 status = eHAL_STATUS_FAILURE;
16844 }
16845 return status;
16846}
16847#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016848
16849#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
16850/* ---------------------------------------------------------------------------
16851 \fn csrSetCCKMIe
16852 \brief This function stores the CCKM IE passed by the supplicant in a place holder
16853 data structure and this IE will be packed inside reassociation request
16854 \param pMac - pMac global structure
16855 \param sessionId - Current session id
16856 \param pCckmIe - pointer to CCKM IE data
16857 \param ccKmIeLen - length of the CCKM IE
16858 \- return Success or failure
16859 -------------------------------------------------------------------------*/
16860VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
16861 const tANI_U8 *pCckmIe,
16862 const tANI_U8 ccKmIeLen)
16863{
16864 eHalStatus status = eHAL_STATUS_SUCCESS;
16865 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16866
16867 if (!pSession)
16868 {
16869 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
16870 return eHAL_STATUS_FAILURE;
16871 }
16872 palCopyMemory(pMac->hHdd, pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
16873 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
16874 return status;
16875}
16876
16877/* ---------------------------------------------------------------------------
16878 \fn csrRoamReadTSF
16879 \brief This function reads the TSF; and also add the time elapsed since last beacon or
16880 probe response reception from the hand off AP to arrive at the latest TSF value.
16881 \param pMac - pMac global structure
16882 \param pTimestamp - output TSF timestamp
16883 \- return Success or failure
16884 -------------------------------------------------------------------------*/
16885VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
16886{
16887 eHalStatus status = eHAL_STATUS_SUCCESS;
16888 tCsrNeighborRoamBSSInfo handoffNode;
16889 tANI_U32 timer_diff = 0;
16890 tANI_U32 timeStamp[2];
16891 tpSirBssDescription pBssDescription = NULL;
16892
16893 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
16894 pBssDescription = handoffNode.pBssDescription;
16895
16896 // Get the time diff in milli seconds
16897 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
16898 // Convert msec to micro sec timer
16899 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
16900
16901 timeStamp[0] = pBssDescription->timeStamp[0];
16902 timeStamp[1] = pBssDescription->timeStamp[1];
16903
16904 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
16905
16906 palCopyMemory(pMac->hHdd, pTimestamp, (void *) &timeStamp[0],
16907 sizeof (tANI_U32) * 2);
16908 return status;
16909}
16910
16911#endif /*FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
16912